SA-MP Forums Archive
wait 2 mins before rob?? - 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: wait 2 mins before rob?? (/showthread.php?tid=272421)



wait 2 mins before rob?? [unsolved] - phil_lendon - 28.07.2011

Right okay, i was given a code the other day but unfortunetally it only lets me rob ONCE and never again until i restart :S so how can i make it so it waits 2 mins before u can rob again and say "You must wait 2 minutes!"

pawn Код:
if(!strcmp("/rob",cmdtext))
{
    if(Robbed[playerid]) return SendClientMessage(playerid, 0xFF0000FF, "You already robbed once.");
    if(IsPlayerInRangeOfPoint(playerid, 500, -23.50, -55.64, 1003.55))
    {
                if( GetPlayerTeam( playerid ) == 2 ) return SendClientMessage( playerid, 0xFF0000FF, "You're a cop, you can't rob." );
        new string[120], playerName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
        format(string, sizeof(string), "%s Is Robbing, And is now wanted!", playerName);
        SendClientMessageToAll(0xFFFFFFFF, string);
        SetPlayerWantedLevel(playerid, 6);
        new money = 500 + random(50000);
        GivePlayerMoney(playerid, money);
        Robbed[playerid] = true;


    }
    return 1;



Re: wait 2 mins before rob?? - Basicz - 28.07.2011

Weeee! A CnR script!

pawn Код:
new
    robTicks[ MAX_PLAYERS ]
;

if(!strcmp("/rob",cmdtext))
{
    if  ( ( GetTickCount( ) - robTicks[ playerid ] ) > 12000 ) {
    //if(Robbed[playerid]) return SendClientMessage(playerid, 0xFF0000FF, "You already robbed once.");
    if(IsPlayerInRangeOfPoint(playerid, 500, -23.50, -55.64, 1003.55))
    {
                if( GetPlayerTeam( playerid ) == 2 ) return SendClientMessage( playerid, 0xFF0000FF, "You're a cop, you can't rob." );
        new string[120], playerName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
        format(string, sizeof(string), "%s Is Robbing, And is now wanted!", playerName);
        SendClientMessageToAll(0xFFFFFFFF, string);
        SetPlayerWantedLevel(playerid, 6);
        new money = 500 + random(50000);
        GivePlayerMoney(playerid, money);
        Robbed[playerid] = true;
        robTicks[ playerid ] = GetTickCount( );
    } else {
       SendClientMessage( playerid, -1, "Please wait 2 minutes before using the command again." );
    }
    return 1;
}
EDIT: I saw Jeffry's post, on another topic, try this ( with gettime )

pawn Код:
new
    robTicks[ MAX_PLAYERS ]
;

if(!strcmp("/rob",cmdtext))
{
    if  ( robTicks + 120 < gettime( ) ) return SendClientMessage( playerid, -1, "you can only use the command every 2 minutes only " );
    //if(Robbed[playerid]) return SendClientMessage(playerid, 0xFF0000FF, "You already robbed once.");
    if(IsPlayerInRangeOfPoint(playerid, 500, -23.50, -55.64, 1003.55))
    {
                if( GetPlayerTeam( playerid ) == 2 ) return SendClientMessage( playerid, 0xFF0000FF, "You're a cop, you can't rob." );
        new string[120], playerName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
        format(string, sizeof(string), "%s Is Robbing, And is now wanted!", playerName);
        SendClientMessageToAll(0xFFFFFFFF, string);
        SetPlayerWantedLevel(playerid, 6);
        new money = 500 + random(50000);
        GivePlayerMoney(playerid, money);
        Robbed[playerid] = true;
        //robTicks[ playerid ] = GetTickCount( );
    }
    return 1;
}



Re: wait 2 mins before rob?? - phil_lendon - 28.07.2011

Thanks!


Re: wait 2 mins before rob?? - phil_lendon - 28.07.2011

error 033: array must be indexed (variable "robTicks")
Any help here?


Re: wait 2 mins before rob?? - phil_lendon - 28.07.2011

-woops triple post..
can anybody help?
error 033: array must be indexed (variable "robTicks")


Re: wait 2 mins before rob?? - phil_lendon - 28.07.2011

C:\Documents and Settings\Gaming.SLIM-D48ECACC66\Desktop\Copy of Project Cuff\gamemodes\copsnrobbers.pwn(150) : error 021: symbol already defined: "robTicks"
C:\Documents and Settings\Gaming.SLIM-D48ECACC66\Desktop\Copy of Project Cuff\gamemodes\copsnrobbers.pwn(155) : error 033: array must be indexed (variable "robTicks")


Re: wait 2 mins before rob?? - iPLEOMAX - 28.07.2011

Replace the line: (add [playerid] to it )
pawn Код:
if  ( robTicks[playerid] + 120 < gettime( ) )........



Re: wait 2 mins before rob?? - phil_lendon - 28.07.2011

Nvm no errors, testing now.


Re: wait 2 mins before rob?? - phil_lendon - 28.07.2011

right well when i join its alright, but then when i try to rob for the first time i have to wait 2 mins? so i waited 2 mins and still wont lemme rob..


Re: wait 2 mins before rob?? - phil_lendon - 28.07.2011

anybody got a fix?