public OnPlayerStateChange(playerid, newstate, oldstate)
{
new string[128];
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
new newcar = GetPlayerVehicleID(playerid);
if(GetVehicleModel(newcar) != 509 && GetVehicleModel(newcar) != 481) // BMX & Bike
{
RadioChoose(playerid, Radio[newcar]);
}
return 1;
}
if(oldstate == PLAYER_STATE_DRIVER)
{
new model = GetVehicleModel(gLastCar[playerid]);
if(IsACopCar(gLastCar[playerid]) || model == 457)
{
SetPlayerWeapons(playerid);
}
}
/*if (newstate == 2)
{
if (oldstate == 1)
{
new
vID = GetPlayerVehicleID(playerid);
if (IsRentableCar(vID))
{
if (!IsRentedCar(vID))
{
new
String[128];
format(String, 128, "~p~~n~rent cost: ~b~%d~n~~w~type ~b~/rentcar~n~~w~to exit it type~n~~p~/exitrental", RENT_COST);
GameTextForPlayer(playerid, String, 30000, 4);
SendClientMessage(playerid, COLOR_YELLOW,"Type {3399CC}/rentcar{FFFFFF} to rent this car");
SendClientMessage(playerid, -1, "Type {3399CC}/exitrental{FFFFFF} to exit this rental car.");
TogglePlayerControllable(playerid, 0);
}
else if (IsRentedCar(vID))
{
if (GetPVarInt(playerid, "CarRentID") == vID)
{
return SendClientMessage(playerid, -1, "{3399CC}Welcome{FFFFFF} to your rented car.");
}
else if (GetPVarInt(playerid, "CarRentID") != vID)
{
new
String[128];
format(String, 128, "This vehicle is rented by: {3399CC}%s{FFFFFF}", RentedBy[vID]);
SendClientMessage(playerid, -1, String);
SendClientMessage(playerid, -1, "Use {3399CC}/exitrental{FFFFFF} to exit this vehicle.");
return 1;
}
}
}
}
}*/
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
new newcar = GetPlayerVehicleID(playerid);
new x = 0;
while(x != MAX_PLAYERS)
{
if(IsPlayerConnected(x) && GetPlayerState(x) == PLAYER_STATE_SPECTATING && SpectatedID[x] == playerid)
{
PlayerSpectateVehicle(x,newcar);
}
x++;
}
}
if(newstate == PLAYER_STATE_ONFOOT)
{
new x = 0;
RadioChoose(playerid, 255);
while(x != MAX_PLAYERS)
{
if(IsPlayerConnected(x) && GetPlayerState(x) == PLAYER_STATE_SPECTATING && SpectatedID[x] == playerid)
{
PlayerSpectatePlayer(x,playerid);
}
x++;
}
if(TransportDuty[playerid] > 0)
{
if(TransportDuty[playerid] == 1)
{
TaxiDrivers -= 1;
}
else if(TransportDuty[playerid] == 2)
{
BusDrivers -= 1;
}
TransportDuty[playerid] = 0;
format(string, sizeof(string), "* You are now Off Duty and earned $%d.", TransportMoney[playerid]);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]+TransportMoney[playerid];
GivePlayerMoney(playerid, TransportMoney[playerid]);
TransportValue[playerid] = 0; TransportMoney[playerid] = 0;
SetPlayerColor(playerid, TCOLOR_WHITE);
PlayerPlaySound(playerid,1055,0.0,0.0,0.0);
}
if(TransportCost[playerid] > 0 && TransportDriver[playerid] < 999)
{
if(IsPlayerConnected(TransportDriver[playerid]))
{
TransportMoney[TransportDriver[playerid]] += TransportCost[playerid];
TransportTime[TransportDriver[playerid]] = 0;
TransportCost[TransportDriver[playerid]] = 0;
format(string, sizeof(string), "~w~The ride cost~n~~r~$%d",TransportCost[playerid]);
GameTextForPlayer(playerid, string, 5000, 1);
format(string, sizeof(string), "~w~Passenger left the taxi~n~~g~Earned $%d",TransportCost[playerid]);
GameTextForPlayer(TransportDriver[playerid], string, 5000, 1);
PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]-TransportCost[playerid];
GivePlayerMoney(playerid, -TransportCost[playerid]);
TransportCost[playerid] = 0;
TransportTime[playerid] = 0;
TransportDriver[playerid] = 999;
PlayerPlaySound(playerid,1083,0.0,0.0,0.0);
}
}
new oldcar = gLastCar[playerid];
if(oldcar >= Trucks[0] && oldcar <= Trucks[10])
{
if(PlayerInfo[playerid][pJob] == 19)
{
if(CP[playerid] >= 1340 && CP[playerid] <= 1347)
{
DisablePlayerCheckpoint(playerid);
CP[playerid] = 0;
SendClientMessage(playerid, -1," To finish delivery, get back in the truck.");
}
}
}
}
if(newstate == PLAYER_STATE_PASSENGER) // TAXI & BUSSES
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
new vehicleid = GetPlayerVehicleID(playerid);
////foreach(Player, i)
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerInVehicle(i, vehicleid) && GetPlayerState(i) == 2 && TransportDuty[i] > 0)
{
if(PlayerInfo[playerid][pCash] < TransportValue[i])
{
format(string, sizeof(string), "* You need $%d to enter.", TransportValue[i]);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
RemovePlayerFromVehicle(playerid);
}
else
{
if(TransportDuty[i] == 1)
{
format(string, sizeof(string), "* You paid $%d to the Taxi Driver.", TransportValue[i]);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
if(PlayerInfo[i][pMask] == 1)
{
format(string, sizeof(string), "* Stranger has entered your taxi.");
}
else
{
format(string, sizeof(string), "* %s has entered your taxi.", name);
}
SendClientMessage(i, COLOR_LIGHTBLUE, string);
TransportTime[i] = 1;
TransportTime[playerid] = 1;
TransportCost[playerid] = TransportValue[i];
TransportCost[i] = TransportValue[i];
TransportDriver[playerid] = i;
}
else if(TransportDuty[i] == 2)
{
format(string, sizeof(string), "* You paid $%d to the Bus Driver.", TransportValue[i]);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
if(PlayerInfo[i][pMask] == 1)
{
format(string, sizeof(string), "* Stranger has entered your bus.");
}
else
{
format(string, sizeof(string), "* %s has entered your bus.", name);
}
SendClientMessage(i, COLOR_LIGHTBLUE, string);
}
PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]-TransportValue[i];
GivePlayerMoney(playerid, - TransportValue[i]);
TransportMoney[i] += TransportValue[i];
}
}
}
}
}
if(newstate == PLAYER_STATE_WASTED) //PLAYER DIES
{
if(PlayerInfo[playerid][pJailed] == 0)
{
PlayerInfo[playerid][pHospital] = 1;
}
}
if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
{
if(playing[playerid]) StopAudioStreamForPlayer(playerid);
}
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
{
new Float:V1X, Float:V1Y, Float:V1Z;
new newcar = GetPlayerVehicleID(playerid);
new Model = GetVehicleModel(newcar);
new oldcar = gLastCar[playerid];
if(IsABoat(newcar))
{
if(PlayerInfo[playerid][pBoatLic] < 1)
{
SendClientMessage(playerid, COLOR_GREY, " You don't know how to Sail yet, so you left the Boat !");
RemovePlayerFromVehicle(playerid);
}
}
else
{
if(PlayerInfo[playerid][pCarLic] < 1)
{
SendClientMessage(playerid, COLOR_GREY, " You don't know how to Drive yet, so you left the Car !");
RemovePlayerFromVehicle(playerid);
}
}
/*if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 525)
{
GameTextForPlayer(playerid, "~w~press ~r~~k~~TOGGLE_SUBMISSIONS~~w~ to tow a car.", 3000, 4);
}*/
if(GetPlayerVehicleID(playerid) >= Trucks[0] && GetPlayerVehicleID(playerid) <= Trucks[10])
{
SendClientMessage(playerid, -1, " Type /loadtruck to load the goods on your truck.");
}
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 519)
{
GameTextForPlayer(playerid, "~w~use ~r~(/int)ercom~w~ to speak with your passengers.", 3000, 4);
}
if(IsACopCar(newcar))
{
if(PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pLeader] == 1 ||PlayerInfo[playerid][pLeader] == 2 || PlayerInfo[playerid][pMember] == 2 || PlayerInfo[playerid][pMember] == 3 || PlayerInfo[playerid][pLeader] == 3)
{
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You don't have the keys for this vehicle [Hint : LSPD-SASD-FBI Vehicles]");
ClearAnimations(playerid);
}
}
if(IsANGCar(newcar))
{
if(IsANG(playerid)){}
else{ SendClientMessage(playerid, COLOR_GREY, "You don't have the Keys for this vehicle [Hint : DoC Members Vehicles]"); ClearAnimations(playerid); }
}
/*if(newcar >= thugCars[0] && newcar <= thugCars[2])
{
if(PlayerInfo[playerid][pFMember] != 1)
{
SendClientMessage(playerid,COLOR_GREY," You're not in 'Thugs of Smoke'!");
RemovePlayerFromVehicle(playerid);
}
}*/
else if(IsATaxiCar(newcar))
{
if(PlayerInfo[playerid][pMember] == 10 || PlayerInfo[playerid][pLeader] == 10 || PlayerInfo[playerid][pJob] == 14) { }
else { SendClientMessage(playerid,COLOR_GREY," You don't have the keys for this vehicle [Taxi Cab Company Vehicles]"); ClearAnimations(playerid); }
}
else if(IsABus(newcar))
{
if(PlayerInfo[playerid][pMember] == 10 || PlayerInfo[playerid][pLeader] == 10 || PlayerInfo[playerid][pJob] == 14) { }
else { SendClientMessage(playerid,COLOR_GREY," You don't have the keys for this vehicle [Bus Company Vehicles]"); ClearAnimations(playerid); }
}
else if(IsANewsCar(newcar))
{
if(PlayerInfo[playerid][pMember] == 9 || PlayerInfo[playerid][pLeader] == 9) { }
else { SendClientMessage(playerid,COLOR_GREY," You don't have the keys for this vehicle [SA-News Agency Vehicles]"); ClearAnimations(playerid); }
}
else if(IsAnAmbulance(newcar))
{
if(PlayerInfo[playerid][pMember] == 4 || PlayerInfo[playerid][pLeader] == 4) { }
else { SendClientMessage(playerid,COLOR_GREY," You don't have the keys for this vehicle [E.M.S Vehicles]!"); ClearAnimations(playerid); }
}
else if(newcar >= SSVehicles[0] && newcar <= SSVehicles[5])
{
if(!(PlayerInfo[playerid][pMember] == 7))
{
SendClientMessage(playerid,COLOR_GREY," You don't have the keys for this vehicle [Secret Service Vehicles]!");
ClearAnimations(playerid);
}
}
else if(newcar >= Trucks[0] && newcar <= Trucks[10])
{
if(PlayerInfo[playerid][pJob] == 19)
{
if(CP[playerid] == 0 && TruckGoods[newcar] == 0)
{
if(TruckGoods[newcar] == 1)
{
SetPlayerCheckpoint(playerid, 1499.6423,-1589.6134,13.3828, 3.0);
CP[playerid] = 1340;
}
if(TruckGoods[newcar] == 2)
{
SetPlayerCheckpoint(playerid, 1194.1232,-1323.2413,13.3984, 3.0);
CP[playerid] = 1341;
}
if(TruckGoods[newcar] == 3)
{
SetPlayerCheckpoint(playerid, 816.3569,-1391.6063,13.4065, 3.0);
CP[playerid] = 1342;
}
if(TruckGoods[newcar] == 4)
{
SetPlayerCheckpoint(playerid, 481.9336,-1499.8834,20.3204, 3.0);
CP[playerid] = 1343;
}
if(TruckGoods[newcar] == 5)
{
SetPlayerCheckpoint(playerid, 1360.2253,-1279.8677,13.3828, 3.0);
CP[playerid] = 1344;
}
if(TruckGoods[newcar] == 6)
{
SetPlayerCheckpoint(playerid, 1099.5890,-1210.1484,17.3746, 3.0);
CP[playerid] = 1345;
}
if(TruckGoods[newcar] == 7)
{
SetPlayerCheckpoint(playerid, 1361.7418,-1650.9559,13.3828, 3.0);
CP[playerid] = 1346;
}
if(TruckGoods[newcar] == 8)
{
SetPlayerCheckpoint(playerid, 1897.3386,-1866.8689,13.1412, 3.0);
CP[playerid] = 1347;
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD2, " This truck is loaded, but you already have an active checkpoint");
SendClientMessage(playerid, -1, " To finish this delivery, lose the old checkpoint first or destroy it(/destroycp)");
}
}
else
{
SendClientMessage(playerid,COLOR_GREY," You're not a trucker!");
RemovePlayerFromVehicle(playerid);
}
}
////////CARS
if(oldcar != PlayerVehicleID1[playerid])
{
UnLockCar(oldcar);
}
else if(oldcar != PlayerVehicleID2[playerid])
{
UnLockCar(oldcar);
}
else if(oldcar != PlayerVehicleID3[playerid])
{
UnLockCar(oldcar);
}
else if(oldcar != PlayerVehicleID4[playerid])
{
UnLockCar(oldcar);
}
else if(oldcar != PlayerVehicleID5[playerid])
{
UnLockCar(oldcar);
}
new Float:playerhp;
if(VehicleInfo[newcar][VehicleDealership] == 1)
{
if(newcar == PlayerVehicleID1[playerid] || newcar == PlayerVehicleID2[playerid] || newcar == PlayerVehicleID3[playerid] || newcar == PlayerVehicleID4[playerid] || newcar == PlayerVehicleID5[playerid])
{
format(string,sizeof(string)," You are the owner of this %s.",vehName[Model-400]);
SendClientMessage(playerid,COLOR_GREY,string);
return 1;
}
else
{
if(VehicleInfo[newcar][VehicleLock] == 2)
{
if(VehicleInfo[newcar][VehicleLocked] == 1)
{
GetVehiclePos(newcar,V1X,V1Y,V1Z);
SetPlayerPos(playerid, V1X,V1Y,V1Z+2);
GetPlayerHealth(playerid,playerhp);
SetPlayerHealth(playerid,playerhp-15.0);
GameTextForPlayer(playerid, "~r~STUNNED", 4000, 3);
}
else
{
format(string,sizeof(string)," Warning: This Vehicle Is Owned By: %s.",VehicleInfo[newcar][VehicleOwner]);
SendClientMessage(playerid,COLOR_GREY,string);
}
}
else
{
format(string,sizeof(string)," Warning: This Vehicle Is Owned By: %s.",VehicleInfo[newcar][VehicleOwner]);
SendClientMessage(playerid,COLOR_GREY,string);
}
}
}
for(new i = 0; i < sizeof(CarInfo); i++)
{
if(CarInfo[i][CarID] == newcar)
{
if(CarInfo[i][DealerShipCar] == 1)
{
new carstring[256];
format(carstring,sizeof(carstring),"Would you like to buy this %s ?\n This vehicles costs $%d",vehName[CarInfo[i][CarModel]-400],CarInfo[i][CarPrice]);
ShowPlayerDialog(playerid, 9001, DIALOG_STYLE_MSGBOX, "For Sale!", carstring, "Buy", "Cancel");
TempCarID[playerid] = i;
}
}
}
if(Model == 427 && !IsACop(playerid)) // enforcer armor exploit fix
{
SetPlayerArmour(playerid, StoreArmour[playerid]);
}
gLastCar[playerid] = newcar;
}
if(newstate == PLAYER_STATE_SPAWNED)
{
if(PlayerInfo[playerid][pWantedLevel] > 0)
{
new points = PlayerInfo[playerid][pWantedLevel];
new wlevel;
if(points == 1) { wlevel = 1; }
else if(points == 2) { wlevel = 2; }
else if(points == 3) { wlevel = 3; }
else if(points == 4) { wlevel = 4; }
else if(points == 5) { wlevel = 5; }
else if(points == 6) { wlevel = 6; SetPlayerColor(playerid, TCOLOR_WANTED); }
SetPlayerWantedLevel(playerid, wlevel);
}
}
return 1;
}
if(newstate == PLAYER_STATE_DRIVER)
Well... I've found that ALL the codes under OnPlayerStateChange doesn't work at all - Tried to find the problem but i failed :S
So.. Here it is.. pawn Код:
|
if(newstate == PLAYER_STATE_DRIVER)
{
SendClientMessage(playerid, -1, "You entered a vehicle.");
return 1;
}
if(newstate == PLAYER_STATE_WHATEVER)
{
// This will never be called because we returned 1 above. This stops the rest of the code from executing.
}