Strcmp still giving me hell!
#1

Okay so I have two codes using strcmp to compare two strings that are both kicking me in the balls.

pawn Код:
stock GetCarIDFromPlayer_Enum(playerid)
{
    for(new i=0; i<sizeof(CarInfo); i++)
    {
        if(!strcmp(CarInfo[i][vOwner], PlayerName(playerid), true)) return i;
        else if(strcmp(CarInfo[i][vOwner], PlayerName(playerid), true)) return 0;
    }
    return -1;
}
The problem with that code is that, if the two strings match, it still returns 0, when it should return i, but if I take out the else if bit and just have the first if .... return i; then it returns the i. The solution is to remove the else if, but I need to have that so it returns 0 if the two strings do not match.

pawn Код:
if(strcmp(tmp, gatepass) != 0)
        {
            SendClientMessage(playerid, COLOR_LIGHTRED, "* Dills gate: Incorrect password !");
            print("Incorrect pass");
            return 1;
        }
The problem with that code is that it does nothing. I have codes above it. I debugged it, and it stops at the bit of code. "Incorrect pass" doesn't print either.

I'll pay someone $10 if they can either fix this or make another code doing the same thing, I've requested help so many times and no one has been able to fix it >.>
Reply


Messages In This Thread
Strcmp still giving me hell! - by Jack_Leslie - 05.10.2011, 06:44
Re: Strcmp still giving me hell! - by MP2 - 05.10.2011, 06:58
Re: Strcmp still giving me hell! - by Jack_Leslie - 05.10.2011, 06:59
Re: Strcmp still giving me hell! - by [HiC]TheKiller - 05.10.2011, 07:03
Re: Strcmp still giving me hell! - by Jack_Leslie - 05.10.2011, 07:03
Re: Strcmp still giving me hell! - by iggy1 - 05.10.2011, 07:06
Re: Strcmp still giving me hell! - by Jack_Leslie - 05.10.2011, 07:23
Re: Strcmp still giving me hell! - by iggy1 - 05.10.2011, 07:32
Re: Strcmp still giving me hell! - by Jack_Leslie - 05.10.2011, 07:36

Forum Jump:


Users browsing this thread: 4 Guest(s)