Quantcast

Jump to content

» «
Photo

Car NAvigation

13 replies to this topic
kiffz
  • kiffz

    Player Hater

  • Members
  • Joined: 14 Apr 2012

#1

Posted 14 April 2012 - 06:10 PM

HI @ all, me again, i scripted another mod, which should navigate the Car to an Specified Target on the marker, two questions...

1. Why isn´t it working
2. If it would be working, will it work on SAMP?

CODE

// This file was decompiled using sascm.ini published by Seemann (http://sannybuilder.com/files/SASCM.rar) on 13.10.2007

{$VERSION 3.1.0027}
{$CLEO .cs}

//-------------MAIN---------------
wait 0
:CARNAV_0
if
   Actor.Defined($PLAYER_ACTOR)
else_jump @CARNAV_0
jump @CARNAV_1

:CARNAV_1
if and
0ADC:   test_cheat "CNAV"
   Actor.Driving($PLAYER_ACTOR)
   not Actor.Dead($PLAYER_ACTOR)
else_jump @CARNAV_1
4@ = 10.0
00BC: show_text_highpriority GXT 'CHEAT1' time 1000 flag 1
018C: play_sound 1058 at 0.0 0.0 0.0
jump @CARNAV_2

:CARNAV_2
0AB6: store_target_marker_coords_to 1@ 2@ 3@
03C0: 0@ = actor $PLAYER_ACTOR car
if
   Car.Defined(0@)
else_jump @CARNAV_2
00AE: set_car 0@ traffic_behaviour_to 2
0423: set_car 0@ improved_handling_to 2.0

Car.DriveTo(0@,1@,2@,3@)
Car.SetSpeedInstantly(0@,4@)
jump @CARNAV_3

:CARNAV_3
if
0AB0: key_pressed 107
else_jump @CARNAV_4
4@ += 10.0


:CARNAV_4
if
0AB0: key_pressed 109
else_jump @CARNAV_5
4@ -= 10

:CARNAV_5
if
0AB0:   key_pressed 87
else_jump @CARNAV_6
Car.RemoveReferences(0@)

:CARNAV_6
if
0AB0:   key_pressed 83
else_jump @CARNAV_7
Car.RemoveReferences(0@)


:CARNAV_7
if
0ADC:   test_cheat "CNAV"
else_jump @CARNAV_2
Car.RemoveReferences(0@)
jump @CARNAV_0



ED-E
  • ED-E

    War. War never changes.

  • Members
  • Joined: 31 May 2010
  • None

#2

Posted 14 April 2012 - 06:19 PM

Firstly, Whenever using If statements you must include a wait in there otherwise the game will crash

The label is ' :CARNAV_0 ' and you are placing wait opcodes outside of this, Incorrect coding!
Place wait opcodes inside the labels with If statements, Always.

Also, You see here:

CODE
jump @CARNAV_1

:CARNAV_1


The code automatically runs down the script meaning you don't have to guide its every move, A jump here isn't needed, Get rid.

Refurbished code:

CODE
{$CLEO .cs}
0000:

:CARNAV_0
wait 0
if
  Actor.Defined($PLAYER_ACTOR)
jf @CARNAV_0

:CARNAV_1
wait 0
if and
0ADC:   test_cheat "CNAV"
  Actor.Driving($PLAYER_ACTOR)
  not Actor.Dead($PLAYER_ACTOR)
jf @CARNAV_1
4@ = 10.0
00BC: show_text_highpriority GXT 'CHEAT1' time 1000 flag 1
018C: play_sound 1058 at 0.0 0.0 0.0

:CARNAV_2
0AB6: store_target_marker_coords_to 1@ 2@ 3@
03C0: 0@ = actor $PLAYER_ACTOR car
wait 0
if
  Car.Defined(0@)
jf @CARNAV_2
00AE: set_car 0@ traffic_behaviour_to 2
0423: set_car 0@ improved_handling_to 2.0
Car.DriveTo(0@,1@,2@,3@)
Car.SetSpeedInstantly(0@,4@)

