CLEO Help Make a coordinate teleporter

CLEO related
Status
Not open for further replies.

SiraBots

Active member
Joined
Aug 11, 2013
Messages
50
Reaction score
0
Location
Norway
Hey there.
I'm trying to make a coordinates teleporter, where I can teleport to multiple locations. I use one command, /tp [location], where I can type locations such as "lspd", "lsfd", "bank", etc. I tried coding it, but I can't seem to get it to work. My script is bugged as hell, please take it as a concept and help me out.

This is what I got so far:
Code:
{$CLEO}
0000: NOP
0B34: samp register_client_command "/tp" to_label @cmd
0@ = 0

:MAIN
WAIT 0
IF 0@ == 1
THEN 
    018C: play_sound 1052 at 0.0 0.0 0.0 
    IF 3@ == 'mining'
    THEN
		0972: $PLAYER_ACTOR -1872.6539 -1686.1276 22.1866
    END
	
	IF 3@ == 'lspd'
    THEN
		0972: $PLAYER_ACTOR -1872.6539 -1686.1276 22.1866
    END
    WAIT 2000
    0@ = 0
END
SAMP.CmdRet()
JUMP @MAIN

:CMD
WAIT 0
SAMP.IsCommandTyped(1@)
IF
0AD4: 2@ = scan_string 1@ format "%d" 3@v 
ELSE_JUMP @USAGE
0@ = 1
SAMP.CmdRet()
JUMP @MAIN

:USAGE
WAIT 0
0AF8: samp add_message_to_chat "USAGE: /tp [location]" color -1
0AF8: samp add_message_to_chat "Locations: mining, lspd, lsfd, bank" color GREY
0@ = 0
SAMP.CmdRet()
JUMP @MAIN

Thanks a lot in advance.
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
hi, I think there's no need to use "scan_string", you could do something like this:

Code:
0B35: samp 1@ = get_last_command_params
if 0C18: 31@ = strstr string1 1@ string2 "lspd"  
then
2@ = X 
3@ = Y
4@ = Z
else
   if 0C18: 31@ = strstr string1 1@ string2 "mining"
   then
   2@ = X
   3@ = Y
   4@ = Z
   else
      //if
      //then
      //else
      //end
   end
end
//and then in your main function tp player to 2@ 3@ 4@
 

4changesLeft

Well-known member
Joined
Apr 10, 2015
Messages
365
Reaction score
4
What monday did is a good way of doing it, but your script has some little mistakes that will crash your game and you have to be careful with them
1st: when you want to register a command, use "command" not "/command".
2nd: you can get the color of the texts from this site http://html-color-codes.info/. For example, for grey use 0xA4A4A4, not "GREY".
3rd: Do the "0@ = 0" for the command after the "end" statement.
For example:
END
0@ = 0
SAMP.CmdRet()
JUMP @MAIN

And 4th: if you want to use var@ == something on an IF statement, search for opcodes, or else it wont compile :p
 

SiraBots

Active member
Joined
Aug 11, 2013
Messages
50
Reaction score
0
Location
Norway
monday said:
hi, I think there's no need to use "scan_string", you could do something like this:
Code:
0B35: samp 1@ = get_last_command_params
if 0C18: 31@ = strstr string1 1@ string2 "lspd"  
then
2@ = X 
3@ = Y
4@ = Z
else
   if 0C18: 31@ = strstr string1 1@ string2 "mining"
   then
   2@ = X
   3@ = Y
   4@ = Z
   else
      //if
      //then
      //else
      //end
   end
end
//and then in your main function tp player to 2@ 3@ 4@

I got a little confused now, can you please add your script into my example and complete it? I'm not sure where I should put your code in my script, I get errors when I try to compile. I bet I'm editing it wrong, that's all.
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
here it is:


Code:
{$CLEO}
0000: NOP
0B34: samp register_client_command "tp" to_label @CMD
0@ = 0

:MAIN
WAIT 0
IF 0@ == 1
THEN 
    018C: play_sound 1052 at 0.0 0.0 0.0 
    0972: $PLAYER_ACTOR x 2@ y 3@ z 4@//-1872.6539 -1686.1276 22.1866
    WAIT 2000
    0@ = 0
END
JUMP @MAIN

:CMD
WAIT 0
SAMP.IsCommandTyped(1@)
if 0C18: 31@ = strstr string1 1@ string2 "lspd"  
then
2@ = 0.0// lspd coordinates 
3@ = 0.0
4@ = 0.0
else
    if 0C18: 31@ = strstr string1 1@ string2 "mining"
    then
    2@ = 0.0 //mining coordinates
    3@ = 0.0
    4@ = 0.0
    else
        if 0C18: 31@ = strstr string1 1@ string2 "lsfd"
        then
        2@ = 0.0 //lsfd coordinates
        3@ = 0.0
        4@ = 0.0
        else
            if 0C18: 31@ = strstr string1 1@ string2 "bank"
            then
            2@ = 0.0
            3@ = 0.0
            4@ = 0.0
            else
            jump @USAGE
                //here you could add more places by deleting "jump @USAGE" and adding few lines of code like:
                //if 0C18: 31@ = strstr string1 1@ string2 "new_place"
                //then
                //2@ = 0.0
                //3@ = 0.0
                //4@ = 0.0
                //else
                //jump @USAGE
                //end
            end     
        end
    end
end
//and then in your main function tp player to 2@ 3@ 4@

0@ = 1
SAMP.CmdRet()

:USAGE
WAIT 0
0AF8: samp add_message_to_chat "USAGE: /tp [location]" color -1
0AF8: samp add_message_to_chat "Locations: mining, lspd, lsfd, bank" color -1
0@ = 0
SAMP.CmdRet()

Or alternatively you could do it in a more readable but slightly less efficient way

Code:
{$CLEO}
0000: NOP
0B34: samp register_client_command "tp" to_label @CMD
0@ = 0

:MAIN
WAIT 0
IF 0@ == 1
THEN 
    018C: play_sound 1052 at 0.0 0.0 0.0 
    0972: $PLAYER_ACTOR x 2@ y 3@ z 4@//-1872.6539 -1686.1276 22.1866
    WAIT 2000
    0@ = 0
END
JUMP @MAIN

:CMD
WAIT 0
0@ = 1
SAMP.IsCommandTyped(1@)
if 0C18: 31@ = strstr string1 1@ string2 "lspd"  
then
2@ = 0.0// lspd coordinates 
3@ = 0.0
4@ = 0.0
SAMP.CmdRet()
end

if 0C18: 31@ = strstr string1 1@ string2 "mining"  
then
2@ = 0.0// mining coordinates 
3@ = 0.0
4@ = 0.0
SAMP.CmdRet()
end

if 0C18: 31@ = strstr string1 1@ string2 "lsfd"  
then
2@ = 0.0// lsfd coordinates 
3@ = 0.0
4@ = 0.0
SAMP.CmdRet()
end

if 0C18: 31@ = strstr string1 1@ string2 "bank"  
then
2@ = 0.0// bank coordinates 
3@ = 0.0
4@ = 0.0
SAMP.CmdRet()
end

if 0C18: 31@ = strstr string1 1@ string2 "new_place"  
then
2@ = 0.0// 
3@ = 0.0
4@ = 0.0
SAMP.CmdRet()
end
jump @USAGE

:USAGE
WAIT 0
0AF8: samp add_message_to_chat "USAGE: /tp [location]" color -1
0AF8: samp add_message_to_chat "Locations: mining, lspd, lsfd, bank" color -1
0@ = 0
SAMP.CmdRet()
 
Status
Not open for further replies.
Top