Command only works for a pickup with the ID 1.
#1

Pretty weird problem. For the other commands I use exactly the same method, but somehow it doesn't work for this one.
The command only works for a pickup(business) with the ID: 1.

Here's the code.
pawn Код:
if(strcmp(cmd, "/setentfee", true) == 0)
    {
    new playernamez[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playernamez, sizeof(playernamez));
    new file[31];
    for(new i; i < sizeof(BusinessData); i++)
    {
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
        SendClientMessage(playerid, COLOR_RED, "USAGE: /setentfee <entry fee>");
        return 1;
    }
    format(file, sizeof(file), "BusinessData/%i.txt", i + 1);
    if(IsPlayerInRangeOfPoint(playerid, 2, x, y, z)) // x y z is already defined.
    {
    new entryfee;
    entryfee = strval(tmp);
    if(entryfee < 0 || entryfee > 5000) { return SendClientMessage(playerid, COLOR_RED, "Entry fee cannot be lower than $0 or higher than $5000"); }
    if(!strcmp(playernamez, BusinessData[i][BusinessOwner], false))
    {
    BusinessData[i][EntFee] = entryfee;
    dini_IntSet(file, "EntFee", entryfee);
    format(string, sizeof(string), "You've set your entry fee to: $%i", entryfee);
    SendClientMessage(playerid, NEWBIE_COLOR, string);
    break;
            }
        }
    }
}
If you're trying this command at a business with the ID 2 or higher, it will say I didn't enter the 'tmp'.
It will give this message: USAGE: /setentfee <entry fee>
Reply
#2

Apperently my previous posts got deleted o.O.

I tried return 1;, instead of break, no result.
I also renamed 'entryfee' to something else, it also failed.
I'm using the EXACT method for an other command..
Reply
#3

pawn Код:
if(strcmp(cmd, "/setentfee", true) == 0)
{
    new playernamez[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playernamez, sizeof(playernamez));
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
        SendClientMessage(playerid, COLOR_RED, "USAGE: /setentfee <entry fee>");
        return 1;
    }
    new entryfee = strval(tmp);
    if(entryfee < 0 || entryfee > 5000) { return SendClientMessage(playerid, COLOR_RED, "Entry fee cannot be lower than $0 or higher than $5000"); }
    new file[31];
    for(new i; i < sizeof(BusinessData); i++)
    {
        format(file, sizeof(file), "BusinessData/%i.txt", i + 1);
        if(IsPlayerInRangeOfPoint(playerid, 2, x, y, z)) // x y z is already defined.
        {
            if(!strcmp(playernamez, BusinessData[i][BusinessOwner], false))
            {
                BusinessData[i][EntFee] = entryfee;
                dini_IntSet(file, "EntFee", entryfee);
                format(string, sizeof(string), "You've set your entry fee to: $%i", entryfee);
                SendClientMessage(playerid, NEWBIE_COLOR, string);
                break;
            }
        }
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)