CLEO Help [LOCK] Part of the name that return the Samp Player ? [LOCK]

CLEO related
Status
Not open for further replies.

Grubitsh

Active member
Joined
Jul 28, 2014
Messages
104
Reaction score
0
Hi, for one of my cleo, I need a function in which you enter a part of the player name then it return the samp player ?

Like /[cmd] Opcode_E
Returns Player Opcode_Exe and do things after

I tried with:


Code:
:command
0B35: samp 31@ = get_last_command_params

if
0AD4:   0@ = scan_string 31@ format "%s" 1@
then       

 for 25@ = 0 to 400 step 1
 
 26@ = samp.GetPlayerNickname(25@)
 
 if
 0C21: stricmp string1 26@ 1@ string2
 then
 // Do things here
end
end
end
0B43: cmd_ret

But it give me error. What could I do ?
 

Hidend

Expert
Joined
Mar 4, 2013
Messages
625
Reaction score
39
Re: Part of the name that return the SampPlayerId ?

:get_playerid_by_name
for 1@ = 0 to 1000
    if SAMP.IsPlayerConnected(1@)
    then
        2@ = SAMP.GetPlayerNickname(1@)
        if 0C14: strcmp string1 0@ string2 2@
        then
        3@ = 1@
        break
        end
    end
end
0ab2: ret 1 3@
 

Grubitsh

Active member
Joined
Jul 28, 2014
Messages
104
Reaction score
0
Re: Part of the name that return the Samp Player ?

Thanks for answering.
WIth this I have to type the entire name of the player ( due to if 0C14: strcmp string1 0@ string2 2@)

Is their a way to enter only a part of the name? (/[command] Mike_J assuming Mike_Jefferson is online).

I looked here in string opcode but I didn't get what I want.
http://blast.hk/wiki/opcodes:sampfuncs:list
 
Joined
Feb 18, 2005
Messages
2,963
Reaction score
267
Re: Part of the name that return the Samp Player ?

Use 0C18(case sensitive) or 0C29(case insensitive).
It searches for a substring in a string.

not tested  :sadpepe:
Code:
:test
0B35: 0@
0C17: 1@ = strlen 0@
IF 1@ > 0
THEN
    FOR 25@ = 0 to 400
        IF SAMP.IsPlayerConnected(25@)
        THEN
            26@ = SAMP.GetPlayerNickname(25@)
            IF 0C29: 27@ = stristr sz1 26@ sz2 0@
            THEN
                0AF8: "Player %s(%d) name contains %s" -1 26@ 25@ 0@
            END
        END
    END
END
cmdret
 

Grubitsh

Active member
Joined
Jul 28, 2014
Messages
104
Reaction score
0
Re: Part of the name that return the Samp Player ?

Thx springfield for answering.

Not working :(

I tried
0C29
0C28
0C21
0C14

All of them make me write the entire name, instead of that it doesn't work. (but no crash at all).

NOTE: I am on SAMPFUNCS 5.2.1 (not latest version).
I might have a problem with string opcodes, see another problem here -> http://ugbase.eu/help-7/(admin-checker-creator)-get-player-from-a-txt-file-15135/
 
Joined
Feb 18, 2005
Messages
2,963
Reaction score
267
Re: Part of the name that return the Samp Player ?

I just tested the code i gave you above, it work flawlessly.

Usage:
Code:
/test the
Result:
Code:
[13:10:32] Player TheWoolf(18) name contains the
[13:10:32] Player TheEmreRo(54) name contains the
[13:10:32] Player TheMaxINFINITE(97) name contains the
[13:10:32] Player DeathTheKid(116) name contains the
[13:10:32] Player TheDoruWTF(125) name contains the
[13:10:32] Player [9mm]The_Punisher=]](140) name contains the
[13:10:32] Player TheCrazyPizda(156) name contains the
[13:10:32] Player [RSS]ImTheKiller(173) name contains the
[13:10:32] Player [HoT]xXTheAlexuXx(244) name contains the
[13:10:32] Player TheAntipatik(258) name contains the
[13:10:32] Player TheLongSixxteen(262) name contains the

So if it doesn't work in your mod, you're doing/using it wrong.
 

Grubitsh

Active member
Joined
Jul 28, 2014
Messages
104
Reaction score
0
Re: Part of the name that return the Samp Player ?

Because I am dumb I inverted the variables in the 0C29, so yes, he couldn't get the entire name into the short name ^^

Working Perfectly, thanks Springfield !

LOCK
 
Status
Not open for further replies.
Top