PHP код:
//============================Tolls============================//
// Main configuration
#define TollCost (50) // How much it costs to pass the tolls
#define TollDelayCop (4) // The timespace in seconds between each /toll command for all cops (To avoid spam)
#define TollOpenDistance (8.0) // The distance in units the player can be from the icon to open the toll
// Other defines
#define MAX_TOLLS (5) // Amount of tolls
#define INVALID_TOLL_ID (-1)
#define RichmanToll (0)
#define FlintToll (1)
#define LVToll (2)
#define BlueberryTollR (3)
#define BlueberryTollL (4)
#define L_sz_TollStringLocked ("Toll guard says: I'm sorry, but I can't open this right now. You'll have to come back later.")
#define L_sz_TollStringNoMoney ("You don't have enough money to pay the guard.")
#define L_sz_TollStringBye ("Toll guard says: Thank you, drive safe.")
#define L_sz_TollStringHurryUp ("You have 6 seconds to get past the barrier, make sure you don't get stuck!")
//============================Tolls============================//
//Tolls
new LaRequestAllowedCop; // The same timer for all /toll changes
new LaTollObject[MAX_TOLLS*2]; // 0 & 1 = Richhman, 2 & 3 = Flint, 4 & 5 = LV, 6 & 7 = BlueBerry right
AddTolls(); // At GameModeInit
forward TollUpdate();
public TollUpdate() // Needs to be called in the OnPlayerUpdate function
{
for(new i = 0; i < MAX_TOLLS; i++)
{
if(aTolls[i][E_tOpenTime] > 0)
{
aTolls[i][E_tOpenTime];
if(aTolls[i][E_tOpenTime] == 1)
{
Toll_CloseToll(i);
}
}
}
}
//Tolls
TollUpdate(); // OnPlayerUpdate
//Tolls
forward AddTolls();
public AddTolls() // Needs to be called in the OnGameModeInit function!
{
// Thanks to Nexus for the following mapping!
/* Richman */
CreateDynamicObject( 8168, 612.73895263672, -1191.4602050781, 20.294105529785, 0.000000, 5, 318.31237792969, -1 );
CreateDynamicObject( 8168, 620.47265625, -1188.49609375, 20.044105529785, 0.000000, 352.99621582031, 138.94409179688, -1 );
CreateDynamicObject( 966, 613.97229003906, -1197.7174072266, 17.475030899048, 0.000000, 0.000000, 23.81982421875, -1 );
CreateDynamicObject( 997, 614.33209228516, -1194.3870849609, 17.709369659424, 0.000000, 0.000000, 266.70568847656, -1 );
CreateDynamicObject( 973, 602.98425292969, -1202.1643066406, 18.000516891479, 0.000000, 0.000000, 19.849853515625, -1 );
LaTollObject[0] = CreateDynamicObject( 968, 613.8935546875, -1197.7329101563, 18.109180450439, 0.000000, -90.000000, 23.81982421875, -1 );
CreateDynamicObject( 966, 619.42913818359, -1181.6597900391, 18.725030899048, 0.000000, 0.000000, 214.37744140625, -1 );
CreateDynamicObject( 973, 629.68823242188, -1176.0551757813, 19.500516891479, 0.000000, 0.000000, 21.831787109375, -1 );
CreateDynamicObject( 997, 619.26574707031, -1181.6518554688, 18.709369659424, 0.000000, 0.000000, 268.68908691406, -1 );
LaTollObject[1] = CreateDynamicObject( 968, 619.44201660156, -1181.6903076172, 19.525806427002, 0.000000, -90.000000, 214.37744140625, -1 );
/* End of Richman */
/* Flint */
CreateDynamicObject( 8168, 61.256042480469, -1533.3946533203, 6.1042537689209, 0.000000, 0.000000, 9.9252624511719, -1 );
CreateDynamicObject( 8168, 40.966598510742, -1529.5725097656, 6.1042537689209, 0.000000, 0.000000, 188.5712890625, -1 );
LaTollObject[2] = CreateDynamicObject( 968, 35.838928222656, -1525.9034423828, 5.0012145042419, 0.000000, -90.000000, 270.67565917969, -1 );
CreateDynamicObject( 966, 35.889751434326, -1526.0096435547, 4.2410612106323, 0.000000, 0.000000, 270.67565917969, -1 );
CreateDynamicObject( 966, 67.093727111816, -1536.8275146484, 3.9910612106323, 0.000000, 0.000000, 87.337799072266, -1 );
LaTollObject[3] = CreateDynamicObject( 968, 67.116600036621, -1536.8218994141, 4.7504549026489, 0.000000, -90.000000, 87.337799072266, -1 );
CreateDynamicObject( 973, 52.9794921875, -1531.9252929688, 5.090488910675, 0.000000, 0.000000, 352.06005859375, -1 );
CreateDynamicObject( 973, 49.042072296143, -1531.5065917969, 5.1758694648743, 0.000000, 0.000000, 352.05688476563, -1 );
CreateDynamicObject( 997, 68.289916992188, -1546.6020507813, 4.0626411437988, 0.000000, 0.000000, 119.09942626953, -1 );
CreateDynamicObject( 997, 34.5198097229, -1516.1402587891, 4.0626411437988, 0.000000, 0.000000, 292.50622558594, -1 );
CreateDynamicObject( 997, 35.903915405273, -1525.8717041016, 4.0626411437988, 0.000000, 0.000000, 342.13012695313, -1 );
CreateDynamicObject( 997, 63.914081573486, -1535.7126464844, 4.0626411437988, 0.000000, 0.000000, 342.130859375, -1 );
/* End of Flint */
/* LV */
CreateDynamicObject( 8168, 1789.83203125, 703.189453125, 15.846367835999, 0.000000, 3, 99.24951171875, -1 );
CreateDynamicObject( 8168, 1784.8334960938, 703.94799804688, 16.070636749268, 0.000000, 357, 278.61096191406, -1 );
CreateDynamicObject( 966, 1781.4122314453, 697.32531738281, 14.636913299561, 0.000000, 0.000000, 348.09008789063, -1 );
CreateDynamicObject( 996, 1767.3087158203, 700.50506591797, 15.281567573547, 0.000000, 0.000000, 346.10510253906, -1 );
CreateDynamicObject( 997, 1781.6832275391, 697.34796142578, 14.698781013489, 0.000000, 3, 77.41455078125, -1 );
CreateDynamicObject( 997, 1792.7745361328, 706.38543701172, 13.948781013489, 0.000000, 2.999267578125, 81.379638671875, -1 );
CreateDynamicObject( 966, 1793.4289550781, 709.87982177734, 13.636913299561, 0.000000, 0.000000, 169.43664550781, -1 );
CreateDynamicObject( 996, 1800.8060302734, 708.38299560547, 14.281567573547, 0.000000, 0.000000, 346.10229492188, -1 );
LaTollObject[4] = CreateDynamicObject( 968, 1781.4133300781, 697.31750488281, 15.420023918152, 0.000000, -90.000000, 348.10229492188, -1 );
LaTollObject[5] = CreateDynamicObject( 968, 1793.6700439453, 709.84631347656, 14.405718803406, 0.000000, -90.000000, 169.43664550781, -1 );
/* End of LV */
/* Blueberry right */
CreateDynamicObject(966, 614.42188, 350.81711, 17.92480, 0.00000, 0.00000, 35.00000);
CreateDynamicObject(966, 602.91162, 342.59781, 17.92480, 0.00000, 0.00000, 215.92000);
LaTollObject[6] = CreateDynamicObject(968, 614.42188, 350.81711, 18.66520, 0.00000, -90.00000, 35.00000);
LaTollObject[7] = CreateDynamicObject(968, 602.91162, 342.59781, 18.66520, 0.00000, -90.00000, 215.92000);
/* Blueberry right */
/* Blueberry left */
CreateDynamicObject(966, -190.35580, 254.64290, 11.07090, 0.00000, 0.00000, 345.00000);
CreateDynamicObject(966, -204.00880, 258.30411, 11.07090, 0.00000, 0.00000, -195.00000);
LaTollObject[8] = CreateDynamicObject(968, -190.24850, 254.62019, 11.89360, 0.00000, -90.00000, -14.94000);
LaTollObject[9] = CreateDynamicObject(968, -204.10410, 258.34149, 11.89360, 0.00000, -90.00000, -195.00000);
/* Blueberry right */
}
Toll_CloseToll(TollID)
{
if(TollID == RichmanToll)
{
SetDynamicObjectRot(LaTollObject[0], 0.000000, -90.000000, 23.81982421875);
SetDynamicObjectRot(L_a_TollObject[1], 0.000000, -90.000000, 214.37744140625);
}
else if(TollID == FlintToll)
{
SetDynamicObjectRot(LaTollObject[2], 0.000000, -90.000000, 270.67565917969);
SetDynamicObjectRot(LaTollObject[3], 0.000000, -90.000000, 87.337799072266);
}
else if(TollID == LVToll)
{
SetDynamicObjectRot(LaTollObject[4], 0.000000, -90.000000, 348.10229492188);
SetDynamicObjectRot(LaTollObject[5], 0.000000, -90.000000, 169.43664550781);
}
else if(TollID == BlueberryTollR)
{
SetDynamicObjectRot(LaTollObject[6], 0.00000, -90.00000, 35.00000);
SetDynamicObjectRot(LaTollObject[7], 0.00000, -90.00000, 215.92000);
}
else if(TollID == BlueberryTollL)
{
SetDynamicObjectRot(LaTollObject[8], 0.00000, -90.00000, -14.94000);
SetDynamicObjectRot(LaTollObject[9], 0.00000, -90.00000, -195.00000);
}
return 1;
}
Toll_OpenToll(TollID)
{
if(TollID == RichmanToll)
{
aTolls[RichmanToll][E_tOpenTime] = 7;
SetDynamicObjectRot(L_a_TollObject[0], 0.000000, 0.000000, 23.81982421875);
SetDynamicObjectRot(L_a_TollObject[1], 0.000000, 0.000000, 214.37744140625);
}
else if(TollID == FlintToll)
{
aTolls[FlintToll][E_tOpenTime] = 7;
SetDynamicObjectRot(L_a_TollObject[2], 0.000000, 0.000000, 270.67565917969);
SetDynamicObjectRot(L_a_TollObject[3], 0.000000, 0.000000, 87.337799072266);
}
else if(TollID == LVToll)
{
aTolls[LVToll][E_tOpenTime] = 7;
SetDynamicObjectRot(L_a_TollObject[4], 0.000000, 0.000000, 348.10229492188);
SetDynamicObjectRot(L_a_TollObject[5], 0.000000, 0.000000, 169.43664550781);
}
else if(TollID == BlueberryTollR)
{
aTolls[BlueberryTollR][E_tOpenTime] = 7;
SetDynamicObjectRot(L_a_TollObject[6], 0.000000, 0.000000, 35.00000);
SetDynamicObjectRot(L_a_TollObject[7], 0.000000, 0.000000, 215.92000);
}
else if(TollID == BlueberryTollL)
{
aTolls[BlueberryTollL][E_tOpenTime] = 7;
SetDynamicObjectRot(L_a_TollObject[8], 0.000000, 0.000000, -14.94000);
SetDynamicObjectRot(L_a_TollObject[9], 0.000000, 0.000000, -195.00000);
}
}
Toll_TimePassedCivil(TollID, playerid) // People have to wait <TollDelayCivilian> seconds between every /opentoll on the same toll
{
if(aTolls[TollID][E_tOpenTime] > 0)
{
SCM(playerid, COLOR_LIGHTRED, "The barrier is already open, wait for it to close before you pay.");
return 0;
}
return 1;
}
Toll_TimePassedCops(playerid) // Cops have to wait for <TollDelayCop> seconds between every /toll (Global)
{
new L_i_tick = GetUnixTime();
if(L_a_RequestAllowedCop > L_i_tick && L_a_RequestAllowedCop != 0)
{
new TollString[63];
format(TollString, 63, "You need to wait at least %d seconds between each toll change.", TollDelayCop);
SCM(playerid, COLOR_LIGHTRED, TollString);
return 0;
}
L_a_RequestAllowedCop = (L_i_tick + TollDelayCop);
return 1;
}
CMD:toll(playerid, params[])
{
new string[128];
if(PlayerInfo[playerid][pMember] == 1 && PlayerInfo[playerid][pRank] < 3 && PlayerInfo[playerid][pDispatch] == 1) return SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use this command!");
new employer[16], rank[64], division[16];
switch (PlayerInfo[playerid][pMember]) // employer/rank/division data is pulled from here
{
case 1:
{
employer = "LSPD";
switch(PlayerInfo[playerid][pRank])
{
case 1: rank = "Officer (I)";
case 2: rank = "Officer (II)";
case 3: rank = "Sergeant";
case 4: rank = "Lieutenant";
case 5: rank = "Captain";
case 6: rank = "Commander";
case 7: rank = "Deputy Chief";
case 8: rank = "Chief";
default: rank = "Cadet";
}
switch(PlayerInfo[playerid][pDivision])
{
case 1: division = "Patrol";
case 2: division = "CIB";
case 3: division = "FTO";
case 4: division = "SPEC";
case 5: division = "SWAT";
case 6: division = "TRAFFIC";
default: division = "General Duties";
}
}
case 6:
{
employer = "LS County";
if(PlayerInfo[playerid][pDivision] == 1 || PlayerInfo[playerid][pDivision] == 0)
{
switch(PlayerInfo[playerid][pRank])
{
case 1: rank = "Representative";
case 2: rank = "Council Member";
case 3: rank = "Council Chairman";
case 4: rank = "Senate";
case 5: rank = "Deputy Mayor";
case 6: rank = "Mayor";
default: rank = "Intern";
}
}
else if(PlayerInfo[playerid][pDivision] == 2)
{
switch(PlayerInfo[playerid][pRank])
{
case 1: rank = "Senior Driver";
case 2: rank = "Agent";
case 3: rank = "Senior Agent";
case 4: rank = "Shift Agent";
case 5: rank = "Executive Agent";
case 6: rank = "Head Agent";
default: rank = "Driver";
}
}
else if(PlayerInfo[playerid][pDivision] == 3)
{
switch(PlayerInfo[playerid][pRank])
{
case 1: rank = "Intern";
case 2: rank = "Forklift Operator";
case 3: rank = "Weapons Specialist";
case 4: rank = "Senior Specialist";
case 5: rank = "Supervisor of Production";
case 6: rank = "Chairman of Production";
default: rank = "Intern";
}
}
switch(PlayerInfo[playerid][pDivision])
{
case 1: division = "";
case 2: division = "SS";
case 3: division = "MANU";
default: division = "";
}
}
case 7:
{
employer = "SASD";
switch(PlayerInfo[playerid][pRank])
{
case 1: rank = "Deputy";
case 2: rank = "Deputy (II)";
case 3: rank = "Sergeant";
case 4: rank = "Lieutenant";
case 5: rank = "Captain";
case 6: rank = "Commander";
case 7: rank = "Undersheriff";
case 8: rank = "Sheriff";
default: rank = "Cadet";
}
switch(PlayerInfo[playerid][pDivision])
{
case 1: division = "(Patrol) ";
case 2: division = "(CIB) ";
case 3: division = "(Traffic) ";
case 4: division = "(Tactical) ";
case 5: division = "(HVE) ";
default: division = "";
}
}
default:
{
SendClientMessageEx(playerid,COLOR_GRAD2,"You're not in a faction.");
return 1;
}
}
new option[11];
if(sscanf(params,"s[11]",option))
{
SendClientMessage(playerid, COLOR_YELLOW, "Toll barrier command central for Los Santos");
SendClientMessage(playerid, COLOR_GRAD2, "emergency/release - (Un)Locks all the barriers.");
SendClientMessage(playerid, COLOR_GRAD2, "flint - (Un)locks flint tolls.");
SendClientMessage(playerid, COLOR_GRAD2, "richman - (Un)locks Richman tunnel tolls.");
SendClientMessage(playerid, COLOR_GRAD2, "lv - (Un)locks the Las Venturas Highway tolls.");
SendClientMessage(playerid, COLOR_GRAD2, "blueberryr - (Un)locks the BlueBerry Right tolls.");
SendClientMessage(playerid, COLOR_GRAD2, "blueberryl - (Un)locks the BlueBerry Left tolls.");
return 1;
}
if(!Toll_TimePassedCops(playerid))
return 1;
if(CompareStrings(option, "emergency"))
{
aTolls[FlintToll][E_tLocked] = 1;
aTolls[RichmanToll][E_tLocked] = 1;
aTolls[LVToll][E_tLocked] = 1;
aTolls[BlueberryTollR][E_tLocked] = 1;
aTolls[BlueberryTollL][E_tLocked] = 1;
Toll_CloseToll(FlintToll);
Toll_CloseToll(RichmanToll);
Toll_CloseToll(LVToll);
Toll_CloseToll(BlueberryTollR);
Toll_CloseToll(BlueberryTollL);
format(string, sizeof(string), "** HQ Announcement: All toll booths were LOCKED by %s %s of the %s ! **", rank, GetPlayerNameEx(playerid),employer);
SendRadioMessage(1, COLOR_LIGHTRED, string);
}
if(CompareStrings(option, "release"))
{
aTolls[FlintToll][E_tLocked] = 0;
aTolls[RichmanToll][E_tLocked] = 0;
aTolls[LVToll][E_tLocked] = 0;
aTolls[BlueberryTollR][E_tLocked] = 0;
aTolls[BlueberryTollL][E_tLocked] = 0;
format(string, sizeof(string), "** HQ Announcement: All toll booths were UNLOCKED by %s %s of the %s ! **", rank, GetPlayerNameEx(playerid),employer);
SendRadioMessage(1, COLOR_LIGHTRED, string);
}
if(CompareStrings(option, "flint"))
{
if(aTolls[FlintToll][E_tLocked] == 0)
{
aTolls[FlintToll][E_tLocked] = 1;
Toll_CloseToll(FlintToll);
format(string, sizeof(string), "** HQ Announcement: Toll booths at Flint County were LOCKED by %s %s of the %s . **", rank, GetPlayerNameEx(playerid),employer);
SendRadioMessage(1, COLOR_LIGHTRED, string);
}
else
{
aTolls[FlintToll][E_tLocked] = 0;
format(string, sizeof(string), "** HQ Announcement: Toll booths at Flint County were UNLOCKED by %s %s of the %s . **", rank, GetPlayerNameEx(playerid),employer);
SendRadioMessage(1, COLOR_LIGHTRED, string);
}
}
if(CompareStrings(option, "richman"))
{
if(aTolls[RichmanToll][E_tLocked] == 0)
{
aTolls[RichmanToll][E_tLocked] = 1;
Toll_CloseToll(RichmanToll);
format(string, sizeof(string), "** HQ Announcement: Toll booths at Richman were LOCKED by %s %s of the %s . **", rank, GetPlayerNameEx(playerid),employer);
SendRadioMessage(1, COLOR_LIGHTRED, string);
}
else
{
aTolls[RichmanToll][E_tLocked] = 0;
format(string, sizeof(string), "** HQ Announcement: Toll booths at Richman were UNLOCKED by %s %s of the %s . **", rank, GetPlayerNameEx(playerid),employer);
SendRadioMessage(1, COLOR_LIGHTRED, string);
}
}
if(CompareStrings(option, "lv"))
{
if(aTolls[LVToll][E_tLocked] == 0)
{
aTolls[LVToll][E_tLocked] = 1;
Toll_CloseToll(LVToll);
format(string, sizeof(string), "** HQ Announcement: Toll booths at Las Venturas were LOCKED by %s %s of the %s . **", rank, GetPlayerNameEx(playerid),employer);
SendRadioMessage(1, COLOR_LIGHTRED, string);
}
else
{
aTolls[LVToll][E_tLocked] = 0;
format(string, sizeof(string), "** HQ Announcement: Toll booths at Las Venturas were UNLOCKED by %s %s of the %s . **", rank, GetPlayerNameEx(playerid),employer);
SendRadioMessage(1, COLOR_LIGHTRED, string);
}
}
if(CompareStrings(option, "blueberryr"))
{
if(aTolls[BlueberryTollR][E_tLocked] == 0)
{
aTolls[BlueberryTollR][E_tLocked] = 1;
Toll_CloseToll(BlueberryTollR);
format(string, sizeof(string), "** HQ Announcement: Toll booths at Blue Berry Right were LOCKED by %s %s of the %s . **", rank, GetPlayerNameEx(playerid),employer);
SendRadioMessage(1, COLOR_LIGHTRED, string);
}
else
{
aTolls[BlueberryTollR][E_tLocked] = 0;
format(string, sizeof(string), "** HQ Announcement: Toll booths at Blue Berry Right were UNLOCKED by %s %s of the %s . **", rank, GetPlayerNameEx(playerid),employer);
SendRadioMessage(1, COLOR_LIGHTRED, string);
}
}
if(CompareStrings(option, "blueberryl"))
{
if(aTolls[BlueberryTollL][E_tLocked] == 0)
{
aTolls[BlueberryTollL][E_tLocked] = 1;
Toll_CloseToll(BlueberryTollL);
format(string, sizeof(string), "** HQ Announcement: Toll booths at Blue Berry Left were LOCKED by %s %s of the %s . **", rank, GetPlayerNameEx(playerid),employer);
SendRadioMessage(1, COLOR_LIGHTRED, string);
}
else
{
aTolls[BlueberryTollL][E_tLocked] = 0;
format(string, sizeof(string), "** HQ Announcement: Toll booths at Blue Berry Left were UNLOCKED by %s %s of the %s . **", rank, GetPlayerNameEx(playerid),employer);
SendRadioMessage(1, COLOR_LIGHTRED, string);
}
}
return 1;
}
CMD:opentoll(playerid, params[])
{
new L_i_TollID;
if(IsPlayerInRangeOfPoint(playerid, TollOpenDistance, 623.9500, -1183.9774, 19.2260) || IsPlayerInRangeOfPoint(playerid, 10.0, 607.9684, -1194.2866, 19.0043)) // Richman tolls
{
L_i_TollID = RichmanToll;
}
else if(IsPlayerInRangeOfPoint(playerid, TollOpenDistance, 39.7039, -1522.9891, 5.1995) || IsPlayerInRangeOfPoint(playerid, 10.0, 62.7378, -1539.9891, 5.0639)) // Flint tolls
{
L_i_TollID = FlintToll;
}
else if(IsPlayerInRangeOfPoint(playerid, TollOpenDistance, 1795.9447, 704.2550, 15.0006) || IsPlayerInRangeOfPoint(playerid, 10.0, 1778.9886, 702.6728, 15.2574)) // LV tolls
{
L_i_TollID = LVToll;
}
else if(IsPlayerInRangeOfPoint(playerid, TollOpenDistance, 612.53070, 346.59592, 17.92614) || IsPlayerInRangeOfPoint(playerid, 10.0, 604.37152, 346.88141, 17.92614)) // LV tolls
{
L_i_TollID = BlueberryTollR;
}
else if(IsPlayerInRangeOfPoint(playerid, TollOpenDistance, -195.2768,252.2416,12.0781) || IsPlayerInRangeOfPoint(playerid, 10.0, -199.5153,260.3405,12.0781)) // LV tolls
{
L_i_TollID = BlueberryTollL;
}
else
{
SendClientMessage(playerid, COLOR_LIGHTRED, "You are not close enough to a toll booth.");
return 1;
}
if(!Toll_TimePassedCivil(L_i_TollID, playerid))
return 1;
new string[128];
if(!CopDuty{playerid})
{
if(aTolls[L_i_TollID][E_tLocked]) // If it's locked
{
ProxDetectorP(20.0, playerid, L_sz_TollStringLocked, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);
return 1;
}
if(GetCash(playerid) < TollCost)
{
SendClientMessage(playerid, COLOR_RED, L_sz_TollStringNoMoney);
return 1;
}
format(string, sizeof(string), "%s paid %d$ to the toll guard.", GetPlayerNameEx(playerid), TollCost);
GiveCash(playerid, -TollCost);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
ProxDetectorP(20.0, playerid, L_sz_TollStringBye, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);
SendClientMessage(playerid, COLOR_LIGHTRED, L_sz_TollStringHurryUp);
Toll_OpenToll(L_i_TollID);
return 1;
}