SA-MP Forums Archive
Time bug! ? - 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: Time bug! ? (/showthread.php?tid=544982)



Time bug! ? - Metharon - 05.11.2014

Hello!
My bug is that the system jumps !? i mean it was 44 secs left , then he jump to "-17" secs?!
there's the code:
Код:
    if(strcmp(cmd, "/mute", true) == 0)
	{
		if (PlayerInfo[playerid][Administrator] >= 3 )
	    {
		    new string[456];
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "{FFFFFF}(( {FFCC00}Exemplu folosire: {C0C0C0} /mute [id] [minute] {FFFFFF}))");
				return 1;
			}
			new victima;
			new time;
			victima = ReturnUser(tmp);
			tmp = strtok(cmdtext, idx);
			time = strval(tmp);
			//if(victima == playerid) { SendClientMessage(playerid, -1, "{FFFFFF}(( {FFCC00}Informatie - {C0C0C0} aceasta comanda trebuie executata pe alta persoana {FFFFFF}))"); return 1; }
			if(IsPlayerConnected(victima))
			{
				if(victima != INVALID_PLAYER_ID)
				{
					GetPlayerName(victima, giveplayer, sizeof(giveplayer));
					if (time > 1)
					{
					format(string, sizeof(string), "(Gerrax) {CC0033}Jucatorul %s a primit mute de la administratorul %s pentru %d minute!", giveplayer,RemoveUnderScore(playerid), time);
					SendClientMessageToAllEx(COLOR_GRAD1, string);
					}
					if (time == 1)
					{
					format(string, sizeof(string), "(Gerrax) {CC0033}Jucatorul %s a primit mute de la administratorul %s pentru %d minut!", giveplayer,RemoveUnderScore(playerid), time);
					SendClientMessageToAllEx(COLOR_GRAD1, string);
					}
					PlayerInfo[victima][pMute] = 1;
					PlayerInfo[victima][pMuteTime] = time*60*1000/1000;
					SendClientMessage(playerid, COLOR_GRAD2, "{FFFFFF}(( {FFCC00}Informatie - {C0C0C0}Tasteaza /mymute pentru a verifica timpul ramas din mute {FFFFFF}))");
					format(string, sizeof(string), "~r~Ai primit mute!~n~Timp ramas :~g~~h~%d minute", time);
					GameTextForPlayer(victima, string, 5000, 1);
					MuteTimer[victima] = SetTimerEx("TimpRamasDinMute", 1000, true, "i", victima);

				}
			}
		}
		else
		{
			SendClientMessage(playerid, -1, "{FFFFFF}(( {FFCC00}Informatie -{C0C0C0} nu ai accces la aceasta comanda! {FFFFFF}))");
		}
		return 1;
	}
Код:
Function TimpRamasDinMute(playerid)
{
	PlayerInfo[playerid][pMuteTime] --;
	if(PlayerInfo[playerid][pMuteTime] < 1)
	{
     	KillTimer(MuteTimer[playerid]);
		PlayerInfo[playerid][pMute] = 0;
		PlayerInfo[playerid][pMuteTime] = 0;
		SendClientMessage(playerid, -1, "{FFFFFF}(( {FFCC00}Informatie -{C0C0C0} timpul de mute a expirat! {FFFFFF}))");
		return 1;
  	}
  	return 1;
}
Result :


Is there anyway to fix this hole?


Re: Time bug! ? - Metharon - 07.11.2014

UP PLEASE


Re: Time bug! ? - Eth - 07.11.2014

instead of function use:
pawn Код:
forward TimpRamasDinMute(playerid);
public TimpRamasDinMute(playerid)
{
    PlayerInfo[playerid][pMuteTime] --;
    if(PlayerInfo[playerid][pMuteTime] < 1)
    {
        KillTimer(MuteTimer[playerid]);
        PlayerInfo[playerid][pMute] = 0;
        PlayerInfo[playerid][pMuteTime] = 0;
        SendClientMessage(playerid, -1, "{FFFFFF}(( {FFCC00}Informatie -{C0C0C0} timpul de mute a expirat! {FFFFFF}))");
        return 1;
    }
    return 1;
}