Problem with fuel system - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem with fuel system (
/showthread.php?tid=474783)
Problem with fuel system -
MrTinder - 09.11.2013
So..I wanna if player is on bike to see only "Speed: 40 km/h".Here is my code:
pawn Код:
public Speedupdate()
{
for(new i = 0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
{
new Float:x,Float:y,Float:z,Float:hp,string[24],vehicleid = GetPlayerVehicleID(i);
TextDrawShowForPlayer(i,speed[i]);
TextDrawShowForPlayer(i,health[i]);
TextDrawShowForPlayer(i,fuel[i]);
GetVehicleVelocity(vehicleid,x,y,z);
GetVehicleHealth(vehicleid,hp);
format(string,sizeof(string),"~w~ Speed: %d km/h",floatround(floatsqroot(((x*x)+(y*y))+(z*z))*181.5));
TextDrawSetString(speed[i],string);
if(GetVehicleModel(vehicleid) != 509 || GetVehicleModel(vehicleid) != 510 || GetVehicleModel(vehicleid) != 481)
{
format(string,sizeof(string),"~g~ Health: %d",floatround(hp));
TextDrawSetString(health[i],string);
format(string,sizeof(string),"~r~ Fuel: %dL",VehicleFuel[vehicleid]);
TextDrawSetString(fuel[i],string);
}
}
if(!IsPlayerInAnyVehicle(i))
{
TextDrawHideForPlayer(i,speed[i]);
TextDrawHideForPlayer(i,health[i]);
TextDrawHideForPlayer(i,fuel[i]);
}
}
}
Re: Problem with fuel system -
Loot - 09.11.2013
pawn Код:
stock IsBike(vehicleid)
{
switch(GetVehicleModel(vehicleid))
{
case 448, 461 .. 463, 468, 471, 481, 509, 510, 521, 522, 581: return 1; // bike models
}
return 0;
}
pawn Код:
if(GetVehicleModel(vehicleid) != 509 || GetVehicleModel(vehicleid) != 510 || GetVehicleModel(vehicleid) != 481)
{
if(!IsBike(vehicleid)) // check also if he's NOT driving a bike to show other textdraws
{
// show other stuff,.. etc
format(string,sizeof(string),"~g~ Health: %d",floatround(hp));
TextDrawSetString(health[i],string);
format(string,sizeof(string),"~r~ Fuel: %dL",VehicleFuel[vehicleid]);
TextDrawSetString(fuel[i],string);
}
}
Re: Problem with fuel system -
MrTinder - 09.11.2013
thank u