vehicle fix
#1

hey guys i scripted this lil thingy . it compiles successfully but it doesn't work...how to fix that fucking bug ?
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	new playerState = GetPlayerState(playerid);
	if(playerState == PLAYER_STATE_DRIVER)
	{
		new Float: health;
		new veh;
		veh = GetPlayerVehicleID(playerid);
		if(GetVehicleHealth(veh,health) <100)
  		{
 			RepairVehicle(playerid);
  		}
	}
	return 1;
}
Reply
#2

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new Float: health;
        new veh;
        veh = GetPlayerVehicleID(playerid);
        if(GetVehicleHealth(veh,health) < 1000) //Max vehicle health is 1000 not 100.
        {
            RepairVehicle(playerid);
        }
    }
    return 1;
}
Reply
#3

whoops thx so much
Reply
#4

tried it but it didn't work either
Reply
#5

GetVehicleHealth does not return any values. The value is stored in 'health' variable. And RepairVehicle takes the car as parameter, not the player
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new playerState = GetPlayerState(playerid);
    if(playerState == PLAYER_STATE_DRIVER)
    {
        new Float: health;
        new veh;
        veh = GetPlayerVehicleID(playerid);
        GetVehicleHealth(veh,health);
        if(health < 1000)
        {
            RepairVehicle(veh);
        }
    }
    return 1;
}
Reply
#6

You don't need GetPlayerState(playerid), you can use newstate
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)