SA-MP Forums Archive
strfind else if - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: strfind else if (/showthread.php?tid=362050)



strfind else if - JaKe Elite - 23.07.2012

Hello
i have problem, my players can even use the /iloveyou command which is for me only

i add a checking system which checks if the player who use the command is Romel but its not working
code

pawn Код:
CMD:iloveyou(playerid, params[])
{
    new str[128];
    if(strfind(GetpName(playerid), "Romel", false) != -1)
    {
        format(str, sizeof(str), "LOVE: %s(%d) says I Love You", GetpName(playerid), playerid);
        SendClientMessageToAll(COLOR_YELLOW, str);
        SendClientMessage(playerid, COLOR_GREEN, "*** You said I Love You ***");
    }
    else if(strfind(GetpName(playerid), "Katy", false) != -1)
    {
        format(str, sizeof(str), "LOVE: %s(%d) says I Love You to Romel", GetpName(playerid), playerid);
        SendClientMessageToAll(COLOR_YELLOW, str);
        SendClientMessage(playerid, COLOR_GREEN, "*** You said I Love You to Romel ***");
    }
    else return SendClientMessage(playerid, COLOR_RED, "*** You are not Katy/Romel ***");
    return 1;
}



Re: strfind else if - Kindred - 23.07.2012

Is your name Romel IG?

Meaning, you have a capital for the R and shit. Due to the fact you set false to ignorecase, it cannot be romel or ROMEL, but only Romel.

Just making sure.

Plus, is the custom function you are using (GetpName) working?


Re: strfind else if - ikey07 - 23.07.2012

try to use
if(strfind(IGName,"Romel", true) == 0)

but you should better use strcmp, as if I take nick Romel07, I could still use that cmd if you use strfind

if(strcmp(IGName,"Romel",true ) == 0)


Re: strfind else if - JaKe Elite - 23.07.2012

Yes @Kindred GetpName is working properly
and i will try ikey


Re: strfind else if - JaKe Elite - 23.07.2012

Nop when i try strfind it won't work. it says i'm not Katy/Romel
i need to use strfind so that i don't need to add new name in strcmp everytime any ideas?


Re: strfind else if - Kindred - 23.07.2012

Why can't you just use one name?

Unless you want to use [clantaghere]Romel, or anything else other then just "Romel" you can just use strcmp.

Using strcmp is recommended, seeing as anyone with the name "Romel" within there name will also be able to use it.


Re: strfind else if - JaKe Elite - 23.07.2012

Well sometimes i'm using my other username. so i have to use strfind


Re: strfind else if - Kindred - 23.07.2012

Then you can simply add another code for the other username?

Unless you are going to create a username every 1 week or less, I don't see this as a problem.

Plus, I think this should work, I see no reason why it wouldn't.

EDIT: Plus, why are you sending a message to yourself saying you love yourself?

There is no parameter for the command, such as iloveyou [id], therefore you set it as player which then sends the message to yourself.


Re: strfind else if - ikey07 - 23.07.2012

strfind should work, but still, you cant use strfind, because as I said, if I take nick Romel07, I will be able to use that cmd

strfind = "Romel64565" = found and can use that cmd
strcmp = "Romel64565" = Not same and can not use that cmd


Re: strfind else if - JaKe Elite - 23.07.2012

Fixed by changing strfind to strcmp rep for both of you