Read commands and do something about them

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 :p


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 .

 

Spix

Well-known member
Joined
Sep 23, 2013
Messages
353
Reaction score
1
Re: +)read commands and do something about -TUT--open source codes

Blackhat it was good, but i dont need any target...

I just want when i type command /deagle,

i want my cleo's to activate in order.


I type /deagle

1: I want this to get activated first

2: then this second

3:  then this last.



And the 1 one is the one that turns on a NOP.

Because the 3 one is the turn off button thats turns off the 1 thats the NOP

And the 2 one is a thing that spawns..

it must be in order, can you help me with that?

I just need help with the /deagle that activate things in order..

Thanks mate, Hope you can help me with this!

Sincerly spexx!  :urtheman:
 

blackHat

Expert
Joined
Jul 28, 2013
Messages
930
Reaction score
2
Re: +)read commands and do something about -TUT--open source codes

[member=6201]SpexxTr0n[/member]
Will this is like snippet it is stable and you have to adjust it as you like

I didn't get what u mean like /deagle1 and /deagle2 ...etc

And if so responed so i can adjust it for you
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
149
Re: +)read commands and do something about -TUT--open source codes

Hi, I tried to use the code you provided to find the location of a specific player but it works only for local players ("invalid ID" notification appears when the player moves like 150 meters away). Is there any way to adjust the code so I'll be able to find any player on the full map?
 

blackHat

Expert
Joined
Jul 28, 2013
Messages
930
Reaction score
2
Re: +)read commands and do something about -TUT--open source codes

monday link said:
Hi, I tried to use the code you provided to find the location of a specific player but it works only for local players ("invalid ID" notification appears when the player moves like 150 meters away). Is there any way to adjust the code so I'll be able to find any player on the full map?

there was a mistake in the code i fixed it so it give you the right massage

for your question i think  yes you can  by using this

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@

//get the none streamed player coords 
0B2F: samp get_streamed_out_player_pos 4@ to 7@ 8@ 9@
// 4@ = target , 7@ = x , 8@ = y , 9@ = z


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 %d" 2@ 
else_jump @USAGE
if 
   SAMP.IsPlayerConnected(2@)
else_jump @INVLID_ID 
4@ = SAMP.GetActorHandleByPlayerID(2@)  // the player id is 4@ , no need to check for define
// here you can do more conditions like:
if                          
    Actor.Driving($PLAYER_ACTOR)
else_jump @NOT_DRIVING
00D9: 6@ = actor 4@ car
if 
056E:   car 5@ defined
else_jump @not_defined

31@ = 1    // = 1 make it active
SAMP.CmdRet
goto @main 

:USAGE
wait 0 
0AF8: samp add_message_to_chat "USAGE: /target <player ID> <veh ID>" color 12566463  
31@ = 0 
SAMP.CmdRet

:INVLID_ID
wait 0 
0AF8: samp add_message_to_chat "ERROR: Invalid player ID" color 12451840  
SAMP.CmdRet
31@ = 0 
goto @main 

:NOT_DRIVING
wait 0 
0AF8: samp add_message_to_chat "ERROR: The target must be  driving" color 12451840  
SAMP.CmdRet
31@ = 0 
goto @main 

:not_defined
wait 0 
0AF8: samp add_message_to_chat "ERROR: Invalid vehicle ID" color 12451840  
SAMP.CmdRet
31@ = 0 
goto @main
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
149
Re: +)read commands and do something about -TUT--open source codes

Hmm I tested it on 2 servers and unfortunately the code doesn't show the desired player but always shows the same place. I attached it in the spoiler below.
zwf2xaB.jpg

That's the code i was using
Code:
{$CLEO .cs}

0000: NOP
0B34: samp register_client_command "abc" 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

0B2F: samp get_streamed_out_player_pos 4@ to 20@ 21@ 22@
02A7: 30@ = create_icon_marker_and_sphere radar_icon_or_model 61 at 20@ 21@ 22@
wait 10000
0164: disable_marker 30@


31@ = 0      //after you finishing your coding , make it  31@ = 0 to deactive it  
SAMP.CmdRet
jump @main




:start
wait 0 
   SAMP.IsCommandTyped(0@)
if 
0AD4: 1@ = scan_string 0@ format "%d %d" 2@ 
else_jump @USAGE
if 
   SAMP.IsPlayerConnected(2@)
else_jump @INVLID_ID 
4@ = SAMP.GetActorHandleByPlayerID(2@)  // the player id is 4@ , no need to check for define
// here you can do more conditions

