В начало мода добавляем:
Код: Выделить всё
#define Update 100
new Text:SpeedShow[MAX_PLAYERS];
new STimer[MAX_PLAYERS];
В public OnPlayerSpawn
Код: Выделить всё
TextDrawHideForPlayer(playerid,SpeedShow[playerid]);
В public OnPlayerDeath
Код: Выделить всё
TextDrawHideForPlayer(playerid,SpeedShow[playerid]);
В public OnPlayerConnect
Код: Выделить всё
SpeedShow[playerid] = TextDrawCreate(510.000000,400.000000,"0");
TextDrawBackgroundColor(SpeedShow[playerid],COLOR_BLACK);
TextDrawLetterSize(SpeedShow[playerid],0.899999,2.510000);
TextDrawFont(SpeedShow[playerid],3);//ñòèëü
TextDrawColor(SpeedShow[playerid],COLOR_BLUE);
TextDrawSetOutline(SpeedShow[playerid],1);
TextDrawSetProportional(SpeedShow[playerid],1);
TextDrawSetShadow(SpeedShow[playerid],1);
STimer[playerid] = SetTimerEx("UpdateSpeed", Update, 1, "d", playerid);
В public OnPlayerDisconnect
Код: Выделить всё
KillTimer(STimer[playerid]);
TextDrawDestroy(SpeedShow[playerid]);
В public OnPlayerStateChange
Код: Выделить всё
if(newstate == PLAYER_STATE_DRIVER)
{
TextDrawShowForPlayer(playerid,SpeedShow[playerid]);
}
if(oldstate == PLAYER_STATE_DRIVER)
{
TextDrawHideForPlayer(playerid,SpeedShow[playerid]);
}
в конец мода
Код: Выделить всё
stock SpeedVehicle(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)) * 120.3;
return floatround(ST[3]);
}
forward UpdateSpeed(playerid);
public UpdateSpeed(playerid)
{
if(IsPlayerInAnyVehicle(playerid))
{
new str[15];
format(str, sizeof(str),"%d",SpeedVehicle(playerid));
TextDrawSetString(SpeedShow[playerid],str);
}
}