SA-MP Forums Archive
OnPlayerChangeState Problem [URGENT] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: OnPlayerChangeState Problem [URGENT] (/showthread.php?tid=139688)



OnPlayerChangeState Problem [URGENT] - Mobst3r111 - 05.04.2010

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


Re: OnPlayerChangeState Problem [URGENT] - Beaver07 - 05.04.2010

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


Re: OnPlayerChangeState Problem [URGENT] - Joe Staff - 05.04.2010

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);