06.03.2014, 13:51
Queria que alguйm colocasse nesse cуdigo e me enviasse para aparecer a velocidade Km/h pra quem ta de carona porque sу aparece pra quem ta dirigindo.
PHP код:
#include a_samp
new Text:Textdraw0[MAX_PLAYERS];
new Text:Textdraw1[MAX_PLAYERS];
new TimerVelocimetro[MAX_PLAYERS];
public OnFilterScriptInit()
{
for(new x = 0; x < MAX_PLAYERS; x++){
Textdraw0[x] = TextDrawCreate(548.000000, 350.000000, "");// Velocidade
TextDrawBackgroundColor(Textdraw0[x], 255);
TextDrawFont(Textdraw0[x], 2);
TextDrawLetterSize(Textdraw0[x], 0.569999, 3.999998);
TextDrawColor(Textdraw0[x], -1);
TextDrawSetOutline(Textdraw0[x], 0);
TextDrawSetProportional(Textdraw0[x], 1);
TextDrawSetShadow(Textdraw0[x], 1);
Textdraw1[x] = TextDrawCreate(600.000000, 350.000000, "Km/h");// KM
TextDrawBackgroundColor(Textdraw1[x], 255);
TextDrawFont(Textdraw1[x], 2);
TextDrawLetterSize(Textdraw1[x], 0.210000, 1.300000);
TextDrawColor(Textdraw1[x], -1);
TextDrawSetOutline(Textdraw1[x], 0);
TextDrawSetProportional(Textdraw1[x], 1);
TextDrawSetShadow(Textdraw1[x], 1);
}
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerConnect(playerid)
{
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
KillTimer(TimerVelocimetro[playerid]);
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
TimerVelocimetro[playerid] = SetTimerEx("AtualizarVelocimetro", 100, true, "n", playerid);
}
else if(oldstate == PLAYER_STATE_DRIVER)
{
KillTimer(TimerVelocimetro[playerid]);
TextDrawHideForPlayer(playerid, Textdraw0[playerid]);
TextDrawHideForPlayer(playerid, Textdraw1[playerid]);
}
return 1;
}
forward AtualizarVelocimetro(playerid);
public AtualizarVelocimetro(playerid)
{
if(IsPlayerInAnyVehicle(playerid))
{
new Velo[30];
format(Velo, 30, "%i", GetPlayerSpeed(playerid));
TextDrawSetString(Textdraw0[playerid], Velo);
TextDrawShowForPlayer(playerid, Textdraw0[playerid]);
TextDrawShowForPlayer(playerid, Textdraw1[playerid]);
}
return 1;
}
stock GetPlayerSpeed(playerid)
{
new Float:ST[4];
if(IsPlayerInAnyVehicle(playerid))
GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]);
else GetPlayerVelocity(playerid,ST[0],ST[1],ST[2]);
ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 100.3;
return floatround(ST[3]);
}