26.09.2012, 23:22
Usa ae o rjj me arrumo isso e to repassando!
pawn Код:
//No Topo do GM:
new Text:Velocimetro[MAX_PLAYERS];
new TimerVelocimetro[MAX_PLAYERS];
//No OnGameModeInit:
for(new x = 0; x < MAX_PLAYERS; x++)
{
Velocimtro[x] = TextDrawCreate(445.000000, 399.000000, " ");
TextDrawFont(Velocimtro[x], 2);
TextDrawLetterSize(Velocimtro[x], 0.4, 2.0);
TextDrawColor(Velocimtro[x], -1);
TextDrawSetOutline(Velocimtro[x], 0);
TextDrawUseBox(Velocimtro[x], 0);
TextDrawBoxColor(Velocimtro[x], 0x0000000F);
TextDrawSetProportional(Velocimtro[x], 1);
TextDrawSetShadow(Velocimtro[x], 1);
}
//No OnPlayerDisconnect:
KillTimer(TimerVelocimetro[playerid]);
//No OnPlayerStateChange:
if(newstate == PLAYER_STATE_DRIVER)
{
TimerVelocimetro[playerid] = SetTimerEx("AtualizarVelocimetro", 100, true, "n", playerid);
}
else if(oldstate == PLAYER_STATE_DRIVER)
{
KillTimer(TimerVelocimetro[playerid]);
TextDrawHideForPlayer(playerid, Velocimetro[playerid]);
}
//E, no Final do GM:
forward AtualizarVelocimetro(playerid);
public AtualizarVelocimetro(playerid)
{
static STR[30];
format(STR, 30, "Velocidade: %i Km/h", GetPlayerSpeed(playerid));
TextDrawSetString(Velocimetro[playerid], STR);
TextDrawShowForPlayer(playerid, Velocimetro[playerid]);
return 1;
}
// Stock
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]);
}