Timer set only for 0 id player.
#1

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.
Reply
#2

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.
Reply
#3

Like that?

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


Forum Jump:


Users browsing this thread: 1 Guest(s)