OnPlayerChangeState Problem [URGENT]
#1

public OnPlayerStateChange(playerid,newstate,oldstate)
{
new string[128];
new vehicleid = GetPlayerVehicleID(playerid);
new Float:Vehhealth,vhealth;

if(newstate == PLAYER_STATE_DRIVER)
{
vhealth = GetVehicleHealth(vehicleid,Float:Vehhealth);
format(string,sizeof(string),"Vehicle Name:%s VehicleID:%d VehicleHealth:%d",aVehicleNames[vehicleid - 400],vehicleid,vhealth);
SendClientMessage(playerid,ANNOUNCE,string);
SendClientMessage(playerid,ANNOUNCE,"You can eject any player from your vehicle by using /eject");
pvehicleid[playerid] = GetPlayerVehicleID(playerid);
pmodelid[playerid] = GetVehicleModel(GetPlayerVehicleID(playerid));
}
}

the message doesnt show when i enter a car as a driver or at all for that matter
Reply
#2

Quote:
Originally Posted by Mobst3r111
public OnPlayerStateChange(playerid,newstate,oldstate)
{
new string[128];
new vehicleid = GetPlayerVehicleID(playerid);
new Float:Vehhealth,vhealth;

if(newstate == PLAYER_STATE_DRIVER)
{
vhealth = GetVehicleHealth(vehicleid,Float:Vehhealth);
format(string,sizeof(string),"Vehicle Name:%s VehicleID:%d VehicleHealth:%d",aVehicleNames[vehicleid - 400],vehicleid,vhealth);
SendClientMessage(playerid,ANNOUNCE,string);
SendClientMessage(playerid,ANNOUNCE,"You can eject any player from your vehicle by using /eject");
pvehicleid[playerid] = GetPlayerVehicleID(playerid);
pmodelid[playerid] = GetVehicleModel(GetPlayerVehicleID(playerid));
}
}

the message doesnt show when i enter a car as a driver or at all for that matter
Code:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
	new string[128];
	new vehicleid = GetPlayerVehicleID(playerid);
    new Float:Vehhealth
  
	if(newstate == PLAYER_STATE_DRIVER)
	{
		GetVehicleHealth(vehicleid,Vehhealth);
		format(string,sizeof(string),"Vehicle Name:%s VehicleID:%d VehicleHealth:%d",aVehicleNames[vehicleid - 400],vehicleid,Vehhealth);
		SendClientMessage(playerid,ANNOUNCE,string);
		SendClientMessage(playerid,ANNOUNCE,"You can eject any player from your vehicle by using /eject");
		pvehicleid[playerid] = vehicleid;
		pmodelid[playerid] = GetVehicleModel(vehicleid);
        return 1;
	}
     return 1;
}
to be honest i can't see much wrong with it i removed the vhealth because that was just pointless and just returned the public
Reply
#3

It will stop at this line:
pawn Code:
format(string,sizeof(string),"Vehicle Name:%s VehicleID:%d VehicleHealth:%d",aVehicleNames[vehicleid - 400],vehicleid,vhealth);
because you're trying to get the vehicle model's name from the vehicle id. It should be:
pawn Code:
format(string,sizeof(string),"Vehicle Name:%s VehicleID:%d VehicleHealth:%d",aVehicleNames[GetVehicleModel(vehicleid)-400],vehicleid,vhealth);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)