SA-MP Forums Archive
Textdraw 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: Textdraw help. (/showthread.php?tid=186429)



Textdraw help. - zack3021 - 29.10.2010

I made my speedo but i dont know why it wont hide when the player exits the vehicle

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    for(new i=0; i<MAX_PLAYERS; i++){
    {
        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)
    {
        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(playerid)
{
    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)
    {
        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(playerid, LocationZone, 256);
    new Float:X, Float:Y, Float:Z, Float:Distance;
    GetPlayerPos(playerid, 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;
}



Respuesta: Textdraw help. - admantis - 29.10.2010

pawn Код:
if(newstate == PLAYER_STATE_ONFOOT) && (oldstate == PLAYER_STATE_DRIVER) || (oldstate == PLAYER_STATE_PASSENGER)
    {
        TextDrawHideForPlayer(i, Textdraw0[i]);
        TextDrawHideForPlayer(i, Textdraw1[i]);
        TextDrawHideForPlayer(i, Textdraw2[i]);
        TextDrawHideForPlayer(i, Textdraw3[i]);
        TextDrawHideForPlayer(i, Textdraw4[i]);
    }
    }
    return 1;
}
Im not sure if this will work


Re: Textdraw help. - zack3021 - 29.10.2010

You dont need the brackets in it, just the one after if and the last one. I will try it.

Oh btw it only works when id 0 goes in the car (it works for every one with id 0)