OnPlayerEnterVehicle
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(gTeam[playerid] >= 3)
{
if (IsACopCar(vehicleid) && !ispassenger)
{
if(PlayerInfo[playerid][pLeader]==1||PlayerInfo[playerid][pLeader]==2||PlayerInfo[playerid][pLeader]==3) {}
else { WantedPoints[playerid]+=2; SetPlayerCriminal(playerid,255, "Kradja policijskog vozila"); }
}
if (IsAnAmbulance(vehicleid) && !ispassenger)
{
if(PlayerInfo[playerid][pMember]==4||PlayerInfo[playerid][pLeader]==4) { }
else { WantedPoints[playerid]+=2; SetPlayerCriminal(playerid,255, "Kradja vozila hitne pomoci"); }
}
}
return 1;
}
public IsAnInstructor(playerid)
{
if(IsPlayerConnected(playerid))
{
new leader = PlayerInfo[playerid][pLeader];
new member = PlayerInfo[playerid][pMember];
if(member==11)
{
return 1;
}
if(leader==11)
{
return 1;
}
}
return 0;
}
public IsAMember(playerid)
{
if(IsPlayerConnected(playerid))
{
new leader = PlayerInfo[playerid][pLeader];
new member = PlayerInfo[playerid][pMember];
if(member==5 || member==6 || member==8)
{
return 1;
}
if(leader==5 || leader==6 || leader==8)
{
return 1;
}
}
return 0;
}
public IsACop(playerid)
{
if(IsPlayerConnected(playerid))
{
new leader = PlayerInfo[playerid][pLeader];
new member = PlayerInfo[playerid][pMember];
if(member==1 || member==2 || member==3)
{
return 1;
}
else if(leader==1 || leader==2 || leader==3)
{
return 1;
}
}
return 0;
}
public IsAtClothShop(playerid)
{
if(IsPlayerConnected(playerid))
{
if(PlayerToPoint(25.0,playerid,207.5627,-103.7291,1005.2578) || PlayerToPoint(25.0,playerid,203.9068,-41.0728,1001.8047))
{//Binco & Suburban
return 1;
}
else if(PlayerToPoint(30.0,playerid,214.4470,-7.6471,1001.2109) || PlayerToPoint(50.0,playerid,161.3765,-83.8416,1001.8047))
{//Zip & Victim
return 1;
}
}
return 0;
}
public IsAtGasStation(playerid)
{
if(IsPlayerConnected(playerid))
{
if(PlayerToPoint(6.0,playerid,1004.0070,-939.3102,42.1797) || PlayerToPoint(6.0,playerid,1944.3260,-1772.9254,13.3906))
{//LS
return 1;
}
else if(PlayerToPoint(6.0,playerid,-90.5515,-1169.4578,2.4079) || PlayerToPoint(6.0,playerid,-1609.7958,-2718.2048,48.5391))
{//LS
return 1;
}
else if(PlayerToPoint(6.0,playerid,-2029.4968,156.4366,28.9498) || PlayerToPoint(8.0,playerid,-2408.7590,976.0934,45.4175))
{//SF
return 1;
}
else if(PlayerToPoint(5.0,playerid,-2243.9629,-2560.6477,31.8841) || PlayerToPoint(8.0,playerid,-1676.6323,414.0262,6.9484))
{//Between LS and SF
return 1;
}
else if(PlayerToPoint(6.0,playerid,2202.2349,2474.3494,10.5258) || PlayerToPoint(10.0,playerid,614.9333,1689.7418,6.6968))
{//LV
return 1;
}
else if(PlayerToPoint(8.0,playerid,-1328.8250,2677.2173,49.7665) || PlayerToPoint(6.0,playerid,70.3882,1218.6783,18.5165))
{//LV
return 1;
}
else if(PlayerToPoint(8.0,playerid,2113.7390,920.1079,10.5255) || PlayerToPoint(6.0,playerid,-1327.7218,2678.8723,50.0625))
{//LV
return 1;
}
}
return 0;
}
public IsAtFishPlace(playerid)
{
if(IsPlayerConnected(playerid))
{
if(PlayerToPoint(1.0,playerid,403.8266,-2088.7598,7.8359) || PlayerToPoint(1.0,playerid,398.7553,-2088.7490,7.8359))
{//Fishplace at the bigwheel
return 1;
}
else if(PlayerToPoint(1.0,playerid,396.2197,-2088.6692,7.8359) || PlayerToPoint(1.0,playerid,391.1094,-2088.7976,7.8359))
{//Fishplace at the bigwheel
return 1;
}
else if(PlayerToPoint(1.0,playerid,383.4157,-2088.7849,7.8359) || PlayerToPoint(1.0,playerid,374.9598,-2088.7979,7.8359))
{//Fishplace at the bigwheel
return 1;
}
else if(PlayerToPoint(1.0,playerid,369.8107,-2088.7927,7.8359) || PlayerToPoint(1.0,playerid,367.3637,-2088.7925,7.8359))
{//Fishplace at the bigwheel
return 1;
}
else if(PlayerToPoint(1.0,playerid,362.2244,-2088.7981,7.8359) || PlayerToPoint(1.0,playerid,354.5382,-2088.7979,7.8359))
{//Fishplace at the bigwheel
return 1;
}
}
return 0;
}
public IsAtCookPlace(playerid)
{
if(IsPlayerConnected(playerid))
{
if(PlayerToPoint(3.0,playerid,369.9786,-4.0798,1001.8589))
{//Cluckin Bell
return 1;
}
else if(PlayerToPoint(3.0,playerid,376.4466,-60.9574,1001.5078) || PlayerToPoint(3.0,playerid,378.1215,-57.4928,1001.5078))
{//Burgershot
return 1;
}
else if(PlayerToPoint(3.0,playerid,374.1185,-113.6361,1001.4922) || PlayerToPoint(3.0,playerid,377.7971,-113.7668,1001.4922))
{//Well Stacked Pizza
return 1;
}
}
return 0;
}
public IsAtBar(playerid)
{
if(IsPlayerConnected(playerid))
{
if(PlayerToPoint(4.0,playerid,495.7801,-76.0305,998.7578) || PlayerToPoint(4.0,playerid,499.9654,-20.2515,1000.6797))
{//In grove street bar (with girlfriend), and in Havanna
return 1;
}
else if(PlayerToPoint(4.0,playerid,1215.9480,-13.3519,1000.9219) || PlayerToPoint(10.0,playerid,-2658.9749,1407.4136,906.2734))
{//PIG Pen
return 1;
}
}
return 0;
}
public IsABoat(carid)
{
if(carid >= 86 && carid <=90)
{
return 1;
}
return 0;
}
public IsAPlane(carid)
{
if(carid==39||carid==40||carid==60||carid==83||carid==91||carid==92||carid==93||carid==95||carid==96||carid==99||carid==100||carid==101||carid==102||carid==103||carid==104||carid==105||carid==106||carid==107||carid==108||carid==109)
{
return 1;
}
return 0;
}
public IsACopCar(carid)
{
if((carid >= 35) && (carid <= 60) || carid == 66 || carid == 67 || carid == 91 || carid == 92 || carid == 93 || carid == 36)
{
if(carid == 45 || carid == 46 || carid == 55 || carid == 59) { return 0; }
return 1;
}
return 0;
}
public IsAnAmbulance(carid)
{
if((carid >= 61) && (carid <= 63)|| carid == 83)
{
return 1;
}
return 0;
}
public IsATruck(carid)
{
if(carid >= 78 && carid <= 81)
{
return 1;
}
return 0;
}
OnPlayerStateChange
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
new string[256];
if(newstate == PLAYER_STATE_ONFOOT)
{
if(PlayerKarting[playerid] > 0 && PlayerInKart[playerid] > 0)
{
PlayerInKart[playerid] = 0;
KartingPlayers --;
}
if(TransportDuty[playerid] > 0)
{
if(TransportDuty[playerid] == 1)
{
TaxiDrivers -= 1;
}
else if(TransportDuty[playerid] == 2)
{
BusDrivers -= 1;
}
TransportDuty[playerid] = 0;
format(string, sizeof(string), "* Vise niste na poslu i zaradili ste $%d.", TransportMoney[playerid]);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
GivePlayerMoney(playerid, TransportMoney[playerid]);
ConsumingMoney[playerid] = 1; TransportValue[playerid] = 0; TransportMoney[playerid] = 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~Voznja kosta~n~~r~$%d",TransportCost[playerid]);
GameTextForPlayer(playerid, string, 5000, 1);
format(string, sizeof(string), "~w~Putnik je napustio taksi~n~~g~Zarada $%d",TransportCost[playerid]);
GameTextForPlayer(TransportDriver[playerid], string, 5000, 1);
GivePlayerMoney(playerid, -TransportCost[playerid]);
TransportCost[playerid] = 0;
TransportTime[playerid] = 0;
TransportDriver[playerid] = 999;
}
}
TelePos[playerid][0] = 0.0;
TelePos[playerid][1] = 0.0;
}
if(newstate == PLAYER_STATE_PASSENGER) // TAXI & BUSSES
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
new vehicleid = GetPlayerVehicleID(playerid);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerInVehicle(i, vehicleid) && GetPlayerState(i) == 2 && TransportDuty[i] > 0)
{
if(GetPlayerMoney(playerid) < TransportValue[i])
{
format(string, sizeof(string), "* POtrebno vam je $%d da udjete.", TransportValue[i]);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
RemovePlayerFromVehicle(playerid);
}
else
{
if(TransportDuty[i] == 1)
{
format(string, sizeof(string), "* Platili ste $%d Taksisti.", TransportValue[i]);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "* Putnik %s Je usao u vas 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), "* Platili ste $%d Vozacu autobusa.", TransportValue[i]);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "* Putnik %s je usao u vas autobus.", name);
SendClientMessage(i, COLOR_LIGHTBLUE, string);
}
GivePlayerMoney(playerid, - TransportValue[i]);
TransportMoney[i] += TransportValue[i];
}
}
}
}
}
if(newstate == PLAYER_STATE_WASTED)
{
if(WantedLevel[playerid] >= 1)
{
new price = WantedLevel[playerid] * 4000;
new count;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(gTeam[i] == 2 && CrimInRange(30.0, playerid,i))
{
count = 1;
format(string, sizeof(string), "~w~Osumnjiceni~r~ubijen~n~Bonus~g~$%d", price);
GameTextForPlayer(i, string, 5000, 1);
ConsumingMoney[i] = 1;
GivePlayerMoney(i, price / 2);
PlayerPlaySound(i, 1058, 0.0, 0.0, 0.0);
}
}
}
if(count == 1)
{
GivePlayerMoney(playerid, - price);
PlayerInfo[playerid][pWantedDeaths] += 1;
PlayerInfo[playerid][pJailed] = 1;
PlayerInfo[playerid][pJailTime] = (WantedLevel[playerid])*(600);
format(string, sizeof(string), "* U zatvoru ste na %d sekundi i izgubili ste $%d zato sto ste bezali od policije.", PlayerInfo[playerid][pJailTime], price);
SendClientMessage(playerid, COLOR_LIGHTRED, string);
WantedPoints[playerid] = 0;
WantedLevel[playerid] = 0;
}
}
}
if(newstate == PLAYER_STATE_DRIVER) //buggy dont finnish
{// 38 / 49 / 56 = SS
new newcar = GetPlayerVehicleID(playerid);
new oldcar = gLastCar[playerid];
new housecar = PlayerInfo[playerid][pPhousekey]+1;
TelePos[playerid][0] = 0.0;
TelePos[playerid][1] = 0.0;
if(IsABoat(newcar))
{
if(PlayerInfo[playerid][pBoatLic] < 1)
{
SendClientMessage(playerid, COLOR_GREY, " Ne znate jos kako da plovite, napustite brod !");
RemovePlayerFromVehicle(playerid);
}
}
else if(IsAPlane(newcar))
{
if(PlayerInfo[playerid][pFlyLic] < 1)
{
if(TakingLesson[playerid] == 1) { }
else {
SendClientMessage(playerid, COLOR_GREY, " Ne znate jos kako da letite, napustite avion !");
RemovePlayerFromVehicle(playerid); }
}
}
else
{
if(PlayerInfo[playerid][pCarLic] < 1)
{
if(PlayerDrunk[playerid] >= 5)
{
WantedPoints[playerid] += 1;
SetPlayerCriminal(playerid,255, "Drunk Driving");
}
if(TakingLesson[playerid] == 1) { }
else {
SendClientMessage(playerid, COLOR_GREY, " Ne znate jos kako da vozite, napustite auto !");
RemovePlayerFromVehicle(playerid); }
}
else if(PlayerDrunk[playerid] >= 5)
{
WantedPoints[playerid] += 1;
SetPlayerCriminal(playerid,255, "Drunk Driving");
}
}//Done with car check
if(IsACopCar(newcar))
{
if(IsACop(playerid)) { }
else { RemovePlayerFromVehicle(playerid); }
}
else if(IsAnAmbulance(newcar))
{
if(PlayerInfo[playerid][pMember] == 4||PlayerInfo[playerid][pLeader] == 4) { }
else { RemovePlayerFromVehicle(playerid); }
}
if(IsATruck(newcar))
{
format(string, sizeof(string), "Produkti: %d/%d", PlayerHaul[newcar][pLoad],PlayerHaul[newcar][pCapasity]);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
SendClientMessage(playerid, COLOR_WHITE, "INFO: Mozete isporucivati produkte biznisima.");
SendClientMessage(playerid, COLOR_WHITE, "INFO: Komande su /load /buyprods /sellprods");
}
if(PlayerKarting[playerid] != 0)
{
new kart = GetPlayerVehicleID(playerid);
if(kart==110||kart==111||kart==112||kart==113||kart==114||kart==115)
{
PlayerInKart[playerid] = 1;
KartingPlayers ++;
}
}
if(newcar == 39 || newcar == 40)
{
if(PlayerInfo[playerid][pMember] == 3 || PlayerInfo[playerid][pLeader] == 3)//national guard
{
if(PlayerInfo[playerid][pRank] < 3)
{
SendClientMessage(playerid,COLOR_GREY," Potreban vam je rank 3 da biste leteli !");
RemovePlayerFromVehicle(playerid);
}
}
else
{
RemovePlayerFromVehicle(playerid);
}
}
if(newcar == 55 || newcar == 59)
{
if(PlayerInfo[playerid][pMember] != 4)
{
SendClientMessage(playerid,COLOR_GREY," Niste vatrogasac !");
RemovePlayerFromVehicle(playerid);
}
}
if(newcar == 64 || newcar == 65)
{
if(PlayerInfo[playerid][pJob] != 14)
{
SendClientMessage(playerid,COLOR_GREY," Niste vozac autobusa !");
RemovePlayerFromVehicle(playerid);
}
}
if(newcar == 69 || newcar == 70 || newcar == 71 || newcar == 99 || newcar == 100 || newcar == 101)
{
if(TakingLesson[playerid] == 1) { }
else if(!IsAnInstructor(playerid))
{
SendClientMessage(playerid,COLOR_GREY," Niste instruktor voznje !");
RemovePlayerFromVehicle(playerid);
}
}
if(newcar == 82 || newcar == 84 || newcar == 85 || newcar == 94)
{
if(PlayerInfo[playerid][pMember] == 10||PlayerInfo[playerid][pLeader] == 10) { }
else
{
SendClientMessage(playerid,COLOR_GREY," Niste taksista !");
RemovePlayerFromVehicle(playerid);
}
}
if(newcar == 95)
{
if(PlayerInfo[playerid][pMember] == 8 || PlayerInfo[playerid][pLeader] == 8)
{
if(PlayerInfo[playerid][pRank] < 3)
{
SendClientMessage(playerid, COLOR_GREY, " Vas rank je premali !");
RemovePlayerFromVehicle(playerid);
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " Niste Hitman !");
RemovePlayerFromVehicle(playerid);
}
}
if(newcar == 96 || newcar == 97 || newcar == 98)
{
if(PlayerInfo[playerid][pMember] == 9 || PlayerInfo[playerid][pLeader] == 9){ }
else
{
SendClientMessage(playerid, COLOR_GREY, " Niste novinar !");
RemovePlayerFromVehicle(playerid);
}
if(PlayerInfo[playerid][pNewsSkill] < 200 && newcar == 96)
{
SendClientMessage(playerid, COLOR_GREY, " Vas skil reportera je premali da biste leteli !");
RemovePlayerFromVehicle(playerid);
}
}
if(newcar==110||newcar==111||newcar==112||newcar==113||newcar==114||newcar==115)
{
if(PlayerKarting[playerid] != 1)
{
RemovePlayerFromVehicle(playerid);
}
}
if(newcar >= 72 && newcar <= 74)
{
if (HireCar[playerid] != newcar)
{
format(string, sizeof(string), "~w~Mozete iznajmiti ovaj auto~n~Cena:~g~$%d~n~~w~da biste iznajmili auto kucajte ~g~/rentcar~w~~n~da biste izasli iz auta kucajte ~r~/exit",SBizzInfo[0][sbEntranceCost]);
TogglePlayerControllable(playerid, 0);
GameTextForPlayer(playerid, string, 5000, 3);
}
}
if(newcar >= 75 && newcar <= 77)
{
if (HireCar[playerid] != newcar)
{
format(string, sizeof(string), "~w~Mozete iznajmiti ovaj auto~n~Cena:~g~$%d~n~~w~da biste iznajmili auto kucajte ~g~/rentcar~w~~n~da biste izasli iz auta kucajte ~r~/exit",SBizzInfo[1][sbEntranceCost]);
TogglePlayerControllable(playerid, 0);
GameTextForPlayer(playerid, string, 5000, 3);
}
}
if(oldcar != 301)
{
if((housecar != oldcar && oldcar != 0) && (HireCar[playerid] != oldcar && newcar != housecar))
{
if(gLastDriver[oldcar] == playerid && oldcar != newcar)
{
gLastDriver[oldcar] = 300;
gCarLock[oldcar] = 0;
UnLockCar(oldcar);
}
}
}
gLastCar[playerid] = newcar;
gLastDriver[newcar] = playerid;
}
if(newstate == PLAYER_STATE_SPAWNED)
{
new Float: lwx, Float:lwy, Float:lwz;
GetPlayerPos(playerid, lwx, lwy, lwz);
if((lwz > 530.0 && PlayerInfo[playerid][pInt] == 0) || PlayerToPoint(1000.0, playerid, -1041.9,-1868.4,79.1)) //the highest land point in sa = 526.8
{
SetPlayerSpawn(playerid);
}
if(WantedPoints[playerid] > 0)
{
new dstring[128];
new wanted = WantedPoints[playerid];
new diecash = 0;
while(WantedPoints[playerid] > 0)
{
diecash += 500;
WantedPoints[playerid] --;
}
format(dstring, sizeof(dstring), "Izgubili ste $%d jer ste poginuli sa %d Wanted Poena.", diecash, wanted);
SendClientMessage(playerid, COLOR_YELLOW, dstring);
GivePlayerMoney(playerid, - diecash);
PlayerInfo[playerid][pWantedDeaths] += 1;
}
if(PlayerOnMission[playerid] > 0)
{
GameTextForPlayer(playerid, "~r~Mission failed", 5000, 3);
PlayerOnMission[playerid] = 0;
PlayerInfo[playerid][pMissionNr] = 0;
}
WantedPoints[playerid] = 0;
WantedLevel[playerid] = 0;
if(PlayerInfo[playerid][pDonateRank] > 0) { SetPlayerHealth(playerid, 100.0); }
else { SetPlayerHealth(playerid, 50.0+PlayerInfo[playerid][pSHealth]); }
MedicBill[playerid] = 1;
TelePos[playerid][0] = 0.0;
TelePos[playerid][1] = 0.0;
gPlayerSpawned[playerid] = 1;
SafeTime[playerid] = 60;
}
return 1;
}