help, speedometer function
#3

PHP код:
for(new 0GetMaxPlayers(); i++)
{
    
//more textdraws before
    
    
Textdraw7 TextDrawCreate(230.799987403.953308"usebox"); //box
    
TextDrawLetterSize(Textdraw70.0000001.591485);
    
TextDrawTextSize(Textdraw7129.1999960.000000);
    
TextDrawAlignment(Textdraw71);
    
TextDrawColor(Textdraw70);
    
TextDrawUseBox(Textdraw7true);
    
TextDrawBoxColor(Textdraw7102);
    
TextDrawSetShadow(Textdraw70);
    
TextDrawSetOutline(Textdraw70);
    
TextDrawFont(Textdraw70);
    for(new 
0GetMaxPlayers(); i++)
    {
        
Textdraw8[i] = TextDrawCreate(139.199981403.946777""); //speed
        
TextDrawLetterSize(Textdraw8[i], 0.4155991.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(playeridnewstateoldstate)
{
    if(
newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER) {
        
TextDrawShowForPlayer(playeridTextdraw7); //show box
        
for(new 0MAX_PLAYERSi++)
        {
            
TextDrawShowForPlayer(playeridTextdraw8[playerid]); //show speed
        
}
    }
    else if(
oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER) {
        
TextDrawHideForPlayer(playerid,  Textdraw7); //show box
        
for(new 0MAX_PLAYERSi++)
        {
            
TextDrawHideForPlayer(playerid,  Textdraw8[playerid]); //show speed
        
}
    }

PHP код:
//after public OnGameModeInit()
SetTimer("speedoUpdate"10true); //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 
0MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
        {
            new 
string  32 ],
            
format(stringsizeof(string), "%d"GetPlayerSpeed(i0)); //set string for Texdraw8
            
TextDrawSetString(Texdraw8[i], string);
        }
    }
    return 
1;

PHP код:
stock GetPlayerSpeed(playeridget3d//get player speed
{
    new
        
Float:x,
        
Float:y,
        
Float:z;
    if(
IsPlayerInAnyVehicle(playerid))
        
GetVehicleVelocity(GetPlayerVehicleID(playerid), xyz);
    else
        
GetPlayerVelocity(playeridxyz);
    return 
SpeedCheck(xyz100.0get3d);

Reply


Messages In This Thread
help, speedometer function - by Coma - 20.05.2016, 23:32
Re: help, speedometer function - by WhiteGhost - 21.05.2016, 01:18
Re: help, speedometer function - by luke49 - 21.05.2016, 04:09
Re: help, speedometer function - by oMa37 - 21.05.2016, 07:06
Re: help, speedometer function - by CodeStyle175 - 21.05.2016, 07:30
Re: help, speedometer function - by luke49 - 21.05.2016, 07:50

Forum Jump:


Users browsing this thread: 2 Guest(s)