Help with function On/Off

Status
Not open for further replies.

Zonex

New member
Joined
Aug 4, 2016
Messages
1
Reaction score
0
Hey guys , who can help me for on/off fuction..​

I want use this code for command.. ​

example: /speed1 ant o driving on 90km/h , /speed1 again, and come normaly speed...​

Srr for bad english :)



Code:
:ACC_20
wait 1 
if and
   Actor.Driving($PLAYER_ACTOR)
84A7:   not actor $PLAYER_ACTOR driving_boat 
jf @ACC_20 
$C = Actor.CurrentCar($PLAYER_ACTOR)
Car.SetImmunities($C, 1, 1, 1, 1, 1)
if and
0AB0:   key_pressed 57 
0AB0:   key_pressed 221
jf @ACC_94 
Car.SetSpeedInstantly($C, 90.0)
0ACD: show_text_highpriority "~R~[3]~W~ - Pavara." time 1337 

:ACC_94
wait 1 
if and
   Actor.Driving($PLAYER_ACTOR)
84A7:   not actor $PLAYER_ACTOR driving_boat
0AB0:   key_pressed 57 
0AB0:   key_pressed 219 
jf @ACC_134 
Car.SetSpeedInstantly($C, 60.0)
0ACD: show_text_highpriority "~R~[2]~W~ - Pavara." time 1337 

:ACC_134
wait 1 
if and
   Actor.Driving($PLAYER_ACTOR)
84A7:   not actor $PLAYER_ACTOR driving_boat
0AB0:   key_pressed 57
0AB0:   key_pressed 80 
else_jump @ACC_20
Car.SetSpeedInstantly($C, 25.0)
0ACD: show_text_highpriority "~R~[1]~W~ - Pavara." time 1337 
  
if or
   Car.Wrecked($C)
02BF:   car $C sunk 
01F4:   car $C flipped 
8202:   not actor $PLAYER_ACTOR near_car $C radius 150.0 150.0 sphere 0 
jf @ACC_20 
Car.RemoveReferences($C)
jump @ACC_20
 

4changesLeft

Well-known member
Joined
Apr 10, 2015
Messages
365
Reaction score
3
This is the opcode you use for on/off with same cmd/key: 0B12: 0@ = 0@ XOR 1
This is an example for how u use it:

if
key_down 1
then
0B12: 0@ = 0@ XOR 1
if
0@ == 1
then
//ON
else
//OFF
end
end
 

Zonex

New member
Joined
Aug 4, 2016
Messages
1
Reaction score
0
I'm try this, or i not understand you..

I make this and not work..

0B34: samp register_client_command "test" to_label @testspeed
...
:testspeed
0001: wait 0 ms
if
key_down 1
then
0B12: 0@ = 0@ XOR 1
if
0@ == 1
then
//ON
0AF8: samp add_message_to_chat "{0099FF} [»]{FF9900}ON!" 0xFFFFFFAA
$C = Actor.CurrentCar($PLAYER_ACTOR)
Car.SetSpeedInstantly($C, 90.0)
else
//OFF
0AF8: samp add_message_to_chat "{0099FF} [»]{FF9900}OFF!" 0xFFFFFFAA
end
end
Samp.CmdRet()
 

4changesLeft

Well-known member
Joined
Apr 10, 2015
Messages
365
Reaction score
3
when you call a function with command (on your script the "testspeed" function) you cant put "if key down" inside.. because the function will be called once, every time you enter the command.. the key_Down should be on another function
 

Zonex

New member
Joined
Aug 4, 2016
Messages
1
Reaction score
0
Sorry again , can you edit my script :D please :D to me is to hard understand you :)
 

4changesLeft

Well-known member
Joined
Apr 10, 2015
Messages
365
Reaction score
3
:loop
wait 0
if
0@ == 1
then
if
key_down 1
then
//DO STUFF
end
end
jump @loop

:testspeed
if
//actor defined $player_Actor opcode here
then
0B12: 0@ = 0@ XOR 1
if
0@ == 1
then
//ON MESSAGE
else
//OFF MESSAGE
end
end
Samp.CmdRet()
jump @loop
 
Status
Not open for further replies.
Top