Problem with timer
#1

I have server running on VPS.VPS has no lag and has no more ping than 60.I have one timer that is working every 1 second.
Код:
SetTimer("FunctionName", 1000, true);
And this function is just decrementing player variable. Im using foreach loop in function. Problem is when i connect for first time on server everything about timer works fine, after some time function/timer just stop(im not sure what is not working).And then i have to restart my server via game panel.Im using if statment to check if is player connect
Код:
if(!IsPlayerConnected(i)) continue;
I never had any problem like this before. I have this server running for like 2.5 years and im using same system for 2.5 years.
Reply
#2

Foreach only loops through connected players, there's no reason to check if they're connected.
Also, can you show the public function?
Reply
#3

well i can show it to you but i guess u wont understand names
Код:
public Odbrojavanja()
{
	foreach(Player, i)
	{
	    if(hIgracUlogovan[i] == 0) continue;
	    new vehicleid = GetPlayerVehicleID(i);
	    if (vehicleid != INVALID_VEHICLE_ID)
				    GetVehiclePos(vehicleid, VehiclePos[vehicleid][0], VehiclePos[vehicleid][1], VehiclePos[vehicleid][2]);
		if(IsPaused[i] == 0)
		{
	    	if(PI[i][ZatvorenVreme] > 0){ PI[i][ZatvorenVreme]--; SCM(i, CRVENA, "Erro!"); }
	    	if(PI[i][Utisan] > 0){PI[i][Utisan]--;if (PI[i][Utisan]==0){SetPlayerChatBubble(i, "", 0xFF0000AA, 15.0, 1);SCM(i,COLOR_WHITE,"{F81414}| GG Anticheat |{FFFFFF}Vise niste utisani, sada pamet u glavu.");}}
        	if(PI[i][Utisan] < 0) PI[i][Utisan] = 0;
	    }
		if(PI[i][MehanicarOdvoz] > 0) PI[i][MehanicarOdvoz]--;
	 	if(hZavezan[i] > 0) hZavezan[i]--;
		if(PI[i][DetektivVreme] > 0) PI[i][DetektivVreme]--;
		if(PI[i][KradljivacVreme] > 0) PI[i][KradljivacVreme]--;
		if(PI[i][DzeparosVreme] > 0) PI[i][DzeparosVreme]--;
		if(PI[i][MobilniDzeparos] > 0) PI[i][MobilniDzeparos]--;
		if(PI[i][LekVreme] > 0) PI[i][LekVreme]--;
		if(PI[i][RovarenjeVreme] > 0) PI[i][RovarenjeVreme]--;
		if(PI[i][ATMRob] > 0) PI[i][ATMRob]--;
		
		if(RentTimer[i] > 0) RentTimer[i]--;
		if(RentTimer[i] <= 0){
			RentTimer[i] = 0;
			new idv = RentVozilo[IznajmioVozilo[i]];
			if(VoziloJeAvion(GetVehicleModel(idv)) || VoziloJeBrod(GetVehicleModel(idv)) || VoziloJeKamion(GetVehicleModel(idv)))
				Gorivo[idv] = 100.00;
			else if(VoziloJeMotor(GetVehicleModel(idv)))
				Gorivo[idv] = 20.00;
			else if(VoziloJeBiciklo(GetVehicleModel(idv)) || GetVehicleModel(idv) == 538)
				Gorivo[idv] = 1000000.00;
			else Gorivo[idv] = 20.00;

			VoziloIznajmljeno[IznajmioVozilo[i]] = -1;
			SetVehicleToRespawn(RentVozilo[IznajmioVozilo[i]]);
			IznajmioVozilo[i] = -1;
			SCM(i, CRVENA, "Istekao vam je rent.");
		}
         }
        return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)