Bug or what? - 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: Bug or what? (
/showthread.php?tid=355539)
Bug or what? -
vassilis - 30.06.2012
Hello guys as a friend of mine told me it would be better to use PlayerCreateTextdraw and all the related fuctions for a vehicle status system
Health:
Speed: etc..
But i still got the same problem which means that playerids > 0 doesn't show textdraw of Health and Speed why that happens?
Here is the code though.
pawn Код:
new PlayerText:SPEEDOS[MAX_PLAYERS];
new PlayerText:HEALTH[MAX_PLAYERS];
public Speedometer(playerid)
{
new vehicleid,Float:speed_x,Float:speed_y,Float:speed_z,Float:final_speed,speed_string[256],final_speed_int;
vehicleid = GetPlayerVehicleID(playerid);
new Float:vehicle_health,final_vehicle_health,health_string[256];
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))*250.666667;
final_speed_int = floatround(final_speed,floatround_round);
format(speed_string,256,"~y~Speed: ~w~%i",final_speed_int);
PlayerTextDrawSetString(playerid,SPEEDOS[playerid], speed_string);
PlayerTextDrawShow(playerid,SPEEDOS[playerid]);
GetVehicleHealth(vehicleid,vehicle_health);
final_vehicle_health = floatround(floatround(vehicle_health - 250)/ 7.5);
format(health_string,256,"~r~Health: ~w~%i", final_vehicle_health);
PlayerTextDrawSetString(playerid,HEALTH[playerid], health_string);
PlayerTextDrawShow(playerid,HEALTH[playerid]);
}
else
{
PlayerTextDrawSetString(playerid,SPEEDOS[playerid], " ");
PlayerTextDrawSetString(playerid,HEALTH[playerid], " ");
}
return 1;
}
Re: Bug or what? -
Mean - 30.06.2012
Can you show us how/where that function gets called? Also where are you using CreatePlayerTextdraw?
Also: isn't final_vehicle_health supposed to be a float?
Re: Bug or what? -
vassilis - 30.06.2012
This is all what i have... and the createplayertextdraw is under onplayerconnect should i reput it under ongamemodeinit?
Re: Bug or what? -
Mean - 30.06.2012
I meant where the Speedometer(playerid) gets called.
Re: Bug or what? -
vassilis - 30.06.2012
Quote:
Originally Posted by Mean
I meant where the Speedometer(playerid) gets called.
|
OnPlayerConnect
pawn Код:
SetTimer("Speedometer",100,1);
Re: Bug or what? -
Mean - 30.06.2012
Replace it with:
pawn Код:
SetTimerEx("Speedometer",100,1, "i", playerid);
Must work then.
Re: Bug or what? -
vassilis - 01.07.2012
Ok Thank you.