:CARNAV_3
wait 0
if
0AB0: key_pressed 107
jf @CARNAV_4
4@ += 10.0

:CARNAV_4
wait 0
if
0AB0: key_pressed 109
jf @CARNAV_5
4@ -= 10

:CARNAV_5
wait 0  
if
0AB0:   key_pressed 87
jf @CARNAV_6
Car.RemoveReferences(0@)

:CARNAV_6
wait 0
if
0AB0:   key_pressed 83
jf @CARNAV_7
Car.RemoveReferences(0@)

:CARNAV_7
wait 0
if
0ADC:   test_cheat "CNAV"
jf @CARNAV_2
Car.RemoveReferences(0@)
jump @CARNAV_0


Hope it works icon14.gif

Bad.boy!
  • Bad.boy!

    SA modder

  • Feroci
  • Joined: 20 Jun 2010
  • Netherlands

#3

Posted 14 April 2012 - 06:22 PM Edited by Bad.boy!, 14 April 2012 - 06:23 PM.

You forgot a lot of waits again...
It should work, but you'll drive on car paths and be an easy target. And if an admin sees you drive perfect like the AI and he is suspicious you're f*cked.

EDIT: To late again

kiffz
  • kiffz

    Player Hater

  • Members
  • Joined: 14 Apr 2012

#4

Posted 14 April 2012 - 06:23 PM

thank you very much, but one question left...
will it run at samp, for other players like me, or is it like, they wil see me enter the car and see me exitting it?
(sry for my bad english biggrin.gif )

Bad.boy!
  • Bad.boy!

    SA modder

  • Feroci
  • Joined: 20 Jun 2010
  • Netherlands

#5

Posted 14 April 2012 - 06:24 PM

QUOTE (kiffz @ Apr 14 2012, 18:23)
thank you very much, but one question left...
will it run at samp, for other players like me, or is it like, they wil see me enter the car and see me exitting it?
(sry for my bad english biggrin.gif )


QUOTE (Bad.boy! @ Apr 14 2012, 18:22)
You forgot a lot of waits again...
It should work, but you'll drive on car paths and be an easy target. And if an admin sees you drive perfect like the AI and he is suspicious you're f*cked.

EDIT: To late again


Finally I can use multiquote for a reason

LINK/2012
  • LINK/2012

    LIVIN' IN CODE

  • Feroci
  • Joined: 30 Jan 2011
  • Brazil

#6

Posted 14 April 2012 - 06:31 PM

QUOTE
Firstly, Whenever using If statements you must include a wait in there otherwise the game will crash

Nooo, This will just slows the script.

You only need a wait when: You need to wait a specific time OR when you should interrupt your script actions to game process other things, like ghapics rendering etc...

So, when you are in a loop that will take time you should use a wait, otherwise only your script will be processed, the rest of the game will be freeze until you use wait to say, Ok My work is done!

kiffz
  • kiffz

    Player Hater

  • Members
  • Joined: 14 Apr 2012

#7

Posted 14 April 2012 - 07:27 PM Edited by kiffz, 14 April 2012 - 08:41 PM.

another bug i found... Why isn´t this part working:

Here is the Part with the bug
CODE

:CARNAV_7
6@ = Car.Health(0@)
wait 0
if or
01F3:   car 0@ in_air
5@ >= 6@                     // TO absorb missunderstandins, this is the errored line of code... the compiler says,
                                   // that i cannot compare those two variables
                                   // and i´ve tested every possible comparisson operator :O
Car.Wrecked(0@)
jf @CARNAV_8
Car.SetSpeedInstantly(0@,4@)
wait 10
Car.SetSpeedInstantly(0@,0.0)
Car.RemoveReferences(0@)


This is the full Script, in which it fits into
CODE

{$CLEO .cs}
0000:

:CARNAV_0
wait 0
if
 Actor.Defined($PLAYER_ACTOR)
jf @CARNAV_0

:CARNAV_1
wait 0
if and
0ADC:   test_cheat "CACA"
 Actor.Driving($PLAYER_ACTOR)
 not Actor.Dead($PLAYER_ACTOR)
