Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(oldstate == PLAYER_STATE_DRIVER)
{
TextDrawHideForPlayer(playerid,speedo_txt[playerid]);
}
if(newstate == PLAYER_STATE_ONFOOT && oldstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_ONFOOT && oldstate == PLAYER_STATE_PASSENGER)
{
if(seatbelt[playerid]) { PutPlayerInVehicle(playerid,old_vehicle[playerid],old_veh_seat[playerid]); return 1; }
}
if(newstate == PLAYER_STATE_ONFOOT && oldstate == PLAYER_STATE_PASSENGER)
{
if(Audio_IsClientConnected(playerid))
{
Audio_SetVolume(playerid,radio_handle[playerid],0);
}
}
if(newstate == PLAYER_STATE_ONFOOT && oldstate == PLAYER_STATE_DRIVER)
{
if(derby_sys_driver[playerid]) { PutPlayerInVehicle(playerid,old_vehicle[playerid],0); SendClientMessage(playerid,COLOR_LIGHTRED,"You cannot exit the vehicle during a DERBY."); }
if(nascar_sys_driver[playerid]) { PutPlayerInVehicle(playerid,old_vehicle[playerid],0); SendClientMessage(playerid,COLOR_LIGHTRED,"You cannot exit the vehicle during a NASCAR race."); }
if(Audio_IsClientConnected(playerid))
{
Audio_SetVolume(playerid,radio_handle[playerid],0);
}
}
if(newstate == PLAYER_STATE_PASSENGER)
{
if(Audio_IsClientConnected(playerid))
{
Audio_SetVolume(playerid,radio_handle[playerid],vehicle_radio_volume[GetPlayerVehicleID(playerid)]);
}
if(InBus(playerid))
{
if(CharacterInfo[playerid][active_character[playerid]][cMoney] >= 10)
{
CharacterInfo[playerid][active_character[playerid]][cMoney] -= 10;
SendEmote(playerid,"pays the driver $10 to board the bus");
}
else
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid,COLOR_LIGHTRED,"You cannot afford to ride the bus.");
}
}
}
if(newstate == PLAYER_STATE_DRIVER)
{
if(IsPushbike(GetVehicleModel(GetPlayerVehicleID(playerid))) && !AccountInfo[playerid][aBikePerm])
{
SendClientMessage(playerid,COLOR_LIGHTRED,"You need permission from an administrator to use this type of vehicle.");
RemovePlayerFromVehicle(playerid);
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid,X,Y,Z);
SetPlayerPos(playerid,X,Y,(Z + 2.5));
} else if(IsPushbike(GetVehicleModel(GetPlayerVehicleID(playerid)))) { StartEngine(GetPlayerVehicleID(playerid)); }
player_vehicle_speed[playerid] = 0;
Audio_SetVolume(playerid,radio_handle[playerid],radio_volume[playerid]);
GetPlayerPos(playerid, SpeedPos[playerid][3], SpeedPos[playerid][4], SpeedPos[playerid][5]);
if(!IsPushbike(GetVehicleModel(GetPlayerVehicleID(playerid)))) { TextDrawShowForPlayer(playerid,speedo_txt[playerid]); }
if(InUtility(playerid))
{
if(CharacterInfo[playerid][active_character[playerid]][cJob] != JOB_ENG)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid,COLOR_LIGHTRED,"Only Engineers can drive this vehicle.");
}
else
{
SendClientMessage(playerid,COLOR_GREEN,"Use /startengineer to begin.");
}
}
if(InSweeper(playerid))
{
if(CharacterInfo[playerid][active_character[playerid]][cJob] != JOB_SWEEPER)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid,COLOR_LIGHTRED,"Only Street Cleaners can drive this vehicle.");
}
else
{
SendClientMessage(playerid,COLOR_GREEN,"Use /startsweep to begin a sweeping run.");
}
}
if(InPizzaBoy(playerid))
{
if(CharacterInfo[playerid][active_character[playerid]][cJob] != JOB_PIZZA)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid,COLOR_LIGHTRED,"Only Pizza Boys may drive this vehicle.");
}
else
{
SendClientMessage(playerid,COLOR_GREEN,"Use /startpizza to begin a pizza run. The faster you deliver the pizzas, the more money you will recieve.");
}
}
if(InTruck(playerid))
{
if(CharacterInfo[playerid][active_character[playerid]][cJob] != JOB_TRUCKER)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid,COLOR_LIGHTRED,"Only truckers may drive this vehicle.");
}
else
{
SendClientMessage(playerid,COLOR_GREEN,"Use /starttrucking to begin a trucking run. (You will be awarded more money for taking a trailer)");
}
}
if(InDeliveryVan(playerid))
{
if(CharacterInfo[playerid][active_character[playerid]][cJob] != JOB_DELIVER)
{
RemovePlayerFromVehicle(playerid);
SendClientMessageA(playerid,COLOR_LIGHTRED,"Only delivery men may drive this vehicle");
}
else
{
SendClientMessageA(playerid,COLOR_GREEN,"Use /startdelivery to begin a delivery chain");
}
}
if(InRentCar(playerid))
{
if(renting_car[playerid] != GetPlayerVehicleID(playerid))
{
TextDrawSetString(infotxt[playerid],"~p~Rentable Vehicle~n~ ~n~~w~~p~Price: ~w~$300~n~ ~n~use ~p~/rentcar~w~ to rent this vehicle.");
TextDrawShowForPlayer(playerid,infotxt[playerid]);
infotxt_expire[playerid] = 10;
}
}
if(InTaxi(playerid))
{
if(CharacterInfo[playerid][active_character[playerid]][cJob] != JOB_TAXI)
{
RemovePlayerFromVehicle(playerid);
SendClientMessageA(playerid,COLOR_LIGHTRED,"Only taxi drivers may drive this vehicle");
return 1;
}
else
{
SendClientMessageA(playerid,COLOR_GREEN,"Use /fare when someone is in your vehicle to begin charging the player fare.");
SendTaxiNotification(playerid);
}
}
if(InBus(playerid))
{
if(CharacterInfo[playerid][active_character[playerid]][cJob] != JOB_BUS)
{
RemovePlayerFromVehicle(playerid);
SendClientMessageA(playerid,COLOR_LIGHTRED,"Only bus drivers may drive this vehicle");
return 1;
}
else
{
SendClientMessageA(playerid,COLOR_GREEN,"Use /startroute to start a bus route.");
}
}
if(InGarbage(playerid))
{
if(CharacterInfo[playerid][active_character[playerid]][cJob] != JOB_GARBAGE)
{
RemovePlayerFromVehicle(playerid);
SendClientMessageA(playerid,COLOR_LIGHTRED,"Only garbage men may drive this vehicle");
return 1;
}
else
{
if(garbage_run[playerid] == -1)
{
SendClientMessageA(playerid,COLOR_GREEN,"Use /startrun to start a garbage run.");
}
}
}
if(InFish(playerid))
{
if(CharacterInfo[playerid][active_character[playerid]][cJob] != JOB_FISH)
{
RemovePlayerFromVehicle(playerid);
SendClientMessageA(playerid,COLOR_LIGHTRED,"Only fisher men may drive this vehicle");
return 1;
}
else
{
if(fish_run[playerid] == -1)
{
SendClientMessageA(playerid,COLOR_GREEN,"Use /startfish to start a fishing run.");
}
}
}
}
return 1;
}