SA-MP Forums Archive
This cmd crashes pawno - 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)
+--- Thread: This cmd crashes pawno (/showthread.php?tid=308515)



This cmd crashes pawno - Face9000 - 03.01.2012

Hello,i've done this command:

pawn Код:
dcmd_rob(playerid,params[])
{
    if((GetTickCount() - robtime[MAX_PLAYERS]) < 120000)) return SendClientMessage(playerid,color,"You have to wait.");
    if(IsPlayerInRangeOfPoint(playerid, RANGE, COORDINATES))
    {
    new string[120], playerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
    robtime[MAX_PLAYERS] = GetTickCount();
    format(string, sizeof(string), "%s Is Robbing .....etc", playerName);
    SendClientMessageToAll(0xFFFFFFFF, string);
    SetPlayerWantedLevel(playerid, 6);
    GivePlayerMoney(playerid, 10000);
    #pragma unused params
    }
    return 1;
}
The new;

pawn Код:
new robtime[MAX_PLAYERS];
But it crashes pawno when compling,wtf?


Re: This cmd crashes pawno - Stigg - 03.01.2012

This:
Код:
robtime[MAX_PLAYERS] = GetTickCount();
Should be:
Код:
robtime[playerid] = GetTickCount();
And this:
Код:
if((GetTickCount() - robtime[MAX_PLAYERS]) < 120000)) return SendClientMessage(playerid,color,"You have to wait.");
Needs attention too.


Re: This cmd crashes pawno - geerdinho8 - 03.01.2012

Quote:
Originally Posted by Stigg
Посмотреть сообщение
This:
Код:
robtime[MAX_PLAYERS] = GetTickCount();
Should be:
Код:
robtime[playerid] = GetTickCount();
And this:
Код:
if((GetTickCount() - robtime[MAX_PLAYERS]) < 120000)) return SendClientMessage(playerid,color,"You have to wait.");
Needs attention too.
Код:
if((GetTickCount() - robtime[playerid]) < 120000)) return SendClientMessage(playerid,color,"You have to wait.");



Re: This cmd crashes pawno - fiki574 - 03.01.2012

pawn Код:
dcmd_rob(playerid,params[])
{
    #pragma unused params
    if((GetTickCount() - robtime[MAX_PLAYERS]) < 120000)) return SendClientMessage(playerid,color,"You have to wait.");
    if(IsPlayerInRangeOfPoint(playerid, RANGE, COORDINATES))
    {
    new string[120], playerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
    robtime[MAX_PLAYERS] = GetTickCount();
    format(string, sizeof(string), "%s Is Robbing .....etc", playerName);
    SendClientMessageToAll(0xFFFFFFFF, string);
    SetPlayerWantedLevel(playerid, 6);
    GivePlayerMoney(playerid, 10000);
    }
    return 1;
}

#pragma unused params NEVER EVER EVER EVER goes beneath dcmd.... EVER!


Re: This cmd crashes pawno - Babul - 03.01.2012

pawn Код:
new Variable[500]
...creates an array starting at cell [0] upto [499], thats 500 together.
if you use [MAX_PLAYERS] in any loop, it ill be an "out of bounds" error. your simple mistake was the playerid instead of MAX_PLAYERS:
pawn Код:
dcmd_rob(playerid,params[])
{
    if((GetTickCount() - robtime[playerid]) < 120000)) return SendClientMessage(playerid,0xff0000ff,"You have to wait.");
    if(IsPlayerInRangeOfPoint(playerid, 10.0000, 0.0000,0.0000,0.0000))
    {
        new string[120], playerName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
        robtime[playerid] = GetTickCount();
        format(string, sizeof(string), "%s Is Robbing .....etc", playerName);
        SendClientMessageToAll(0xFFFFFFFF, string);
        SetPlayerWantedLevel(playerid, 6);
        GivePlayerMoney(playerid, 10000);
    }
    return 1;
}
btw: let a player start to rob, then /q, then let another player connect on the same id, and let him try to rob again. the robtime[playerid] gets reset at OnPlayerDisconnect?
oh, and where are the coodrinates and the radius for
Код:
if(IsPlayerInRangeOfPoint(playerid, RANGE, COORDINATES))
? its at blueberry acres now hehe