Read commands and do something about them

was this tutorial useful to you?

  • Yes.

    Votes: 5 45.5%
  • No.

    Votes: 3 27.3%
  • Kinda.

    Votes: 3 27.3%

  • Total voters
    11

blackHat

Well-Known Member
Joined
Jul 28, 2013
Messages
931
Likes
0
Points
16
#1
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"
[email protected] = 0  // = 0 make it not active

:main
wait 0                                  
if 
  [email protected] == 1  //check if it is active
jf @main

//your codes are here 
//ps: >> player(target) id = [email protected]
// player(target) car = [email protected]

[email protected] = 0      //after you finishing your coding , make it = 0 to deactive it  
SAMP.CmdRet
jump @main









:start
wait 0 
   SAMP.IsCommandTyped([email protected])
if 
0AD4: [email protected] = scan_string [email protected] format "%d" [email protected] 
else_jump @USAGE
if 
   SAMP.IsPlayerConnected([email protected])
else_jump @INVLID_ID 
[email protected] = SAMP.GetActorHandleByPlayerID([email protected])
if 
056D:   actor [email protected] defined      //the target actor = [email protected]
else_jump @NOT_STREAMED 


// here you can do more conditions like:
if                          
    Actor.Driving([email protected])
else_jump @NOT_DRIVING
00D9: [email protected] = actor [email protected] car
[email protected] = 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  
[email protected] = 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  
[email protected] = 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
[email protected] = 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
[email protected] = 0 //make it false so  the main label don't start
goto @main


some people may ask what is [email protected] = 0 & [email protected] = 1?
well [email protected] is a random variable , we can use any like [email protected] [email protected] [email protected] ..etc ([email protected] - [email protected])
we use this to make the script do start the cheat if [email protected] = 1

so in the very begging we declare the variable [email protected] 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 [email protected] = 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 [email protected] = 1 so the label MAIN can be run and function,


so we add this:

Code:
[email protected] = 1    // = 1 make it active
SAMP.CmdRet
goto @main


now after we put our conditions, we say if all are true then make [email protected] = 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 [email protected] = 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 [email protected] = 1 or not

here we already make it [email protected] = 1 in label start
so the Label MAIN is going to run normal , and after it finished it reset [email protected] to 0 to end the cheat


now:
[email protected] = 1 means true
[email protected] = 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
Likes
0
Points
16
#2
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:
 
OP
OP
blackHat

blackHat

Well-Known Member
Joined
Jul 28, 2013
Messages
931
Likes
0
Points
16
#3
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

Well-Known Member
Joined
Jun 23, 2014
Messages
919
Likes
4
Points
18
#4
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?
 
OP
OP
blackHat

blackHat

Well-Known Member
Joined
Jul 28, 2013
Messages
931
Likes
0
Points
16
#5
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"
[email protected] = 0  // = 0 make it not active

:main
wait 0                                  
if 
  [email protected] == 1  //check if it is active
jf @main

//your codes are here 
//ps: >> player(target) id = [email protected]
// player(target) car = [email protected]

//get the none streamed player coords 
0B2F: samp get_streamed_out_player_pos [email protected] to [email protected] [email protected] [email protected]
// [email protected] = target , [email protected] = x , [email protected] = y , [email protected] = z


[email protected] = 0      //after you finishing your coding , make it = 0 to deactive it  
SAMP.CmdRet
jump @main









:start
wait 0 
   SAMP.IsCommandTyped([email protected])
if 
0AD4: [email protected] = scan_string [email protected] format "%d %d" [email protected] 
else_jump @USAGE
if 
   SAMP.IsPlayerConnected([email protected])
else_jump @INVLID_ID 
[email protected] = SAMP.GetActorHandleByPlayerID([email protected])  // the player id is [email protected] , no need to check for define
// here you can do more conditions like:
if                          
    Actor.Driving($PLAYER_ACTOR)
else_jump @NOT_DRIVING
00D9: [email protected] = actor [email protected] car
if 
056E:   car [email protected] defined
else_jump @not_defined

[email protected] = 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  
[email protected] = 0 
SAMP.CmdRet

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

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

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

monday

Well-Known Member
Joined
Jun 23, 2014
Messages
919
Likes
4
Points
18
#6
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.

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"
[email protected] = 0  // = 0 make it not active

:main
wait 0                                  
if 
  [email protected] == 1  //check if it is active
jf @main

0B2F: samp get_streamed_out_player_pos [email protected] to [email protected] [email protected] [email protected]
02A7: [email protected] = create_icon_marker_and_sphere radar_icon_or_model 61 at [email protected] [email protected] [email protected]
wait 10000
0164: disable_marker [email protected]


[email protected] = 0      //after you finishing your coding , make it  [email protected] = 0 to deactive it  
SAMP.CmdRet
jump @main




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