31@ = 1    // = 1 make it active
SAMP.CmdRet
goto @main 






:USAGE
wait 0 
0AF8: samp add_message_to_chat "USAGE: /target <player ID> <veh ID>" color 12566463  
31@ = 0 
SAMP.CmdRet

:INVLID_ID
wait 0 
0AF8: samp add_message_to_chat "ERROR: Invalid player ID" color 12451840  
SAMP.CmdRet
31@ = 0 
goto @main 

:NOT_DRIVING
wait 0 
0AF8: samp add_message_to_chat "ERROR: The target must be  driving" color 12451840  
SAMP.CmdRet
31@ = 0 
goto @main 

:not_defined
wait 0 
0AF8: samp add_message_to_chat "ERROR: Invalid vehicle ID" color 12451840  
SAMP.CmdRet
31@ = 0 
goto @main
 

blackHat

Expert
Joined
Jul 28, 2013
Messages
930
Reaction score
2
Re: +)read commands and do something about -TUT--open source codes

monday link said:
Hmm I tested it on 2 servers and unfortunately the code doesn't show the desired player but always shows the same place. I attached it in the spoiler below.
zwf2xaB.jpg

That's the code i was using
Code:
{$CLEO .cs}

0000: NOP
0B34: samp register_client_command "abc" 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

0B2F: samp get_streamed_out_player_pos 4@ to 20@ 21@ 22@
02A7: 30@ = create_icon_marker_and_sphere radar_icon_or_model 61 at 20@ 21@ 22@
wait 10000
0164: disable_marker 30@


31@ = 0      //after you finishing your coding , make it  31@ = 0 to deactive it  
SAMP.CmdRet
jump @main




:start
wait 0 
   SAMP.IsCommandTyped(0@)
if 
0AD4: 1@ = scan_string 0@ format "%d %d" 2@ 
else_jump @USAGE
if 
   SAMP.IsPlayerConnected(2@)
else_jump @INVLID_ID 
4@ = SAMP.GetActorHandleByPlayerID(2@)  // the player id is 4@ , no need to check for define
// here you can do more conditions

31@ = 1    // = 1 make it active
SAMP.CmdRet
goto @main 






:USAGE
wait 0 
0AF8: samp add_message_to_chat "USAGE: /target <player ID> <veh ID>" color 12566463  
31@ = 0 
SAMP.CmdRet

:INVLID_ID
wait 0 
0AF8: samp add_message_to_chat "ERROR: Invalid player ID" color 12451840  
SAMP.CmdRet
31@ = 0 
goto @main 

:NOT_DRIVING
wait 0 
0AF8: samp add_message_to_chat "ERROR: The target must be  driving" color 12451840  
SAMP.CmdRet
31@ = 0 
goto @main 

:not_defined
wait 0 
0AF8: samp add_message_to_chat "ERROR: Invalid vehicle ID" color 12451840  
SAMP.CmdRet
31@ = 0 
goto @main



ok let see

Code:
{$CLEO .cs}

0000: NOP
0B34: samp register_client_command "abc" to_label @start 
31@ = 0 

:main
wait 0                                  
if 
  31@ == 1  //check if it is active
jf @main
repeat
wait 0
0B2F: samp get_streamed_out_player_pos 4@ to 20@ 21@ 22@
02A7: 30@ = create_icon_marker_and_sphere radar_icon_or_model 61 at 20@ 21@ 22@
UNTIL 0AB0: key_pressed 49 // key 1
// this will loop until you press key 1 
31@ = 0      
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@)  // the player id is 4@ 
// here you can do more conditions
31@ = 1    // = 1 make it active
SAMP.CmdRet
goto @main 






:USAGE
wait 0 
0AF8: samp add_message_to_chat "USAGE: /target <player ID> <veh ID>" color 12566463  
31@ = 0 
SAMP.CmdRet

:INVLID_ID
wait 0 
0AF8: samp add_message_to_chat "ERROR: Invalid player ID" color 12451840  
SAMP.CmdRet
31@ = 0 
goto @main 

:NOT_DRIVING
wait 0 
0AF8: samp add_message_to_chat "ERROR: The target must be  driving" color 12451840  
SAMP.CmdRet
31@ = 0 
goto @main 

:not_defined
wait 0 
0AF8: samp add_message_to_chat "ERROR: Invalid vehicle ID" color 12451840  
SAMP.CmdRet
31@ = 0 
goto @main


this should work
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
149
Re: +)read commands and do something about -TUT--open source codes

