Timer saves wrongly... - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Timer saves wrongly... (
/showthread.php?tid=473771)
Timer saves wrongly... -
Scrillex - 04.11.2013
Hello samp forum members thank you for reading my topic and code.
Maybe someone could help me out with it..
I can't find whats going wrong...
INI FILE:
OnGameModeInit:
pawn Код:
SetTimer("GlobalCheck",1000,true);
Global checking:
pawn Код:
forward GlobalCheck();
public GlobalCheck()
{
foreach(Player,i)
{
if(PlayerInfo[i][pCMDT] > 0 && gettime() <= PlayerInfo[i][pCMDT])
{
PlayerInfo[i][pCMDT] = 0;
SendClientMessage(i,0xFFFFFFFF,"The /giverespect command is ready for use once more.");
}
}
return 1;
}
CMD:
pawn Код:
CMD:giverespect(playerid, params[])
{
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pCMDT] > 0)return SendClientMessage(playerid,0xFF0000FF,"Please wait before using this command again.");
if(PlayerInfo[playerid][pCMDT] <= 0)
{
new id, string[128];
if(sscanf(params, "r", id)) return SendClientMessage(playerid, 0xCC0000AA, "USAGE: /respect <playerid/partofname>");
if(IsPlayerInRangeOfPlayer(playerid, id, 5))
{
if(playerid != id)
{
PlayerInfo[playerid][pStreetRespect]++;
PlayerInfo[playerid][pCMDT] = gettime() + 3600;
if((gettime() - PlayerInfo[playerid][pCMDT]) > 3600)
format(string, sizeof(string), " You have gived Street Respect to %s.", NORPN(id));
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), " Player %s has gived you Street Respect to you.", NORPN(playerid));
SendClientMessage(playerid, COLOR_WHITE, string);
}
}
else
{
SendClientMessage(playerid, -1, "You can't heal yourself.");
}
}
else
{
SendClientMessage(playerid, -1, "You aren't close enough to the player.");
}
return 1;
}
Re: Timer saves wrongly... -
Jefff - 04.11.2013
pawn Код:
forward GlobalCheck();
public GlobalCheck()
{
foreach(Player,i)
{
if(PlayerInfo[i][pCMDT] > 0)
if(--PlayerInfo[i][pCMDT] < 1)
{
PlayerInfo[i][pCMDT] = 0;
SendClientMessage(i,0xFFFFFFFF,"The /giverespect command is ready for use once more.");
}
}
return 1;
}
CMD:giverespect(playerid, params[])
{
if(!IsPlayerLoggedIn(playerid)) SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
else if(PlayerInfo[playerid][pCMDT] > 0) SendClientMessage(playerid,0xFF0000FF,"Please wait before using this command again.");
else{
new id;
if(sscanf(params, "u", id)) SendClientMessage(playerid, 0xCC0000AA, "USAGE: /respect <playerid/partofname>");
else if(id == INVALID_PLAYER_ID || !IsPlayerConnected(id)) SendClientMessage(playerid, -1, "ID not connected");
else if(playerid == id) SendClientMessage(playerid, -1, "You can't heal yourself.");
else if(!IsPlayerInRangeOfPlayer(playerid, id, 5)) SendClientMessage(playerid, -1, "You aren't close enough to the player.");
else{
new string[128];
PlayerInfo[playerid][pStreetRespect]++;
PlayerInfo[playerid][pCMDT] = Time_Here; // example 3600 - 1 hour
format(string, sizeof(string), " You have gived Street Respect to %s.", NORPN(id));
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), " Player %s has gived you Street Respect to you.", NORPN(playerid));
SendClientMessage(id, COLOR_WHITE, string);
}
}
return 1;
}