Speedo
#1

I get into my car, my speedo does not show up?

Код:
stock ShowSpeedo(playerid)
{
	PlayerTextDrawShow(playerid, SpeedoText0);
	PlayerTextDrawShow(playerid, SpeedoText1);
	PlayerTextDrawShow(playerid, SpeedoText2);
	PlayerTextDrawShow(playerid, SpeedoText3);
	PlayerTextDrawShow(playerid, SpeedoText4);
	PlayerTextDrawSetString(playerid,SpeedoText0,"~b~SPEED:~n~~w~0 MPH~n~~g~GAS: ~w~100.00");
	PlayerInfo[playerid][pSpeedoOn] =1;
}

stock HideSpeedo(playerid)
{
	PlayerTextDrawHide(playerid, SpeedoText0);
	PlayerTextDrawHide(playerid, SpeedoText1);
	PlayerTextDrawHide(playerid, SpeedoText2);
	PlayerTextDrawHide(playerid, SpeedoText3);
	PlayerTextDrawHide(playerid, SpeedoText4);
	PlayerInfo[playerid][pSpeedoOn] =0;
}
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
	{
		ShowSpeedo(playerid);
	}
	if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
	{
		HideSpeedo(playerid);
	}
	return 1;
}
Reply
#2

You should set the string before you show it:
pawn Код:
stock ShowSpeedo(playerid)
{
    PlayerTextDrawSetString(playerid,SpeedoText0,"~b~SPEED:~n~~w~0 MPH~n~~g~GAS: ~w~100.00");
    PlayerTextDrawShow(playerid, SpeedoText0);
    PlayerTextDrawShow(playerid, SpeedoText1);
    PlayerTextDrawShow(playerid, SpeedoText2);
    PlayerTextDrawShow(playerid, SpeedoText3);
    PlayerTextDrawShow(playerid, SpeedoText4);
    PlayerInfo[playerid][pSpeedoOn] =1;
}
Reply
#3

You shouldn't solely rely on the player changing from PLAYER_STATE_DRIVER to PLAYER_STATE_ONFOOT. For instance, what if someone dies while in a vehicle? Their new state certainly won't be onfoot but PLAYER_STATE_WASTED.

The simplest answer would be to when updating the textdraw, check if they are still driving a vehicle.
Reply
#4

Quote:
Originally Posted by Abagail
Посмотреть сообщение
You shouldn't solely rely on the player changing from PLAYER_STATE_DRIVER to PLAYER_STATE_ONFOOT. For instance, what if someone dies while in a vehicle? Their new state certainly won't be onfoot but PLAYER_STATE_WASTED.

The simplest answer would be to when updating the textdraw, check if they are still driving a vehicle.
Well, that's done when updating the speedometer's info, so there isn't really something to worry about.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)