HasRobbedShopRecently[playerid] = GetTickCount()+60000;
CMD:rob(playerid, params[])
{
if(HasRobbedShopRecently[playerid] > GetTickCount())
return SendClientMessage(playerid, -1, "Wait...");
HasRobbedShopRecently[playerid] = GetTickCount()+60000;
//Functions
return true;
}
new gHealTime[MAX_PLAYERS];
CMD:heal(playerid, params[])
{
if(gHealTime[playerid] <= gettime())
{
SetPlayerHealth(playerid, 100.0);
gHealTime[playerid] = gettime() + 10;
SendClientMessage(playerid, -1, "You have been healed.");
}
else
{
SendClientMessage(playerid, -1, "You can only use this command every 10 seconds.");
}
return 1;
}
forward ResetRob(playerid);
public ResetRob(playerid)
{
HasRobbedShopRecently[playerid] = 0;
}
stock IsNearStore(playerid)
{
if(IsPlayerInRangeOfPoint(playerid, 5, ##COORDX##, ##COORDY##, ##COORDZ##)) return 1; // Store 1 replace COORDX, Y and Z with the coordinates of the shop.
if(IsPlayerInRangeOfPoint(playerid, 5, ##COORDX##, ##COORDY##, ##COORDZ##)) return 1; // Store 2 replace COORDX, Y and Z with the coordinates of the shop.
if(IsPlayerInRangeOfPoint(playerid, 5, ##COORDX##, ##COORDY##, ##COORDZ##)) return 1; // Store 3 replace COORDX, Y and Z with the coordinates of the shop.
if(IsPlayerInRangeOfPoint(playerid, 5, ##COORDX##, ##COORDY##, ##COORDZ##)) return 1; // Store 4 replace COORDX, Y and Z with the coordinates of the shop.
return 0;
}
CMD:rob(playerid, params[])
{
if(HasRobbedShopRecently[playerid] != 0) return SendClientMessage(playerid, -1, "You have already robbed a shop the last 60 seconds."); // if the value is not 0, show this message.
if(!IsNearStore(playerid)) return SendClientMessage(playerid, -1, "You are not near a store.");
HasRobbedShopRecently[playerid] = 1; // Shop has been robbed recently.
new rand, str[100];
rand = random(2000);
GivePlayerMoney(playerid, rand); // Give a random value between 1-2000.
format(str, sizeof(str), "You have robbed the shop and you managed to take $%i.", rand); // format the string
SendClientMessage(playerid, -1, str); // send the string
SetTimerEx("ResetRob", 60000, false, "i", playerid); // Set a non-looping timer on 60000 ms (60 sec) to ResetRob(playerid);
return 1;
}
VincentDunn, don't need to check if it's 0, cause gettime will always be bigger.
|
if(gMinute==60)
{
//1 hour passed
}
if(gMinute==120)
{
//2 hour passed
}
if(gMinute==1440)
{
//1 day passed
gDay++;
}