Jump to content
  • 0

Problema kilometraj


Dripple

Question

Salut, am schimbat kilometraj-ul de pe server dupa modelul vechi, fara sa ii fac vreo modificare. Se complicaza perfect, dar cand intru intr-o masina doar imi apar textdraw-urile exact cum le-am creat si nu se intampla nimic. Aveti mai jos codurile necesare.

function CheckCar()
{
 	foreach(new i : Player)
	{
 		new vehicleid = GetPlayerVehicleID(i);
		new carid = FindSpawnID(vehicleid);
	    if(GetPlayerState(i) == PLAYER_STATE_DRIVER && SpeedLimiter[i] > 0 && GetPlayerSpeed(i, 0) > SpeedLimiter[i])
		{
			new newspeed = GetPlayerSpeed(i, 0) - SpeedLimiter[i];
			ModifyVehicleSpeed(GetPlayerVehicleID(i), - newspeed);
		}
		
		if(IsPlayerInAnyVehicle(i))
		{
			new car = GetPlayerVehicleID(i);
			new Speed;
			new idd;
   			new str0[128],str1[128],str2[128],str3[128];
			new str4[128],str5[128],str6[128],str7[128];
			new str8[128],str9[128],str10[128];
   			new LuxZone[MAX_ZONE_NAME];
			if(GetVehicleType(car) == 5 || GetVehicleType(car) == 9) Speed = GetPlayerSpeed(i,1);
			else Speed = GetPlayerSpeed(i,0);
			new Float: oldX[MAX_PLAYERS], Float: oldY[MAX_PLAYERS], Float: oldZ[MAX_PLAYERS];
			oldX[i] = PosX[i];
			oldY[i] = PosY[i];
			oldZ[i] = PosZ[i];
			GetPlayerPos(i,PosX[i],PosY[i],PosZ[i]);
			GetPlayer2DZone(i, LuxZone, MAX_ZONE_NAME);
			new Float:distanta[MAX_PLAYERS];
			GetVehicleParamsEx(car,engine,lights,alarm,doors,bonnet,boot,objective);
			distanta[i] = GetDistanceBetweenPoints(oldX[i],oldY[i],oldZ[i],PosX[i],PosY[i],PosZ[i]);
			format(str0, sizeof(str0), "~w~Vehicle: ~y~%s", vehName[CarInfo[idd][cModel]-400]);
			TextDrawSetString(textmasina[i], str0);
			if(Speed<=100)
			{
				format(str1, sizeof(str1), "~w~Speed: ~y~%d KM/H", Speed);
				TextDrawSetString(textviteza[i], str1);
			}
			if(Speed>100 && Speed<=150)
			{
				format(str1, sizeof(str1), "~w~Speed: ~b~%d KM/H", Speed);
				TextDrawSetString(textviteza[i], str1);
			}
			if(Speed>150)
			{
				format(str1, sizeof(str1), "~w~Speed: ~r~%d KM/H", Speed);
				TextDrawSetString(textviteza[i], str1);
			}
			format(str2, sizeof(str2), "~w~Fuel: ~y~%d%L", Fuel[car]);
			TextDrawSetString(textbenzina[i], str2);
			if(lights == 1)
			{
				format(str3,sizeof(str3),"~b~L");
				TextDrawSetString(textfaruri[i], str3);
			}
			if(lights == 0)
			{
				format(str3,sizeof(str3),"~w~L");
				TextDrawSetString(textfaruri[i], str3);
			}
   			if(engine == 1)
			{
				format(str4,sizeof(str4),"~g~EN");
				TextDrawSetString(textmotor[i], str4);
			}
			if(engine == 0)
			{
				format(str4,sizeof(str4),"~r~EN");
				TextDrawSetString(textmotor[i], str4);
			}
			if(Speed>1)
			{
				format(str5,sizeof(str5),"~g~1~w~/N");
				TextDrawSetString(textinainte[i], str5);
			}
			if(Speed == 0)
			{
				format(str5,sizeof(str5),"~w~1/~y~N");
				TextDrawSetString(textinainte[i], str5);
			}
			if(Fuel[car]<=10)
			{
				format(str6,sizeof(str6),"~r~E");
				TextDrawSetString(textempty[i], str6);
			}
			if(Fuel[car]>=11)
			{
				format(str6,sizeof(str6),"~w~E");
				TextDrawSetString(textempty[i], str6);
			}
			format(str7,sizeof(str7),"~w~GPS: ~y~%s",LuxZone);
			TextDrawSetString(textgps[i], str7);
			CarInfo[carid][KM] += distanta[i]/5000;
			mysql_format(handle, str8,128,"UPDATE `cars` SET `KM`='%f' WHERE `ID`='%d' LIMIT 1",CarInfo[carid][KM],carid);
			mysql_tquery(handle, str8, "", "");
			idd = PlayerInfo[i][CarKey1] || PlayerInfo[i][CarKey2] || PlayerInfo[i][CarKey3] || PlayerInfo[i][CarKey4] || PlayerInfo[i][CarKey5];
			if(CarInfo[carid][cID] != -2 && carid != 0)
			{
				format(str9,sizeof(str9),"~w~Odometer: ~y~%.2f",CarInfo[carid][KM]);
				TextDrawSetString(textodo[i], str9);
			}
			else
			{
				format(str9,sizeof(str9),"~w~Odometer: ~y~N/A");
    			TextDrawSetString(textodo[i], str9);
			}
			if(Speed > 235 && GetVehicleType(car) != 5 && GetVehicleType(car) != 9 && GetPlayerState(i) == PLAYER_STATE_DRIVER)
			{
				if(SHB[i] < gettime())
				{
				    format(str10, sizeof(str10), "{ffff00}AdmWarning:{FFFFFF} %s caught %d km/h with a %s.",GetName(i), Speed, VehicleNames[GetVehicleModel(car) - 400]);
					ABroadCast(COLOR_LIGHTRED, str10, 1);
					format(str10, sizeof(str10), "speed hack (%d km/h with %s)", Speed, VehicleNames[GetVehicleModel(car) - 400]);
					HackLog(i, str10);
				}
				SHB[i] = gettime()+5;
			}
		}
    	if(SpectatorID[i] != INVALID_PLAYER_ID)
		{
			if(GetPlayerInterior(i) != GetPlayerInterior(SpectatorID[i])) SetPlayerInterior(i, GetPlayerInterior(SpectatorID[i]));
			if(GetPlayerVirtualWorld(i) != GetPlayerVirtualWorld(SpectatorID[i])) SetPlayerVirtualWorld(i, GetPlayerVirtualWorld(SpectatorID[i]));

			if((GetPlayerState(SpectatorID[i]) == PLAYER_STATE_DRIVER || GetPlayerState(SpectatorID[i]) == PLAYER_STATE_PASSENGER) && OldState[SpectatorID[i]] != GetPlayerState(SpectatorID[i])) PlayerSpectateVehicle(i, GetPlayerVehicleID(SpectatorID[i]));
			else if(GetPlayerState(SpectatorID[i]) == PLAYER_STATE_ONFOOT && OldState[SpectatorID[i]] != GetPlayerState(SpectatorID[i])) PlayerSpectatePlayer(i, SpectatorID[i]);
			OldState[SpectatorID[i]] = GetPlayerState(SpectatorID[i]);

			new specstring[210], Float:shp, Float:sap, Float:vhp, temp2[70], temp3[60];
			GetPlayerHealthEx(SpectatorID[i], shp);
			GetPlayerArmourEx(SpectatorID[i], sap);
			format(specstring, sizeof(specstring), "~r~%s(%d)~w~ (%.1fHP/%.1fAP)", GetName(SpectatorID[i]), SpectatorID[i], shp, sap);
			if(GetPlayerWeapon(SpectatorID[i]) > 0 && GetPlayerAmmo(SpectatorID[i]) > 0) { format(temp2, sizeof(temp2), "~n~Weapon: ~r~%d ~w~Ammo: ~r~%d", GetPlayerWeapon(SpectatorID[i]), GetPlayerAmmo(SpectatorID[i])); strcat(specstring, temp2); }
			if(IsPlayerInAnyVehicle(SpectatorID[i])) { GetVehicleHealth(GetPlayerVehicleID(SpectatorID[i]), vhp); format(temp3, sizeof(temp3), "~n~~w~Vehicle(%d): ~r~%.1f HP ~w~Speed: ~r~%dkm/h", GetPlayerVehicleID(SpectatorID[i]), vhp, GetPlayerSpeed(SpectatorID[i], 0)); strcat(specstring, temp3); }
			PlayerTextDrawSetString(i, SpecText[i], specstring);
		}
	}
	return 1;
}

Textdraw-urile sunt puse sa apara atunci cand intri intr-o masina, si sa dispara cand iesi din ea. Am incercat sa le pun sa le pun in functie, dar degeaba, la fel face.

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.