jf @CARNAV_1
4@ = 10.0
00BC: show_text_highpriority GXT 'CHEAT1' time 1000 flag 1
018C: play_sound 1058 at 0.0 0.0 0.0

:CARNAV_2
0AB6: store_target_marker_coords_to 1@ 2@ 3@
03C0: 0@ = actor $PLAYER_ACTOR car
5@ = Car.Health(0@)
wait 0
if
 Car.Defined(0@)
jf @CARNAV_2
00AE: set_car 0@ traffic_behaviour_to 2
0423: set_car 0@ improved_handling_to 2.0
Car.DriveTo(0@,1@,2@,3@)
Car.SetMaxSpeed(0@, 4@)
Car.SetSpeedInstantly(0@,4@)

:CARNAV_3
wait 0
if
0AB0: key_pressed 107
jf @CARNAV_4
4@ += 10.0
jump @CARNAV_2

:CARNAV_4
wait 0
if
0AB0: key_pressed 109
jf @CARNAV_5
4@ -= 10
jump @CARNAV_2

:CARNAV_5
wait 0  
if
0AB0:   key_pressed 87
jf @CARNAV_6
Car.RemoveReferences(0@)

:CARNAV_6
wait 0
if
0AB0:   key_pressed 83
jf @CARNAV_7
Car.RemoveReferences(0@)

:CARNAV_7
6@ = Car.Health(0@)
wait 0
if or
01F3:   car 0@ in_air
5@ >= 6@
Car.Wrecked(0@)
jf @CARNAV_8
Car.SetSpeedInstantly(0@,4@)
wait 10
Car.SetSpeedInstantly(0@,0.0)
Car.RemoveReferences(0@)


:CARNAV_8
wait 0
if
   4@ > 150.0
jf @CARNAV_9
4@ -= 10.0
jump @CARNAV_2

:CARNAV_9
wait 0
if
0ADC:   test_cheat "CACA"
jf @CARNAV_2
Car.RemoveReferences(0@)
jump @CARNAV_1



and the next question is following: How do i detect, if my car collides with a building, latern or so on, bcause, i use SetSpeedInstantly, and this is gay, because if my car crashes to another car or house or whatever, it starts to fly, and it should not fly, on an RL SAMP server

I think i can make this up, with the Car Damage, but i cannot compare the Car Damage Values, as you See.
May Someone wants to help me, makin this Mod 100% FUD for Admins? Expect the Driving on Carpaths, this is impossible to change...

kiffz
  • kiffz

    Player Hater

  • Members
  • Joined: 14 Apr 2012

#8

Posted 14 April 2012 - 07:45 PM

may i get some help please :/

Bad.boy!
  • Bad.boy!

    SA modder

  • Feroci
  • Joined: 20 Jun 2010
  • Netherlands

#9

Posted 14 April 2012 - 08:28 PM

No one will help you cheating on samp.
And that part doesn't work, because you removed refrences to the car.

And have some more more patient. We don't have to help you.

kiffz
  • kiffz

    Player Hater

  • Members
  • Joined: 14 Apr 2012

#10

Posted 14 April 2012 - 08:31 PM Edited by kiffz, 14 April 2012 - 08:38 PM.

i know, that wasn´t an order, it was a question, sry it wasn´t ment, like you understood :O

another missunderstanding, no everything works, exept this comparisson with 5@ and 6@, and i dont know why, but it seems to be the '<' operator or the, but all of those smaller / greater operators don´t work at this line of code, a few lines beyond i used the '>' operator, and it works perfectly :O

kiffz
  • kiffz

    Player Hater

  • Members
  • Joined: 14 Apr 2012

#11

Posted 14 April 2012 - 08:52 PM

Now the Operator should work, but it doesn´t

CODE

{$CLEO .cs}
0000:

:CARNAV_0
wait 0
if
 Actor.Defined($PLAYER_ACTOR)
jf @CARNAV_0

