20.09.2012, 21:38
Alternatively you could use:
Sorry if there is any mistakes, I just made this here and now without compiling.
pawn Код:
forward ResetRob(playerid);
public ResetRob(playerid)
{
HasRobbedShopRecently[playerid] = 0;
}
pawn Код:
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;
}
pawn Код:
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;
}