CLEO Help [Cleo HELP] - Two params with different variable types.

CLEO related
Status
Not open for further replies.

couldnot

Active member
Joined
Dec 24, 2018
Messages
25
Reaction score
1
I have this script and i want to use /cmd id reason
and in chat i want it to appear like this /say playername(id) is gay, Reason : bla bla
/sex id

The script detects the player id and player name prefectly but not the reason, any help ?

PHP:
:cmd_70294
   SAMP.IsCommandTyped(20@)
if
0AD4: 4@ = scan_string 20@ format "%d %s" 21@ 22@ 
else_jump @cmd_70295
1@ = SAMP.GetPlayerNickname(21@)
msg "/say This player is gay %s(%d),  reason : %s." 1@ 21@ 22@
msg "/sex %d" 21@
jump @cmd_70296

:cmd_70295
msg "{B8DBFF}Syntax: /sex <Playerid> <Reason>" -1

:cmd_70296
SAMP.CmdRet
Code:
 

cheetahftw1

Active member
Joined
Aug 31, 2018
Messages
39
Reaction score
0
PHP:
:cmd
SAMP.IsCommandTyped(0@)
if 0AD4: 1@ = scan_string 0@ format "%d %s" 2@ 3@v
then
    20@ = SAMP.GetPlayerNickname(2@)
    msg "/say %s(%d) is gay because: %s" -1 20@ 2@ 3@v
else
    msg "{B8DBFF}Syntax: /sex <Playerid> <Reason>" -1
end
cmdret
Code:
It's because of 0AD4 can only output strings to long variables(@v).
 
Last edited:

ItsRobinson

Active member
Joined
Nov 16, 2017
Messages
105
Reaction score
20
PHP:
:is_gay
if
    SAMP.IsCommandTyped(20@)
then
    if
        0AD4: $NOT_USED = scan_string 20@ format "%d %s" $NOT_USED $NOT_USED //Checks format is correct 
    then
        if
            0AD4: $NOT_USED = scan_string 20@ format "%d %s" 21@ $NOT_USED //Stores the int not the string
        then
            alloc 2@ 128 
            format 2@ "%d " 21@ //Fromats a string with the int and a space (need length to remove it from the original string)
            0AB1: @strlen 1 string 2@ return 3@ //strlen without SAMPFUNCS, credits to Parazitas
            format 2@ "%s" 20@ //now we need to store the entire original string to the allocated memory
            005A: 2@ += 3@ //add the strlen return to the memory (this just moves the start from 0 to return)
            chatmsg "Int: %d String: %s" -1 21@ 2@  //Output in chat the int and string
            free 2@         
        end    
    end
end
samp.CmdRet()

:strlen
{
    Example: 0AB1: @strlen 1 string 1@ return: 3@
    In: 0@ - text;
    Out: 1@ - size;
}
for 1@ = 0 to 1024
    0A8D: 2@ = read_memory 0@ size 1 virtual_protect 0
    if not 2@ == 0
    jf break
    0@ += 1
end
0AB2: ret 1 1@

@cheetahftw1 is sort of right, but in my experience, you can only save up to a certain amount of characters in the long string varaibles until it breaks the other variable.

My code above might be the wrong way of doing it, but it works :D
Xvi5QrH.png
 

couldnot

Active member
Joined
Dec 24, 2018
Messages
25
Reaction score
1
PHP:
:is_gay
if
    SAMP.IsCommandTyped(20@)
then
    if
        0AD4: $NOT_USED = scan_string 20@ format "%d %s" $NOT_USED $NOT_USED //Checks format is correct
    then
        if
            0AD4: $NOT_USED = scan_string 20@ format "%d %s" 21@ $NOT_USED //Stores the int not the string
        then
            alloc 2@ 128
            format 2@ "%d " 21@ //Fromats a string with the int and a space (need length to remove it from the original string)
            0AB1: @strlen 1 string 2@ return 3@ //strlen without SAMPFUNCS, credits to Parazitas
            format 2@ "%s" 20@ //now we need to store the entire original string to the allocated memory
            005A: 2@ += 3@ //add the strlen return to the memory (this just moves the start from 0 to return)
            chatmsg "Int: %d String: %s" -1 21@ 2@  //Output in chat the int and string
            free 2@        
        end   
    end
end
samp.CmdRet()

:strlen
{
    Example: 0AB1: @strlen 1 string 1@ return: 3@
    In: 0@ - text;
    Out: 1@ - size;
}
for 1@ = 0 to 1024
    0A8D: 2@ = read_memory 0@ size 1 virtual_protect 0
    if not 2@ == 0
    jf break
    0@ += 1
end
0AB2: ret 1 1@

@cheetahftw1 is sort of right, but in my experience, you can only save up to a certain amount of characters in the long string varaibles until it breaks the other variable.

My code above might be the wrong way of doing it, but it works
Thanks a lot bro!
 
Status
Not open for further replies.
Top