hello guys , this is off topic xD
this means it is kinda related to the tutorial series but it is just for open source codes![Stick out tongue :p :p](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
this will read your command like (/get , /spawn , /kill) ..etc and do something about
the following code generally took from [member=6677]TH3RM4L[/member] , i wanted to share it because it is very simple and easy to understand , i got it from some cleo that he made (open source) -- you better say thanks to him too.
i edit some of it to make it easier and the explanations are in comments in the place you need it .
big mistakes has been fixed !
some people may ask what is 31@ = 0 & 31@ = 1?
well 31@ is a random variable , we can use any like 11@ 2@ 5@ ..etc (0@ - 33@)
we use this to make the script do start the cheat if 31@ = 1
so in the very begging we declare the variable 31@ to = 0 (means all stuff is off)
the script then will wait until we type the command to active the cheat
while it is waiting it will start to loop in the MAIN label and check if 31@ = 1
so if it is = 1 than it will run the other codes under the "jf @"
but when we type the command we jump to the start label
here there is many conditions we need it to be true
so we add our conditions and if all is true we make 31@ = 1 so the label MAIN can be run and function,
so we add this:
now after we put our conditions, we say if all are true then make 31@ = 1
then we put "SAMP.CmdRet" this is to retrieve the command line (because we work with commands and we registered the command in the first place , so we have to end it , and we do this with SAMP.CmdRet" )
then we add "goto @main" it means " jump @main"
so after all conditions are true we make 31@ = 1 // and 1 means active , 0 means inactive
and after we retrieve the command line
we jump to the main so now the script can check if 31@ = 1 or not
here we already make it 31@ = 1 in label start
so the Label MAIN is going to run normal , and after it finished it reset 31@ to 0 to end the cheat
now:
31@ = 1 means true
31@ = 0 means false
these used to check to run the script
thanks for following my offtopic sources .
this means it is kinda related to the tutorial series but it is just for open source codes
this will read your command like (/get , /spawn , /kill) ..etc and do something about
the following code generally took from [member=6677]TH3RM4L[/member] , i wanted to share it because it is very simple and easy to understand , i got it from some cleo that he made (open source) -- you better say thanks to him too.
i edit some of it to make it easier and the explanations are in comments in the place you need it .
big mistakes has been fixed !
Code:
{$CLEO .cs}
0000: NOP
0B34: samp register_client_command "target" to_label @start //now when you type "/target id" it will run
//to change just replace target with any word you like >>
// like 0B34: samp register_client_command "whatever" to_label @start >> now "/whatever id"
31@ = 0 // = 0 make it not active
:main
wait 0
if
31@ == 1 //check if it is active
jf @main
//your codes are here
//ps: >> player(target) id = 4@
// player(target) car = 6@
31@ = 0 //after you finishing your coding , make it = 0 to deactive it
SAMP.CmdRet
jump @main
:start
wait 0
SAMP.IsCommandTyped(0@)
if
0AD4: 1@ = scan_string 0@ format "%d" 2@
else_jump @USAGE
if
SAMP.IsPlayerConnected(2@)
else_jump @INVLID_ID
4@ = SAMP.GetActorHandleByPlayerID(2@)
if
056D: actor 4@ defined //the target actor = 4@
else_jump @NOT_STREAMED
// here you can do more conditions like:
if
Actor.Driving(4@)
else_jump @NOT_DRIVING
00D9: 6@ = actor 4@ car
31@ = 1 // = 1 make it active
SAMP.CmdRet //retrieve the command line
goto @main
:USAGE
wait 0
0AF8: samp add_message_to_chat "USAGE: /target <player ID> <veh ID>" color 12566463
31@ = 0 //make it false so the main label don't start
SAMP.CmdRet //retrieve the command line
goto @main
:NOT_STREAMED
wait 0
0AF8: samp add_message_to_chat "ERROR: The target is not streamed" color 12451840
31@ = 0 //make it false so the main label don't start
SAMP.CmdRet //retrieve the command line
goto @main
:INVLID_ID
wait 0
0AF8: samp add_message_to_chat "ERROR: Invalid player ID" color 12451840
SAMP.CmdRet //retrieve the command line
31@ = 0 //make it false so the main label don't start
goto @main
:NOT_DRIVING
wait 0
0AF8: samp add_message_to_chat "ERROR: The target must be driving" color 12451840
SAMP.CmdRet //retrieve the command line
31@ = 0 //make it false so the main label don't start
goto @main
some people may ask what is 31@ = 0 & 31@ = 1?
well 31@ is a random variable , we can use any like 11@ 2@ 5@ ..etc (0@ - 33@)
we use this to make the script do start the cheat if 31@ = 1
so in the very begging we declare the variable 31@ to = 0 (means all stuff is off)
the script then will wait until we type the command to active the cheat
while it is waiting it will start to loop in the MAIN label and check if 31@ = 1
so if it is = 1 than it will run the other codes under the "jf @"
but when we type the command we jump to the start label
here there is many conditions we need it to be true
so we add our conditions and if all is true we make 31@ = 1 so the label MAIN can be run and function,
so we add this:
Code:
31@ = 1 // = 1 make it active
SAMP.CmdRet
goto @main
now after we put our conditions, we say if all are true then make 31@ = 1
then we put "SAMP.CmdRet" this is to retrieve the command line (because we work with commands and we registered the command in the first place , so we have to end it , and we do this with SAMP.CmdRet" )
then we add "goto @main" it means " jump @main"
so after all conditions are true we make 31@ = 1 // and 1 means active , 0 means inactive
and after we retrieve the command line
we jump to the main so now the script can check if 31@ = 1 or not
here we already make it 31@ = 1 in label start
so the Label MAIN is going to run normal , and after it finished it reset 31@ to 0 to end the cheat
now:
31@ = 1 means true
31@ = 0 means false
these used to check to run the script
thanks for following my offtopic sources .