Wait 2 mins before doing this again -
phil_lendon - 27.07.2011
Right so i have this command:
Код:
if(!strcmp("/rob",cmdtext))
{
if(IsPlayerInRangeOfPoint(playerid, 500, -23.50, -55.64, 1003.55))
{
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);
}
return 1;
}
But now what i want to do is make it so you have to wait 2 mins before you can re-do and when u try to re-do it should say "You must wait before you can do that again!"
Re: Wait 2 mins before doing this again -
Vince - 27.07.2011
Search for GetTickCount.
Re: Wait 2 mins before doing this again -
phil_lendon - 27.07.2011
Quote:
Originally Posted by Vince
Search for GetTickCount.
|
Huh? Cant i just use a timer.. i dunno how tho
Re: Wait 2 mins before doing this again -
iPLEOMAX - 27.07.2011
pawn Код:
//On top of your script:
new bool:Robbed[MAX_PLAYERS];
//Modify your cmd:
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))
{
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;
}
Now, you can use Robbed[playerid] = false; anytime you wish. Perhaps OnPlayerSpawn?
Make sure you put the false OnPlayerDisconnect.
Re: Wait 2 mins before doing this again -
phil_lendon - 27.07.2011
C:\Documents and Settings\Gaming.SLIM-D48ECACC66\Desktop\Project Cuff\gamemodes\copsnrobbers.pwn(77) : error 017: undefined symbol "Robbed"
C:\Documents and Settings\Gaming.SLIM-D48ECACC66\Desktop\Project Cuff\gamemodes\copsnrobbers.pwn(77) : warning 215: expression has no effect
C:\Documents and Settings\Gaming.SLIM-D48ECACC66\Desktop\Project Cuff\gamemodes\copsnrobbers.pwn(77) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\Gaming.SLIM-D48ECACC66\Desktop\Project Cuff\gamemodes\copsnrobbers.pwn(77) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Gaming.SLIM-D48ECACC66\Desktop\Project Cuff\gamemodes\copsnrobbers.pwn(77) : fatal error 107: too many error messages on one line
Re: Wait 2 mins before doing this again -
iPLEOMAX - 27.07.2011
I think you didn't place "new bool:Robbed[MAX_PLAYERS];" correctly.

I have no errors when compiling.
Put the line: "new
bool:Robbed[MAX_PLAYERS];" after this:
#include <a_samp>
Re: Wait 2 mins before doing this again -
AndreT - 27.07.2011
Act something like this:
pawn Код:
new lastRobbed[MAX_PLAYERS];
// in the command
if(GetTickCount() - lastRobbed[playerid] < 120 * 1000)
return SendClientMessage(playerid, COLOR, "You must wait 2 minutes before robbing again!");
lastRobbed[playerid] = GetTickCount();
You could also make it using PVars since this data isn't often accessed.