Problem with fuel system
#1

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]);
        }
    }
}
Reply
#2

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);
    }
}
Reply
#3

thank u
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)