The same situation occurs. I wonder why because the same code with:
00A0: store_actor 4@ position_to 20@ 21@ 22@
instead of:
0B2F: samp get_streamed_out_player_pos 4@ to 20@ 21@ 22@
works well but only for local players

Edit:
It works now, I changed one thing
0B2F: samp get_streamed_out_player_pos 4@ to 20@ 21@ 22@
into
0B2F: samp get_streamed_out_player_pos 2@ to 20@ 21@ 22@

Edit2:
I found out that it works on some servers and it doesn't on the other. If there are blips on the radar for each player on the server then it works. If there is no blips on the radar then it just doesn't work somehow.
 

blackHat

Expert
Joined
Jul 28, 2013
Messages
930
Reaction score
2
Re: +)read commands and do something about -TUT--open source codes

monday link said:
It works now, I changed one thing
0B2F: samp get_streamed_out_player_pos 4@ to 20@ 21@ 22@
into
0B2F: samp get_streamed_out_player_pos 2@ to 20@ 21@ 22@

hmmm :me_gusta:

4@is the player him self
2@ is the id of the player

so 4@ = $PLAYER_ACTOR
2@ = id like id 5 or 13 ..etc

i wonder why it worked with 2 o.o


this should not work only for local players
as the code says "streamed_out" , you got cleo 4.1?
 

blackHat

Expert
Joined
Jul 28, 2013
Messages
930
Reaction score
2
Re: +)read commands and do something about -TUT--open source codes

this code replace the id with the player heh so if you typed id 5 you get player handle so let say 6?
it is different stuff, i don't why that opcode give you streamed players only heh
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
149
Re: +)read commands and do something about -TUT--open source codes

Hmm the code that was giving me the streamed players only was this one:
00A0: store_actor 4@ position_to 20@ 21@ 22@

The other one:
0B2F: samp get_streamed_out_player_pos 2@ to 20@ 21@ 22@
works well but only on servers that have the blips on the radar for every player, like DM or racing servers. On RP servers where players are "hidden" it doesn't work. I wonder why
 

blackHat

Expert
Joined
Jul 28, 2013
Messages
930
Reaction score
2
Re: +)read commands and do something about -TUT--open source codes

monday link said:
Hmm the code that was giving me the streamed players only was this one:
The other one:works well but only on servers that have the blips on the radar for every player, like DM or racing servers. On RP servers where players are "hidden" it doesn't work. I wonder why

oh so the code is working meh , thought it was broken
anyways the servers that has hidden players ,is (i think) a protection for such things , so they simply disable the function that register players places

but even with that ,i thought this code should work , hmm idk xD
what does the script return with servers like RP?
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
149
Re: +)read commands and do something about -TUT--open source codes

It places the blip always at the same spot
zwf2xaB.jpg
 

blackHat

Expert
Joined
Jul 28, 2013
Messages
930
Reaction score
2
Re: +)read commands and do something about -TUT--open source codes

ah ok this means the script doesn't get the coords of the player
so it make a marker on the map at 0.0 0.0 0.0 (the center of gta)
it is blocked by the server , try to search for opcodes that may help , but i think this could be done with memories ?[member=60]Opcode.eXe[/member] 
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
149
Re: +)read commands and do something about -TUT--open source codes

Hmm I'm not sure but TH3RM4L who made player finder says it's not possible to find streamed out players on servers that have map blips for players disabled.

Btw I have one more question regarding the code, what is the "Samp.CmdRet" about?
 

blackHat

Expert
Joined
Jul 28, 2013
Messages
930
Reaction score
2
Re: +)read commands and do something about -TUT--open source codes

monday link said:
Hmm I'm not sure but TH3RM4L who made player finder says it's not possible to find streamed out players on servers that have map blips for players disabled.

Btw I have one more question regarding the code, what is the "Samp.CmdRet" about?
Ofcourse because the function is disabled by the server, i already explained this , here u go:

(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" )
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
149
Re: +)read commands and do something about -TUT--open source codes

Oh, thanks, I get it now:) End in order to use again.
 

blackHat

Expert
Joined
Jul 28, 2013
Messages
930
Reaction score
2
Re: +)read commands and do something about -TUT--open source codes

monday link said:
Oh, thanks, I get it now:) End in order to use again.
Exactly :) , you are welcome bro :D
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
149
Re: +)read commands and do something about -TUT--open source codes

Is it possible to turn on something with a command and then turn it off by using the same command?

Example:
/abc to enable
/abc to disable (or do any other action when the command is typed second time)
 
Top