21.05.2016, 04:09
PHP код:
for(new i = 0; i < GetMaxPlayers(); i++)
{
//more textdraws before
Textdraw7 = TextDrawCreate(230.799987, 403.953308, "usebox"); //box
TextDrawLetterSize(Textdraw7, 0.000000, 1.591485);
TextDrawTextSize(Textdraw7, 129.199996, 0.000000);
TextDrawAlignment(Textdraw7, 1);
TextDrawColor(Textdraw7, 0);
TextDrawUseBox(Textdraw7, true);
TextDrawBoxColor(Textdraw7, 102);
TextDrawSetShadow(Textdraw7, 0);
TextDrawSetOutline(Textdraw7, 0);
TextDrawFont(Textdraw7, 0);
for(new i = 0; i < GetMaxPlayers(); i++)
{
Textdraw8[i] = TextDrawCreate(139.199981, 403.946777, ""); //speed
TextDrawLetterSize(Textdraw8[i], 0.415599, 1.473066);
TextDrawAlignment(Textdraw8[i], 1);
TextDrawColor(Textdraw8[i], -16776961);
TextDrawSetShadow(Textdraw8[i], 0);
TextDrawSetOutline(Textdraw8[i], 1);
TextDrawBackgroundColor(Textdraw8[i], 51);
TextDrawFont(Textdraw8[i], 1);
TextDrawSetProportional(Textdraw8[i], 1);
//more textdraws, such as fuel, health and etc.
}
}
PHP код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER) {
TextDrawShowForPlayer(playerid, Textdraw7); //show box
for(new i = 0; i < MAX_PLAYERS; i++)
{
TextDrawShowForPlayer(playerid, Textdraw8[playerid]); //show speed
}
}
else if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER) {
TextDrawHideForPlayer(playerid, Textdraw7); //show box
for(new i = 0; i < MAX_PLAYERS; i++)
{
TextDrawHideForPlayer(playerid, Textdraw8[playerid]); //show speed
}
}
}
PHP код:
//after public OnGameModeInit()
SetTimer("speedoUpdate", 10, true); //the bigger number is, the slower speedometer will be (this is time in milliseconds).
PHP код:
//somewhere at the bottom of your script
forward speedoUpdate(playerid);
public speedoUpdate(playerid)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
{
new string [ 32 ],
format(string, sizeof(string), "%d", GetPlayerSpeed(i, 0)); //set string for Texdraw8
TextDrawSetString(Texdraw8[i], string);
}
}
return 1;
}
PHP код:
stock GetPlayerSpeed(playerid, get3d) //get player speed
{
new
Float:x,
Float:y,
Float:z;
if(IsPlayerInAnyVehicle(playerid))
GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
else
GetPlayerVelocity(playerid, x, y, z);
return SpeedCheck(x, y, z, 100.0, get3d);
}