SA-MP Forums Archive
string check dont work - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: string check dont work (/showthread.php?tid=134346)



string check dont work - Headshot1108 - 16.03.2010

i like to check if the gang already the name, what the player like to create:

pawn Код:
if(strcmp(GangInfo[i][gangNames],tmp,true) == 0)
    {
    for(new i = 1; i < MAX_GANGS; i++)
    {
    SendClientMessage(playerid, rot, "This Gang already exists!");
    return 1;
     }
    }
if i do this, i dont can create any gang.

But if i define the ID, it work:

pawn Код:
if(strcmp(GangInfo[0][gangNames],tmp,true) == 0)
    {
    SendClientMessage(playerid, rot, "This Gang already exists!");
    return 1;
    }



Re: string check dont work - woot - 16.03.2010

pawn Код:
for(new i = 1; i < MAX_GANGS; i++)
{
    if( strcmp( GangInfo[i][gangNames],tmp,true ) == 0) return SendClientMessage(playerid, rot, "This Gang already exists!");
}



Re: string check dont work - Headshot1108 - 16.03.2010

Quote:
Originally Posted by //exora
pawn Код:
for(new i = 1; i < MAX_GANGS; i++)
{
    if( strcmp( GangInfo[i][gangNames],tmp,true ) == 0) return SendClientMessage(playerid, rot, "This Gang already exists!");
}
same code, and don't work...


Re: string check dont work - woot - 16.03.2010

No, you have to do the loop before checking the gangname, it shouldn't even compile the way you did.


Re: string check dont work - Headshot1108 - 16.03.2010

Quote:
Originally Posted by //exora
No, you have to do the loop before checking the gangname, it shouldn't even compile the way you did.
lol, it work, and i tested ingame.

// Edit: ok, my bad, i've scriptet in this forum, i was to lazy to copy my snippet

my code in my script:

pawn Код:
for(new i = 1; i < MAX_GANGS; i++)
    {
        if(strcmp(GangInfo[i][gangNames],tmp,true)==0)
        {
        SendClientMessage(playerid, rot, "This Gang already exists!");
        return 1;
        }
    }
and your code is the same
and these two doesn't work..



Re: string check dont work - Headshot1108 - 16.03.2010

lol wtf?
solution?
i need it.


Re: string check dont work - Jeffry - 16.03.2010

I would suggest that you make a
pawn Код:
GangCreated[gangid]=1;
at your /gangcreate (or whatever the cmd is)

and check it with :
pawn Код:
if(GangCreated[i]==1) return SendClientMessage...
Helped?


Re: string check dont work - Headshot1108 - 16.03.2010

i have it already, but the other players can create gangs with the same name, but also have a other gangid.
that i like to fix, that players dont can create gangs, what a gang already have. (the name)

with
pawn Код:
if(strcmp(GangInfo[0][gangNames],tmp,true) == 0)
    {
    SendClientMessage(playerid, rot, "This Gang already exists!");
    return 1;
    }
it work, but with the loop doesn't work? (The 0 is gangid 0)


Re: string check dont work - Jeffry - 16.03.2010

Try:
pawn Код:
for(new i = 0; i < MAX_GANGS; i++)
    {
        if(strcmp(GangInfo[i][gangNames],tmp,true)==0)
        {
        SendClientMessage(playerid, rot, "This Gang already exists!");
        return 1;
        }
    }
Btw, german?


Re: string check dont work - Headshot1108 - 16.03.2010

Quote:
Originally Posted by Jeffry
Try:
pawn Код:
for(new i = 0; i < MAX_GANGS; i++)
    {
        if(strcmp(GangInfo[i][gangNames],tmp,true)==0)
        {
        SendClientMessage(playerid, rot, "This Gang already exists!");
        return 1;
        }
    }
yes, that i have but doesn't work

Quote:
Originally Posted by Jeffry
Btw, german?
yes