wait 2 mins before rob??
#1

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

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

Thanks!
Reply
#4

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

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

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

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

Nvm no errors, testing now.
Reply
#9

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

anybody got a fix?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)