I Hate Timers :(
#5

Quote:
Originally Posted by Aly
Посмотреть сообщение
Why do you need that timer?
Use OnPlayerStateChange like:
pawn Код:
if(newstate == PLAYER_STATE_DRIVER || PLAYER_STATE_PASSENGER)
{
                        TextDrawShowForPlayer(playerid, Speedo0[playerid);
            TextDrawShowForPlayer(playerid, Speedo1[playerid]);
            TextDrawShowForPlayer(playerid, Speedo2[playerid]);
            TextDrawShowForPlayer(playerid,Speedo3[playerid]);
            TextDrawShowForPlayer(playerid, Speedo4[playerid]);
            TextDrawShowForPlayer(playerid, Speedo5[playerid]);
            TextDrawShowForPlayer(playerid, Speedo6[playerid]);
            TextDrawShowForPlayer(playerid, Speedo7[playerid]);
            TextDrawShowForPlayer(playerid, Speedo8[playerid]);
            TextDrawShowForPlayer(playerid, Speedo9[playerid]);
            TextDrawShowForPlayer(playerid, Speedo10[playerid]);
            TextDrawShowForPlayer(playerid, Speedo11[playerid]);
            TextDrawShowForPlayer(playerid, Speedo12[playerid]);
            TextDrawShowForPlayer(playerid, Speedo13[playerid]);
}
if(oldstate == PLAYER_STATE_DRIVER || PLAYER_STATE_PASSANGER)
{
                        TextDrawHideForPlayer(playerid, Speedo0[playerid);
            TextDrawHideForPlayer(playerid, Speedo1[playerid]);
            TextDrawHideForPlayer(playerid, Speedo2[playerid]);
            TextDrawHideForPlayer(playerid,Speedo3[playerid]);
            TextDrawHideForPlayer(playerid, Speedo4[playerid]);
            TextDrawHideForPlayer(playerid, Speedo5[playerid]);
            TextDrawHideForPlayer(playerid, Speedo6[playerid]);
            TextDrawHideForPlayer(playerid, Speedo7[playerid]);
            TextDrawHideForPlayer(playerid, Speedo8[playerid]);
            TextDrawHideForPlayer(playerid, Speedo9[playerid]);
            TextDrawHideForPlayer(playerid, Speedo10[playerid]);
            TextDrawHideForPlayer(playerid, Speedo11[playerid]);
            TextDrawHideForPlayer(playerid, Speedo12[playerid]);
            TextDrawHideForPlayer(playerid, Speedo13[playerid]);
}
Ok i will put the textdraws there but that is not the full code of that timer i just paste here the textdraws, under that code is more stuff...
Here is the rest of the code
Код:
public Speedometer()
{
	new Hour, Minute, Second;
	gettime(Hour, Minute, Second);
	new saat = Hour+1;
	SetWorldTime(saat);
	SetWeather(2);
	foreach (new i : Player)
	{
		if(IsPlayerInAnyVehicle(i))
		{
			TextDrawShowForPlayer(i, Speedo0[i]);
			TextDrawShowForPlayer(i, Speedo1[i]);
			TextDrawShowForPlayer(i, Speedo2[i]);
			TextDrawShowForPlayer(i, Speedo3[i]);
			TextDrawShowForPlayer(i, Speedo4[i]);
			TextDrawShowForPlayer(i, Speedo5[i]);
			TextDrawShowForPlayer(i, Speedo6[i]);
			TextDrawShowForPlayer(i, Speedo7[i]);
			TextDrawShowForPlayer(i, Speedo8[i]);
			TextDrawShowForPlayer(i, Speedo9[i]);
			TextDrawShowForPlayer(i, Speedo10[i]);
			TextDrawShowForPlayer(i, Speedo11[i]);
			TextDrawShowForPlayer(i, Speedo12[i]);
			TextDrawShowForPlayer(i, Speedo13[i]);
			new vehicleid = GetPlayerVehicleID(i);
			if(vehicleid != 0)
			{
				new brzinastring[64];
				new speed = floatround(GetVehicleSpeed(GetPlayerVehicleID(i),0));
				format(brzinastring,sizeof(brzinastring),"%i",speed);
				TextDrawSetString(Speedo1[i], brzinastring);
				new vozilostring[64];
				format(vozilostring,sizeof(vozilostring),"%s", VehNames[GetVehicleModel(vehicleid) - 400]);
				TextDrawSetString(Speedo3[i], vozilostring);
			    new Float:vh;
			    new h, jacinastring[64];
			    GetVehicleHealth(vehicleid, vh);
			    h = floatround(vh) / 10;
			 	if(h >= 75)
	 			{
	    			format(jacinastring, sizeof(jacinastring), "%d\%", h); //55 -> Orange, 30 -> Red
	    			TextDrawSetString(Speedo5[i], jacinastring);
				}
	 			if(h >= 50 && h <= 74)
	 			{
	    			format(jacinastring, sizeof(jacinastring), "~y~%d\%", h); //55 -> Orange, 30 -> Red
	    			TextDrawSetString(Speedo5[i], jacinastring);
				}
	 			if(h >= 0 && h <= 49)
	 			{
	    			format(jacinastring, sizeof(jacinastring), "~r~%d\%", h); //55 -> Orange, 30 -> Red
	    			TextDrawSetString(Speedo5[i], jacinastring);
				}
				new gorivostring[64];
			    format(gorivostring, sizeof(gorivostring), "%d litri", Gas[vehicleid]); //55 -> Orange, 30 -> Red
			    TextDrawSetString(Speedo7[i], gorivostring);
				new gpsstring[64];
				new Zona[MAX_ZONE_NAME];
				GetPlayer2DZone(i, Zona, MAX_ZONE_NAME);
			    format(gpsstring, sizeof(gpsstring), "%s", Zona); //55 -> Orange, 30 -> Red
			    TextDrawSetString(Speedo11[i], gpsstring);
				new rtext[24];
				if(Registrirano[vehicleid] == 1)
				{
				    rtext = "Da";
				}
				if(Registrirano[vehicleid] == 0)
				{
				    rtext = "~r~Ne";
				}
				new regstring[64];
 	 			format(regstring, sizeof(regstring), "%s", rtext); //55 -> Orange, 30 -> Red
	    		TextDrawSetString(Speedo9[i], regstring);
				new kmstring[64];
	    		format(kmstring, sizeof(kmstring), "%.02f", KMPominati[vehicleid] * 0.000621); //55 -> Orange, 30 -> Red
	    		TextDrawSetString(Speedo13[i], kmstring);
				if(ConvertVehIDtoDYID(vehicleid) != -1)
	 			{
	 			    new vozilo = ConvertVehIDtoDYID(vehicleid);
					GetPlayerPos(i,x2km[i],y2km[i],z2km[i]);
   					temper[i] = floatsqroot(floatpower(floatabs(floatsub(xkm[i],x2km[i])),2)+floatpower(floatabs(floatsub(ykm[i],y2km[i])),2)+floatpower(floatabs(floatsub(zkm[i],z2km[i])),2));
   					MyVehicle[vozilo][MyVehKM] += temper[i];
					KMPominati[vehicleid] = MyVehicle[vozilo][MyVehKM];
   					xkm[i] = x2km[i];
   					ykm[i] = y2km[i];
   					zkm[i] = z2km[i];
   					UpdateMyVehSystem(vozilo);
					return 1;
				}
				GetPlayerPos(i,x2km[i],y2km[i],z2km[i]);
   				temper[i] = floatsqroot(floatpower(floatabs(floatsub(xkm[i],x2km[i])),2)+floatpower(floatabs(floatsub(ykm[i],y2km[i])),2)+floatpower(floatabs(floatsub(zkm[i],z2km[i])),2));
   				KMPominati[vehicleid] += temper[i];
   				xkm[i] = x2km[i];
   				ykm[i] = y2km[i];
   				zkm[i] = z2km[i];
			}
		}
		else
		{
		    if(RentaMotor[i] == 1)
		    {
		    	KillTimer(RentanjeTimer[i]);
		    	KillTimer(RentanjeTimer1[i]);
		    	RentaMotor[i] = 0;
		    }
		}
 	}
 	return 1;
}
At the other timers which i have mentioned on the top i have codes in them to update the textdraws, but when i make them global timers they don't update...
Reply


Messages In This Thread
I Hate Timers :( - by NeroX98 - 11.06.2013, 20:36
Re: I Hate Timers :( - by RALL0 - 11.06.2013, 20:47
Re: I Hate Timers :( - by NeroX98 - 11.06.2013, 20:53
Re: I Hate Timers :( - by Aly - 11.06.2013, 20:58
Re: I Hate Timers :( - by NeroX98 - 11.06.2013, 21:02
Re: I Hate Timers :( - by RALL0 - 11.06.2013, 21:02
Re: I Hate Timers :( - by Aly - 11.06.2013, 21:08

Forum Jump:


Users browsing this thread: 1 Guest(s)