Crashdetect Warning on Rob command
#1

hello guys. i have a this crash detect warning on my rob command command

i dont even use OnPlayerCommandText callback i dont know why it giving me crash detect warning on OnPlayerCommandText
Warning
pawn Код:
[18:06:58] [debug] Run time error 4: "Array index out of bounds"
[18:06:58] [debug]  Accessing element at index 65535 past array upper bound 499
[18:06:58] [debug] AMX backtrace:
[18:06:58] [debug] #0 000234f4 in public cmd_rob () from lscnr_mysql.amx
[18:06:58] [debug] #1 native CallLocalFunction () [00471e90] from samp-server.exe
[18:06:58] [debug] #2 0000bfd4 in public OnPlayerCommandText () from lscnr_mysql.amx
Command
pawn Код:
CMD:rob(playerid,params[])
{
    new string[128];
    new ID;
    //
    if(sscanf(params, "u", ID)) return SendClientMessage(playerid,COLOR_RED_ERROR,"USAGE: /rob ( ID )");
    if(IsSpawned[playerid] != 1) return  SendClientMessage(playerid,-1,"{FF0000}[ERROR]: {FFFFFF}You must be alive and spawned in order to be able to use this command.");
    if(IsFrozen[playerid] == 1) return SendClientMessage(playerid,-1,"{FF0000}[ERROR]: {FFFFFF}You have been frozen by a Server Administrator. You cannot use this command.");
    if(OnDuty[ID] == 1) return SendClientMessage(playerid,-1,"{FF0000}[ERROR]: {FFFFFF}You cannot use this command on this player because they are in Administrator mode.");
    if(IsKidnapped[playerid] == 1) return SendClientMessage(playerid,-1,"{FF0000}[ERROR]: {FFFFFF}You are kidnapped. You cannot use this command.");
    if(GetPlayerInterior(playerid) > 0) return SendClientMessage(playerid,-1,"{FF0000}[ERROR]: {FFFFFF}You cannot rob someone inside an Interior");
    if(!IsPlayerConnected(ID))
    {
        format(string,sizeof(string),"{FF0000}[ERROR]: {FFFFFF}The player ID (%d) is not connected to the server. You cannot rob them",ID);
        return SendClientMessage(playerid,-1,string);
    }
    if(IsPlayerCloseToPlayer(playerid,ID,3.5) == 0)
    {
        format(string,sizeof(string),"{FF0000}[ERROR]: {FFFFFF}%s(%d) is too far away. You cannot reach him to rob him.",PlayerName(ID),ID);
        return SendClientMessage(playerid,-1,string);
    }
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid,-1,"{FF0000}[ERROR]: {FFFFFF}You cannot rob someone while in a vehicle. Exit the vehicle first.");
    if(GetPlayerState(ID) == PLAYER_STATE_DRIVER || GetPlayerState(ID) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid,-1,"{FF0000}[ERROR]: {FFFFFF}You cannot rob someone while they are in a vehicle. Get them to exit the vehicle first.");
    if(playerid == ID) return SendClientMessage(playerid,-1,"{FF0000}[ERROR]: {FFFFFF}You cannot rob yourself, how can you even manage that?");
    if(IsSpawned[ID] != 1)
    {
        format(string,sizeof(string),"{FF0000}[ERROR]: {FFFFFF}%s(%d) is not spawned. You cannot rob dead people ..",PlayerName(ID),ID);
        return SendClientMessage(playerid,-1,string);
    }
    if(IsFrozen[ID] == 1)
    {
        format(string,sizeof(string),"{FF0000}[ERROR]: {FFFFFF}%s(%d) is frozen by a Server Administrator. You cannot rob them.",PlayerName(ID),ID);
        return SendClientMessage(playerid,-1,string);
    }
    if(AttemptedToRobRecently[playerid] >= 1) return SendClientMessage(playerid,-1,"{FF0000}[ERROR]: {FFFFFF}You are too tired from your last rob attempt. Please wait before robbing again.");
    if(HasRobbedRecently[playerid] >= 1) return SendClientMessage(playerid,-1,"{FF0000}[ERROR]: {FFFFFF}You are too tired from the last person you robbed. Please wait before robbing again.");
    if(GetPlayerMoney(ID) <= 0) return SendClientMessage(playerid,-1,"{FF0000}[ERROR]: {FFFFFF}That player has no money in their pockets. What would be the point in robbing them?");
    new crand = random(100);
    if(crand <= 30)
    {
        SendClientMessage(playerid,COLOR_RED_ERROR,"Rob attempt failed. The player slipped out of your grasp.");
        AttemptedToRobRecently[playerid] =35;
        return 1;
    }
    if(HasSecureWallet[ID] > 1)
    {
        SendClientMessage(playerid,COLOR_RED_ERROR,"You cannot rape this person. He have Security Wallet.");
        HasSecureWallet[ID] = HasSecureWallet[ID] - 1;
        format(string, sizeof(string), "%s has attempted to rob you, you now have %d Security Wallet left.", PlayerName(playerid),HasSecureWallet[ID]);
        SendClientMessage(ID, -1, string);
        AttemptedToRobRecently[playerid] =25;
        return 1;
    }
    if(IsPlayerCloseToPlayer(playerid,ID,3.5) == 1 && crand > 30)
    {
        new current_zone = player_zone[playerid];
        new mrand =random(GetPlayerMoney(ID));
        SendClientMessage(playerid,COLOR_GREY,"[[_Player Robbed_]]");
        format(string,sizeof(string),"You have robbed $%d from %s(%d). Careful they dont come after you!",mrand,PlayerName(ID),ID);
        SendClientMessage(playerid,COLOR_RED,string);

        GivePlayerMoney(playerid,mrand);
        IncreaseWantedLevel(playerid,8);
        HasRobbedRecently[playerid] =180;
        IncreasePlayerScore(playerid,3);

        SendClientMessage(ID,COLOR_GREY,"[[_Robbed_]]");
        format(string,sizeof(string),"You have had $%d robbed from you by %s(%d). Kill them for your money back or run!",mrand,PlayerName(playerid),playerid);
        SendClientMessage(ID,COLOR_RED,string);
        GivePlayerMoney(ID,-mrand);

        format(string,sizeof(string),"[DISPATCH] Robbery: %s(%d) has robbed $%d from %s(%d). Location: %s.",PlayerName(playerid),playerid,mrand,PlayerName(ID),ID,zones[current_zone][zone_name]);
        SendClientMessageToAllCops(string);
        format(string,sizeof(string),"{FFDA00}[ROBBERY]:{FFFFFF} %s(%d) has robbed $%d from %s(%d).",PlayerName(playerid), playerid,mrand,PlayerName(ID),ID);
        SendClientMessageToAll(-1, string);
        return 1;
    }
    return 1;
}
Reply
#2

It looks like MAX_PLAYERS is lower than 'ID'. Example: ID is 10 while MAX_PLAYERS is defined as 5. Anyway, it exceeds it somehow (sscanf returns invalid ID (65535) probably)
Reply
#3

What's wrong with your previous topic? Did you bother reading the answers given there?
Reply
#4

FIXED!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)