public OnPlayerStateChange(playerid, newstate, oldstate)
{
new string[128];
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
//new newcar = GetPlayerVehicleID(playerid);
ShowSpeed[playerid] = 1;
/*if(GetVehicleModel(newcar) != 509 && GetVehicleModel(newcar) != 481) // BMX & Bike
{
RadioChoose(playerid, Radio[newcar]);
}*/
}
/*if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
new vehicleid = GetPlayerVehicleID(playerid),
playingid = v_VehicleInfo[vehicleid][RadioPlaying];
#if USE_TEXTDRAW_SET == 2
new string[50];
format(string,sizeof(string),"Listening to: ~n~~w~%s",r_RadioInfo[playingid][r_Name]);
TextDrawSetString(v_VehicleInfo[vehicleid][r_Draw],string);
#else
TextDrawSetString(v_VehicleInfo[vehicleid][r_Draw],r_RadioInfo[playingid][r_Name]);
#endif
TextDrawShowForPlayer(playerid,v_VehicleInfo[vehicleid][r_Draw]);
SetPVarInt(playerid,"ID_HideRadioTextdraw",SetTime rEx("HideRadioTextdraw",TEXTDRAW_DISAPPEAR_TIME,fa lse,"ii",playerid,vehicleid));
PlayAudioStreamForPlayer(playerid,r_RadioInfo[playingid][r_Link]);
SetPVarInt(playerid,"ID_OldVehicle",vehicleid);
return 1;
}
if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
{
new vehicleid = GetPVarInt(playerid,"ID_OldVehicle"),
timer = GetPVarInt(playerid,"ID_HideRadioTextdraw");
if(timer != -1)
{
TextDrawHideForPlayer(playerid,v_VehicleInfo[vehicleid][r_Draw]);
KillTimer(timer);
}
StopAudioStreamForPlayer(playerid);
}*/
/*if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
new gastext[41];
new vid = GetPlayerVehicleID(playerid);
format(gastext, sizeof(gastext), "Vehicle Fuel : %d", Gas[vid]);
TextDrawSetString(GasAmount, gastext);
TextDrawShowForPlayer(playerid, GasAmount);
}
if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
{
TextDrawHideForPlayer(playerid, GasAmount);
}*/
if(newstate == PLAYER_STATE_DRIVER)
{
if(GetPVarInt(playerid,"used") == 0)
{
new p = GetPlayerVehicleID(playerid);
pObj[playerid] = CreatePlayerObject(playerid,19300, 0.0000, -1282.9984, 10.1493, 0.0000, -1, -1, 100);
AttachPlayerObjectToVehicle(playerid,pObj[playerid],p,-0.314999, -0.195000, 0.510000, 0.000000, 0.000000, 0.000000);
AttachCameraToPlayerObject(playerid,pObj[playerid]);
SetPVarInt(playerid,"used",1);
}
}
else if(GetPVarInt(playerid,"used") == 1)
{
SetCameraBehindPlayer(playerid);
DestroyPlayerObject(playerid,pObj[playerid]);
SetPVarInt(playerid,"used",0);
}
if(newstate == PLAYER_STATE_ONFOOT)
{
if(GetPVarInt(playerid,"used") == 1)
{
SetPVarInt(playerid,"used",0);
SetCameraBehindPlayer(playerid);
DestroyPlayerObject(playerid,pObj[playerid]);
}
}
if (newstate == PLAYER_STATE_DRIVER)
{
if (GetPVarInt(playerid, "StartMoving") && GetVehicleModel(GetPlayerVehicleID(playerid)) != 414)
{
SendClientMessage(playerid, LIGHTRED, "* You have failed the moving job because you've left your truck.");
DeletePVar(playerid, "StartMoving");
DeletePVar(playerid, "MovingCash");
DisablePlayerCheckpoint(playerid);
CP[playerid] = 0;
}
}
if(newstate == PLAYER_STATE_PASSENGER)
{
if(GetPlayerVehicleID(playerid) == NPCBlueBus)
{
SetPlayerVirtualWorld(playerid, 2);
SetPlayerPos(playerid, 2021.9740,2235.6626,2103.9536);
SetPlayerFacingAngle(playerid, 355.3504);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 1);
BusID[playerid] = 1;
GameTextForPlayer(playerid, "~w~Bus A-1", 3000, 1);
costtimer = SetTimerEx("CostTimer", 30000, 1, "d", playerid);
SendClientMessage(playerid, -1,"You have entered the bus - Please take a seat");
BusCost[playerid] += 2;
}
|