:CARNAV_1
wait 0
if and
0ADC:   test_cheat "CACA"
 Actor.Driving($PLAYER_ACTOR)
 not Actor.Dead($PLAYER_ACTOR)
jf @CARNAV_1
4@ = 10.0
00BC: show_text_highpriority GXT 'CHEAT1' time 1000 flag 1
018C: play_sound 1058 at 0.0 0.0 0.0

:CARNAV_2
0AB6: store_target_marker_coords_to 1@ 2@ 3@
03C0: 0@ = actor $PLAYER_ACTOR car
5@ = Car.Health(0@)
wait 0
if
 Car.Defined(0@)
jf @CARNAV_2
00AE: set_car 0@ traffic_behaviour_to 2
0423: set_car 0@ improved_handling_to 2.0
Car.DriveTo(0@,1@,2@,3@)
Car.SetMaxSpeed(0@, 4@)
Car.SetSpeedInstantly(0@,4@)

:CARNAV_3
wait 0
if
0AB0: key_pressed 107
jf @CARNAV_4
4@ += 10.0
jump @CARNAV_2

:CARNAV_4
wait 0
if
0AB0: key_pressed 109
jf @CARNAV_5
4@ -= 10
jump @CARNAV_2

:CARNAV_5
wait 0  
if
0AB0:   key_pressed 87
jf @CARNAV_6
Car.RemoveReferences(0@)
jump @CARNAV_1

:CARNAV_6
wait 0
if
0AB0:   key_pressed 83
jf @CARNAV_7
Car.RemoveReferences(0@)
jump @CARNAV_1

:CARNAV_7
6@ = Car.Health(0@)
wait 0
if or
01F3:   car 0@ in_air
not 5@ > 6@   // This operation lets the compiler respond with an error: Unknown Expression One of those Variables has an incompatible type or the Operator does not exist - WHY?!
Car.Wrecked(0@)
jf @CARNAV_8
Car.SetSpeedInstantly(0@,4@)
wait 10
Car.SetSpeedInstantly(0@,0.0)
Car.RemoveReferences(0@)
jump @CARNAV_1


:CARNAV_8
wait 0
if
   4@ > 150.0
jf @CARNAV_9
4@ -= 10.0
jump @CARNAV_2

:CARNAV_9
wait 0
if
0ADC:   test_cheat "CACA"
jf @CARNAV_2
Car.RemoveReferences(0@)
jump @CARNAV_1


Can Someone Help me please? :(

LINK/2012
  • LINK/2012

    LIVIN' IN CODE

  • Feroci
  • Joined: 30 Jan 2011
  • Brazil

#12

Posted 14 April 2012 - 09:02 PM

Because you should say to the compiler the variable type (Int\Float\String), so it can get the right opcode.

Read Sanny Builder Help > Coding > Variables

kiffz
  • kiffz

    Player Hater

  • Members
  • Joined: 14 Apr 2012

#13

Posted 14 April 2012 - 09:57 PM

QUOTE
Because you should say to the compiler the variable type (Int\Float\String), so it can get the right opcode.
            Read Sanny Builder Help > Coding > Variables


Thank you very much, but i do not get more intelligent out of this, this is makin me a bit confused wow.gif
Can you explain to me please, what i am doing, and what is wrong on that?
It would be really nice

Deji
  • Deji

    Coding like a Rockstar!

  • Feroci
  • Joined: 24 Dec 2007
  • None

#14

Posted 14 April 2012 - 11:40 PM

QUOTE (kiffz @ Saturday, Apr 14 2012, 21:57)
QUOTE
Because you should say to the compiler the variable type (Int\Float\String), so it can get the right opcode.
            Read Sanny Builder Help > Coding > Variables


Thank you very much, but i do not get more intelligent out of this, this is makin me a bit confused wow.gif
Can you explain to me please, what i am doing, and what is wrong on that?
It would be really nice

CODE
not 5@ > 6@


Sanny doesn't know whether you're comparing floats or integers. So it doesn't know which opcode to use. You can either enter the correct opcode manually or define the variables types (as Link2012 said, read SB's help documentation).




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users