SA-MP Forums Archive
Timer set only for 0 id player. - 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 set only for 0 id player. (/showthread.php?tid=452822)



Timer set only for 0 id player. - ShadowMultiGaming - 22.07.2013

Hello,

I create a audible signal system if the seat belt is not fastened for any player in any veh.

I create a Loop Timer on gamemode init with param "i" for select all player doesn't have seat belt fasten but the song only played when the id 0 player don't gave set belt fasten..

My script:

The Timer:
Код:
forward checkceinturetimer(playerid);
OnGameModeInit:
Код:
	for(new i=0; i<MAX_PLAYERS; i++)
	{
		SetTimer("checkceinturetimer", 3000, false);
	}
Public:
Код:
public checkceinturetimer()
{
	for(new i=0;i<MAX_PLAYERS;i++)
	{
		new carid;
		carid = GetPlayerVehicleID(i);
		if(GetVehicleModel(carid) != 481 || GetVehicleModel(carid) != 509 || GetVehicleModel(carid) != 510)
		{
		    new pState = GetPlayerState(i);
			if(pState == 2 && GetPlayerVehicleSeat(i) == 0)
			{
				if(!Ceinture[i])
				{
					PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
				}
				else
				{
					return 1;
				}
				return 1;
			}
			return 1;
		}
		return 1;
	}
	return 1;
}
Please help me!! Thanks

PS: Sorry for my bad English but i'm Belgian and i post in English because I find that the English community support more than the French community.


Re: Timer set only for 0 id player. - gtakillerIV - 22.07.2013

SetTimer("checkceinturetimer", 3000, false);

This is so wrong. If your MAX_PLAYERS is 500, then you're creating 500 timers for one thing.

Use SetTimerEx.


Re : Timer set only for 0 id player. - ShadowMultiGaming - 22.07.2013

Like that?

Код:
	for(new i=0; i<MAX_PLAYERS; i++)
	{
		SetTimerEx("checkceinturetimer", 5000, false, "i", i);
	}