I learned how to use SetTimer properly. (but still have a mistake)
pawn Код:
forward ResetRob(playerid);
public ResetRob(playerid)
{
RecentRob[playerid] = 0;
RecentRobbed[playerid] = 0;
}
pawn Код:
CMD:robplayer(playerid,params[])
{
if(gTeam[playerid] != CIVILIAN)
{
SendClientMessage(playerid, -1, "{ff0000}=ERROR=: {ffffff}You can't rob players as officer!");
return 1;
}
else if (gTeam[playerid] == CIVILIAN)
{
new targetid,targetname[25],playername[25],Float:X, Float:Y, Float:Z;
if(sscanf(params,"u", targetid)) return SendClientMessage(playerid, -1, "{ffff00}=USAGE=: {ffffff}/robplayer <id>");
if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "{ff0000}=ERROR=: {ffffff}The player is not online!");
if(targetid == playerid) return SendClientMessage(playerid, -1, "{ff0000}=ERROR=: {ffffff}You can't rob yourself, idiot.");
if(GetPlayerState(targetid) == PLAYER_STATE_DRIVER || GetPlayerState(targetid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid,-1,"{ff0000}=ERROR=: {ffffff}You can't rob a player that is in a vehicle!");
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return SendClientMessage(playerid,-1,"{ff0000}=ERROR=: {ffffff}You can't rob when you're in a vehicle, exit your vehicle first!");
if(targetid != IsPlayerInRangeOfPoint(playerid, 4, X, Y, Z)) SendClientMessage(playerid, -1, "{ff0000}=ERROR=: {ffffff}You can't rob this player as you're too far than the player!");
GetPlayerPos(targetid, X, Y, Z);
GetPlayerName(targetid, targetname, sizeof(targetname));
GetPlayerName(playerid, playername, sizeof(playername));
if(IsPlayerInRangeOfPoint(targetid, 4, X,Y,Z))
{
if(GetPlayerMoney(targetid) <= 2500 || RecentRobbed[targetid] == 1 || RecentRob[playerid] == 1)
{
SendClientMessage(playerid, -1, "{ff0000}=ERROR=: {ffffff}You can't rob this player as the player's cash is less than $2500 or he's recently robbed!");
return 0;
}
else if(GetPlayerMoney(targetid) > 2500 && RecentRobbed[targetid] == 0 || RecentRob[playerid] == 0)
{
new string[128];
new Money = GetPlayerMoney(targetid);
new Robbed = random(Money);
GivePlayerMoney(playerid, Robbed);
GivePlayerMoney(targetid, -Robbed);
format(string, sizeof(string), "{ffff00}=SUCCESS=: {ffffff}You have robbed %d from %s!", Robbed, targetname);
SendClientMessage(playerid, -1, string);
format(string, sizeof(string), "{ffff00}=SUCCESS=: {ffffff}%s has robbed %d from you!", playername, Robbed);
SendClientMessage(targetid, -1, string);
RecentRobbed[targetid] = 1;
RecentRob[playerid] = 1;
UserInfo[playerid][uRobbed]++;
SetTimer("ResetRob", 5*60*1000, 0);
return 1;
}
}
}
return 1;
}
Just sayin'. Take this script if you want my shitty script.