string check dont work
#1

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

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!");
}
Reply
#3

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

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

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

lol wtf?
solution?
i need it.
Reply
#7

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

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

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)