[email protected] = 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  
[email protected] = 0 
SAMP.CmdRet

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

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

:not_defined
wait 0 
0AF8: samp add_message_to_chat "ERROR: Invalid vehicle ID" color 12451840  
SAMP.CmdRet
[email protected] = 0 
goto @main
 
OP
OP
blackHat

blackHat

Well-Known Member
Joined
Jul 28, 2013
Messages
931
Likes
0
Points
16
#7
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.

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"
[email protected] = 0  // = 0 make it not active

:main
wait 0                                  
if 
  [email protected] == 1  //check if it is active
jf @main

0B2F: samp get_streamed_out_player_pos [email protected] to [email protected] [email protected] [email protected]
02A7: [email protected] = create_icon_marker_and_sphere radar_icon_or_model 61 at [email protected] [email protected] [email protected]
wait 10000
0164: disable_marker [email protected]


[email protected] = 0      //after you finishing your coding , make it  [email protected] = 0 to deactive it  
SAMP.CmdRet
jump @main




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

[email protected] = 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  
[email protected] = 0 
SAMP.CmdRet

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

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

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


ok let see

Code:
{$CLEO .cs}

0000: NOP
0B34: samp register_client_command "abc" to_label @start 
[email protected] = 0 

:main
wait 0                                  
if 
  [email protected] == 1  //check if it is active
jf @main
repeat
wait 0
0B2F: samp get_streamed_out_player_pos [email protected] to [email protected] [email protected] [email protected]
02A7: [email protected] = create_icon_marker_and_sphere radar_icon_or_model 61 at [email protected] [email protected] [email protected]
UNTIL 0AB0: key_pressed 49 // key 1
// this will loop until you press key 1 
[email protected] = 0      
SAMP.CmdRet
jump @main




:start
wait 0 
   SAMP.IsCommandTyped([email protected])
if 
0AD4: [email protected] = scan_string [email protected] format "%d" [email protected] 
else_jump @USAGE
if 
   SAMP.IsPlayerConnected([email protected])
else_jump @INVLID_ID 
[email protected] = SAMP.GetActorHandleByPlayerID([email protected])  // the player id is [email protected] 
// here you can do more conditions
[email protected] = 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  
[email protected] = 0 
SAMP.CmdRet

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

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

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

this should work
 

monday

Well-Known Member
Joined
Jun 23, 2014
Messages
919
Likes
4
Points
18
#8
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 [email protected] position_to [email protected] [email protected] [email protected]
instead of:
0B2F: samp get_streamed_out_player_pos [email protected] to [email protected] [email protected] [email protected]
works well but only for local players

Edit:
It works now, I changed one thing
0B2F: samp get_streamed_out_player_pos 4@ to [email protected] [email protected] [email protected]
into
0B2F: samp get_streamed_out_player_pos 2@ to [email protected] [email protected] [email protected]

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.
 
OP
OP
blackHat

blackHat

Well-Known Member
Joined
Jul 28, 2013
Messages
931
Likes
0
Points
16
#9
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 [email protected] [email protected] [email protected]
into
0B2F: samp get_streamed_out_player_pos 2@ to [email protected] [email protected] [email protected]
hmmm :me_gusta:

[email protected] the player him self
[email protected] is the id of the player

so [email protected] = $PLAYER_ACTOR
[email protected] = 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?
 
OP
OP
blackHat

blackHat

Well-Known Member
Joined
Jul 28, 2013
Messages
931
Likes
0
Points
16
#11
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

Well-Known Member
Joined
Jun 23, 2014
Messages
919
Likes
4
Points
18
#12
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:
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
 
OP
OP
blackHat

blackHat

Well-Known Member
Joined
Jul 28, 2013
Messages
931
Likes
0
Points
16
#13
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

Well-Known Member
Joined
Jun 23, 2014
Messages
919
Likes
4
Points
18
#14
Re: +)read commands and do something about -TUT--open source codes

It places the blip always at the same spot
 
OP
OP
blackHat

blackHat

Well-Known Member
Joined
Jul 28, 2013
Messages
931
Likes
0
Points
16
#15
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

Well-Known Member
Joined
Jun 23, 2014
Messages
919
Likes
4
Points
18
#16
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?
 
OP
OP
blackHat

blackHat

Well-Known Member
Joined
Jul 28, 2013
Messages
931
Likes
0
Points
16
#17
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

Well-Known Member
Joined
Jun 23, 2014
Messages
919
Likes
4
Points
18
#18
Re: +)read commands and do something about -TUT--open source codes

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

blackHat

Well-Known Member
Joined
Jul 28, 2013
Messages
931
Likes
0
Points
16
#19
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

Well-Known Member
Joined
Jun 23, 2014
Messages
919
Likes
4
Points
18
#20
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