strfind else if
#1

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;
}
Reply
#2

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?
Reply
#3

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)
Reply
#4

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

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?
Reply
#6

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.
Reply
#7

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

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.
Reply
#9

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
Reply
#10

Fixed by changing strfind to strcmp rep for both of you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)