Jump to content

Recommended Posts

Posted

Descriere tutorial: Vreau sa fac si eu pe un server mysql kilometraj la masinile personale , gamemode blown folosesc , am incercat eu sa fac ceva dar nu citeste km dupa restart , o sa las mai jos ce am facut eu .

public CheckGas()
{
	for(new i=1; i<= MAX_VEHICLES; i++)
	{
		if(i != INVALID_VEHICLE_ID)
		{
			GetVehicleParamsEx(i,engine,lights,alarm,doors,bonnet,boot,objective);
			if(engine == VEHICLE_PARAMS_ON && alarmon == 0)
			{
			    if(IsAPlane(i) == 0 && IsABoat(i) == 0 && IsABmx(i) == 0 && Gas > 0  && i != 307 && i != 308 && i != 171 &&i != 172 && i != 173 && i != 174 && i != 161 && i != 162 && i != 163)
				{
					Gas--;
					foreach(Player, o)
					{
					  new Float:Viteza = GetVehicleSpeed_P(o);
					  if(Viteza > 5 && GetPlayerState(o) == PLAYER_STATE_DRIVER && GetPlayerVehicleID(o) == i)
					  {
					    CarData[i-PreVehicle][cKM]++;
				        new query[MAX_STRING];
				        format(query, sizeof(query), "UPDATE cars SET KM='%d' WHERE id=%d", CarData[i-PreVehicle][cKM], i-PreVehicle);
				        mysql_query(query);
					  }
					}
				}
			}
		}
	}
	foreach(Player, i)
	{
   	    if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
   	    {
       		new vehicle = GetPlayerVehicleID(i);
        	if(Gas[vehicle] >= 1)
	   		{
	   		    if(Gas[vehicle] <= 10) { PlayerPlaySound(i, 1085, 0.0, 0.0, 0.0); }
	   		}
   			else
           	{
              	GetVehicleParamsEx(vehicle,engine,lights,alarm,doors,bonnet,boot,objective);
              	SetVehicleParamsEx(vehicle,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
	        	GameTextForPlayer(i,"~w~~n~~n~~n~~n~~n~~n~~n~~n~nu mai ai benzina",1500,3);
			}
		}
	}
	return 1;
 }

aceasta salveaza km in baza de date dar nu stiu cum sa-l fac sa citeasca ..

Va multumesc !

Posted

Am reusit sa fac , dar dupa ce iesi de pe server sau intra alt cnv in masina nu mai apare textdraw km si nici nu ii mai contorizeaza :-?

Guest
This topic is now closed to further replies.
×
×
  • 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.