SA-MP Forums Archive
Speedo Help - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Speedo Help (/showthread.php?tid=186433)



Speedo Help - zack3021 - 29.10.2010

When the player goes in a vehicle they dont see the speedo but when i go into another vehicle (i am id 0 and they and i are in different vehicles) it workes perfectly, but as soon i step out of my car, they dont see anything. Can anyone help me.

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    for(new i=0; i<MAX_PLAYERS; i++){
    if(newstate == PLAYER_STATE_DRIVER)
    {
          TextDrawShowForPlayer(i, Textdraw0[i]);
        TextDrawShowForPlayer(i, Textdraw1[i]);
        TextDrawShowForPlayer(i, Textdraw2[i]);
        TextDrawShowForPlayer(i, Textdraw3[i]);
        TextDrawShowForPlayer(i, Textdraw4[i]);
    }
    if(oldstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_ONFOOT)
    {
        TextDrawHideForPlayer(i, Textdraw0[i]);
        TextDrawHideForPlayer(i, Textdraw1[i]);
        TextDrawHideForPlayer(i, Textdraw2[i]);
        TextDrawHideForPlayer(i, Textdraw3[i]);
        TextDrawHideForPlayer(i, Textdraw4[i]);
    }
    }
    return 1;
}
pawn Код:
public Speed()
{
    for(new i=0; i<MAX_PLAYERS; i++){
    new vehicleid,Float:speed_x,Float:speed_y,Float:speed_z,Float:final_speed,speed_string[256],final_speed_int;
     vehicleid = GetPlayerVehicleID(i);
    if(vehicleid != 0 || IsPlayerInAnyVehicle(i))
    {
        GetVehicleVelocity(vehicleid,speed_x,speed_y,speed_z);
        final_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*85.4166672; // 136.666667 = kmph  // 85.4166672= mph
        final_speed_int = floatround(final_speed,floatround_round);
        format(speed_string,256,"Speed: ~w~%i",final_speed_int);
        TextDrawSetString(Textdraw1[i], speed_string);
        TextDrawShowForPlayer(i, Textdraw1[i]);
    }
    {
    new string[128],Float:health;
    GetVehicleHealth(GetPlayerVehicleID(i), health);
     format(string, sizeof(string), "Health: ~w~%.1f", health);
    TextDrawSetString(Textdraw3[i], string);
    TextDrawShowForPlayer(i, Textdraw3[i]);
    }
    {
    new PlayerVehicleModelID = GetVehicleModel(GetPlayerVehicleID(i)),String[128],Float:Distance;
    PlayerVehicleModelID -= 400;
    format(String,sizeof(String),"Name: ~w~%s",PlayerVehicle[PlayerVehicleModelID],floatround(floatmul(floatdiv(Distance, 1.609344), 2.0), floatround_floor), floatround(floatmul(Distance, 2.0), floatround_floor));
    TextDrawSetString(Textdraw0[i], String);
    TextDrawShowForPlayer(i, Textdraw0[i]);
    }
    {
    new string[256];
    new LocationZone[256];
    GetPlayer2DZone(i, LocationZone, 256);
    new Float:X, Float:Y, Float:Z, Float:Distance;
    GetPlayerPos(i, X, Y, Z);
    Distance = floatsqroot(floatadd(floatadd(floatpower(floatsub(X, OldX[i]), 2), floatpower(floatsub(Y, OldY[i]), 2)), floatpower(floatsub(Z, OldZ[i]), 2)));
    format(string,sizeof(string),"GPS: ~w~%s",LocationZone, floatround(floatmul(floatdiv(Distance, 1.609344), 2.0), floatround_floor), floatround(floatmul(Distance, 2.0), floatround_floor));
    TextDrawSetString(Textdraw4[i], string);
    TextDrawShowForPlayer(i, Textdraw4[i]);
     }
    }
    return 1;
}