Advertisement
DarkSkull

EVO V1.0

Aug 23rd, 2016
1,064
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 60.23 KB | None | 0 0
  1. /*  Elite Vehicle Ownership
  2.  *
  3.  *  (c) Copyright 2016, DarkSkull
  4.  *  Script Version: 1.0
  5.  *
  6.  *
  7.  *  Credits(DO NOT REMOVE THIS):
  8.  *  Y_Less for y_ini
  9.  *  Y_Less for sscanf2
  10.  *  Zeex for ZCMD
  11.  *  Konstantinos, Misiur, AndySedeyn & ThePhenix for helping me fix bugs.
  12.  *  DarkSkull for this script
  13.  *
  14.  *  You may use this script for your own use.
  15.  *  You're not allowed re-distrbute or re-release this script without proper permissions.
  16.  *
  17.  */
  18.  
  19. #define FILTERSCRIPT
  20.  
  21. #include <a_samp>
  22. #include <crashdetect>
  23. #include <YSI\y_ini>
  24. #include <ZCMD>
  25. #include <sscanf2>
  26.  
  27. #if !defined strcpy
  28.     #define strcpy(%0,%1,%2) strcat((%0[0] = '\0', %0), %1, %2)
  29. #endif
  30.  
  31. // -------------------------------------------------------------------------
  32. //                              COLORS
  33. // -------------------------------------------------------------------------
  34.  
  35. #define COLOR_RED 0xFF0000FF
  36. #define COLOR_YELLOW 0xFFFF00AA
  37. #define COLOR_ORANGE 0xFFA500FF
  38. #define COLOR_LAWNGREEN 0x7CFC00FF
  39. #define COLOR_DODGERBLUE 0x1E90FFFF
  40.  
  41. // -------------------------------------------------------------------------
  42.  
  43. // -------------------------------------------------------------------------
  44. //                              SETTINGS
  45. // -------------------------------------------------------------------------
  46.  
  47. #define USERS_PATH "/EVO/users/%s.ini"
  48. #define VEHICLES_PATH "/EVO/vehicles/%d.ini"
  49. #define MAX_OWNABLE_VEHICLES 5
  50. #define DEFAULT_OWNER "Server"
  51. #define DEFAULT_PLATE "ABC123"
  52. #define DEFAULT_PRICE 50000
  53. #define RESPAWN_TIME 5
  54. #define TELEPORT_TIME 3
  55.  
  56.  // -------------------------------------------------------------------------
  57.  
  58. #define DIALOG_VLIST 733
  59. #define DIALOG_VINFO 734
  60. #define DIALOG_VHELP 735
  61.  
  62.  
  63. // -------------------------------------------------------------------------
  64.  
  65. // -------------------------------------------------------------------------
  66. //                                   ENUMS
  67. // -------------------------------------------------------------------------
  68. enum vInfo {
  69.     vID,
  70.     vModel,
  71.     Float:xSpawn,
  72.     Float:ySpawn,
  73.     Float:zSpawn,
  74.     Float:angleSpawn,
  75.     vCol1,
  76.     vCol2,
  77.     vPaintjob,
  78.     vMod[17],
  79.     vPlate[10],
  80.     vRespawn,
  81.     vOwner[MAX_PLAYER_NAME],
  82.     vPrice,
  83.     bool:Secure,
  84.     bool:isOwned,
  85.     bool:vBuyable,
  86.     bool:vTemp,
  87.     bool:vIsSelling,
  88.     vSellingPrice
  89. }
  90.  
  91. enum pInfo {
  92.     bool:pAllowed,
  93.     pTotalVehs,
  94.     pVSlot[MAX_OWNABLE_VEHICLES],
  95.     sTo,
  96.     sFrom,
  97.     svID
  98. }
  99. // -------------------------------------------------------------------------
  100. new SellingTimer[MAX_PLAYERS];
  101. new VehicleInfo[MAX_VEHICLES][vInfo];
  102. new bool:vCreated[MAX_VEHICLES] = {false, ...};
  103. new PlayerInfo[MAX_PLAYERS][pInfo];
  104. new teleport_time  = TELEPORT_TIME;
  105.  
  106. new spoiler[20][0] = {
  107.     {1000},
  108.     {1001},
  109.     {1002},
  110.     {1003},
  111.     {1014},
  112.     {1015},
  113.     {1016},
  114.     {1023},
  115.     {1058},
  116.     {1060},
  117.     {1049},
  118.     {1050},
  119.     {1138},
  120.     {1139},
  121.     {1146},
  122.     {1147},
  123.     {1158},
  124.     {1162},
  125.     {1163},
  126.     {1164}
  127. };
  128.  
  129. new nitro[3][0] = {
  130.     {1008},
  131.     {1009},
  132.     {1010}
  133. };
  134.  
  135. new fbumper[23][0] = {
  136.     {1117},
  137.     {1152},
  138.     {1153},
  139.     {1155},
  140.     {1157},
  141.     {1160},
  142.     {1165},
  143.     {1166},
  144.     {1169},
  145.     {1170},
  146.     {1171},
  147.     {1172},
  148.     {1173},
  149.     {1174},
  150.     {1175},
  151.     {1179},
  152.     {1181},
  153.     {1182},
  154.     {1185},
  155.     {1188},
  156.     {1189},
  157.     {1192},
  158.     {1193}
  159. };
  160.  
  161. new rbumper[22][0] = {
  162.     {1140},
  163.     {1141},
  164.     {1148},
  165.     {1149},
  166.     {1150},
  167.     {1151},
  168.     {1154},
  169.     {1156},
  170.     {1159},
  171.     {1161},
  172.     {1167},
  173.     {1168},
  174.     {1176},
  175.     {1177},
  176.     {1178},
  177.     {1180},
  178.     {1183},
  179.     {1184},
  180.     {1186},
  181.     {1187},
  182.     {1190},
  183.     {1191}
  184. };
  185.  
  186. new exhaust[28][0] = {
  187.     {1018},
  188.     {1019},
  189.     {1020},
  190.     {1021},
  191.     {1022},
  192.     {1028},
  193.     {1029},
  194.     {1037},
  195.     {1043},
  196.     {1044},
  197.     {1045},
  198.     {1046},
  199.     {1059},
  200.     {1064},
  201.     {1065},
  202.     {1066},
  203.     {1089},
  204.     {1092},
  205.     {1104},
  206.     {1105},
  207.     {1113},
  208.     {1114},
  209.     {1126},
  210.     {1127},
  211.     {1129},
  212.     {1132},
  213.     {1135},
  214.     {1136}
  215. };
  216.  
  217. new bventr[2][0] = {
  218.     {1142},
  219.     {1144}
  220. };
  221.  
  222. new bventl[2][0] = {
  223.     {1143},
  224.     {1145}
  225. };
  226.  
  227. new bscoop[4][0] = {
  228.     {1004},
  229.     {1005},
  230.     {1011},
  231.     {1012}
  232. };
  233.  
  234. new rscoop[17][0] = {
  235.     {1006},
  236.     {1032},
  237.     {1033},
  238.     {1035},
  239.     {1038},
  240.     {1053},
  241.     {1054},
  242.     {1055},
  243.     {1061},
  244.     {1067},
  245.     {1068},
  246.     {1088},
  247.     {1091},
  248.     {1103},
  249.     {1128},
  250.     {1130},
  251.     {1131}
  252. };
  253.  
  254. new lskirt[21][0] = {
  255.     {1007},
  256.     {1026},
  257.     {1031},
  258.     {1036},
  259.     {1039},
  260.     {1042},
  261.     {1047},
  262.     {1048},
  263.     {1056},
  264.     {1057},
  265.     {1069},
  266.     {1070},
  267.     {1090},
  268.     {1093},
  269.     {1106},
  270.     {1108},
  271.     {1118},
  272.     {1119},
  273.     {1133},
  274.     {1122},
  275.     {1134}
  276. };
  277.  
  278. new rskirt[21][0] = {
  279.     {1017},
  280.     {1027},
  281.     {1030},
  282.     {1040},
  283.     {1041},
  284.     {1051},
  285.     {1052},
  286.     {1062},
  287.     {1063},
  288.     {1071},
  289.     {1072},
  290.     {1094},
  291.     {1095},
  292.     {1099},
  293.     {1101},
  294.     {1102},
  295.     {1107},
  296.     {1120},
  297.     {1121},
  298.     {1124},
  299.     {1137}
  300. };
  301.  
  302. new hydraulics[1][0] = {
  303.     {1087}
  304. };
  305.  
  306. new cbase[1][0] = {
  307.     {1086}
  308. };
  309.  
  310. new rbbars[4][0] = {
  311.     {1109},
  312.     {1110},
  313.     {1123},
  314.     {1125}
  315. };
  316.  
  317. new fbbars[2][0] = {
  318.     {1115},
  319.     {1116}
  320. };
  321.  
  322. new wheels[17][0] = {
  323.     {1025},
  324.     {1073},
  325.     {1074},
  326.     {1075},
  327.     {1076},
  328.     {1077},
  329.     {1078},
  330.     {1079},
  331.     {1080},
  332.     {1081},
  333.     {1082},
  334.     {1083},
  335.     {1084},
  336.     {1085},
  337.     {1096},
  338.     {1097},
  339.     {1098}
  340. };
  341.  
  342. new lights[2][0] = {
  343.     {1013},
  344.     {1024}
  345. };
  346.  
  347. new Messages1[][] =
  348. {
  349.        "Please drive carefully.",
  350.        "Enjoy your ride.",
  351.        "Have fun.",
  352.        "Have a good day."
  353. };
  354.  
  355. new TotalVehicles;
  356.  
  357. forward public TuneVeh(vehicleid);
  358. forward public PlateSet(vehicleid);
  359. forward public LoadVehicleData(vehicleID, name[], value[]);
  360. forward LoadUser_data(playerid, name[], value[]);
  361. forward public PlayerToggle(playerid);
  362. forward public RespawnVehicle(vehicleid);
  363. forward public TeleportVehicleInfront(playerid, vehicleid);
  364. forward SaveComponent(vehicleid, componentid);
  365. forward public KillSale(playerid, targetid);
  366.  
  367.  
  368. // -------------------------------------------------------------------------
  369. //                              FUNCTIONS
  370. //--------------------------------------------------------------------------
  371. new VehicleNames[][] =
  372. {
  373.     "Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial", "Sentinel",
  374.     "Dumper", "Firetruck", "Trashmaster", "Stretch", "Manana", "Infernus",
  375.     "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam",
  376.     "Esperanto", "Taxi", "Washington", "Bobcat", "Whoopee", "BF Injection",
  377.     "Hunter", "Premier", "Enforcer", "Securicar", "Banshee", "Predator", "Bus",
  378.     "Rhino", "Barracks", "Hotknife", "Trailer", "Previon", "Coach", "Cabbie",
  379.     "Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster", "Admiral",
  380.     "Squalo", "Seasparrow", "Pizzaboy", "Tram", "Trailer", "Turismo", "Speeder",
  381.     "Reefer", "Tropic", "Flatbed", "Yankee", "Caddy", "Solair", "Berkley's RC Van",
  382.     "Skimmer", "PCJ-600", "Faggio", "Freeway", "RC Baron", "RC Raider", "Glendale",
  383.     "Oceanic","Sanchez", "Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy",
  384.     "Hermes", "Sabre", "Rustler", "ZR-350", "Walton", "Regina", "Comet", "BMX",
  385.     "Burrito", "Camper", "Marquis", "Baggage", "Dozer", "Maverick", "News Chopper",
  386.     "Rancher", "FBI Rancher", "Virgo", "Greenwood", "Jetmax", "Hotring", "Sandking",
  387.     "Blista Compact", "Police Maverick", "Boxville", "Benson", "Mesa", "RC Goblin",
  388.     "Hotring Racer A", "Hotring Racer B", "Bloodring Banger", "Rancher", "Super GT",
  389.     "Elegant", "Journey", "Bike", "Mountain Bike", "Beagle", "Cropduster", "Stunt",
  390.     "Tanker", "Roadtrain", "Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra",
  391.     "FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck", "Fortune",
  392.     "Cadrona", "FBI Truck", "Willard", "Forklift", "Tractor", "Combine", "Feltzer",
  393.     "Remington", "Slamvan", "Blade", "Freight", "Streak", "Vortex", "Vincent",
  394.     "Bullet", "Clover", "Sadler", "Firetruck", "Hustler", "Intruder", "Primo",
  395.     "Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite",
  396.     "Windsor", "Monster", "Monster", "Uranus", "Jester", "Sultan", "Stratium",
  397.     "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna", "Bandito",
  398.     "Freight Flat", "Streak Carriage", "Kart", "Mower", "Dune", "Sweeper",
  399.     "Broadway", "Tornado", "AT-400", "DFT-30", "Huntley", "Stafford", "BF-400",
  400.     "News Van", "Tug", "Trailer", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club",
  401.     "Freight Box", "Trailer", "Andromada", "Dodo", "RC Cam", "Launch", "Police Car",
  402.     "Police Car", "Police Car", "Police Ranger", "Picador", "S.W.A.T", "Alpha",
  403.     "Phoenix", "Glendale", "Sadler", "Luggage", "Luggage", "Stairs", "Boxville",
  404.     "Tiller", "Utility Trailer"
  405. };
  406.  
  407. public RespawnVehicle(vehicleid) {
  408.     new vid = GetVID(vehicleid);
  409.     if (vCreated[vid]) {
  410.         DestroyVehicle(vehicleid);
  411.         CreateVehicle(VehicleInfo[vid][vModel], VehicleInfo[vid][xSpawn], VehicleInfo[vid][ySpawn], VehicleInfo[vid][zSpawn], VehicleInfo[vid][angleSpawn], VehicleInfo[vid][vCol1], VehicleInfo[vid][vCol2], VehicleInfo[vid][vRespawn]);
  412.         SetVehicleNumberPlate(vehicleid, VehicleInfo[vehicleid][vPlate]);
  413.         SetTimerEx("PlateSet", 1000, false, "i", vehicleid);
  414.         SetTimerEx("TuneVeh", 1000, false, "i", vehicleid);
  415.     }
  416.     return 1;
  417. }
  418.  
  419. public PlayerToggle(playerid) {
  420.     TogglePlayerControllable(playerid, true);
  421.  
  422. }
  423.  
  424. public TuneVeh(vehicleid) {
  425.     new vid = GetVID(vehicleid);
  426.     if(VehicleInfo[vid][vCol1] != -1 && VehicleInfo[vid][vCol2] != -1) {
  427.         ChangeVehicleColor(vehicleid, VehicleInfo[vid][vCol1], VehicleInfo[vid][vCol2]);
  428.     }
  429.     ApplyPaintjob(vehicleid);
  430.     ModVehicle(vehicleid);
  431. }
  432.  
  433. public KillSale(playerid, targetid) {
  434.     PlayerInfo[playerid][sTo] = -1;
  435.     new vid = PlayerInfo[playerid][svID];
  436.     PlayerInfo[playerid][svID] = 0;
  437.     PlayerInfo[targetid][sFrom] = -1;
  438.     VehicleInfo[vid][vIsSelling] = false;
  439.     VehicleInfo[vid][vSellingPrice] = 0;
  440.  
  441.     SendClientMessage(playerid, COLOR_LAWNGREEN, "[SERVER]: Offer timed out.");
  442.     SendClientMessage(targetid, COLOR_LAWNGREEN, "[SERVER]: Offer timed out.");
  443.     return 1;
  444. }
  445.  
  446. public PlateSet(vehicleid) {
  447.     new Float:xp, Float:yp, Float:zp, Float:anglep;
  448.     GetVehiclePos(vehicleid, xp, yp, zp);
  449.     GetVehicleZAngle(vehicleid, anglep);
  450.     SetVehicleToRespawn(vehicleid);
  451.     SetVehiclePos(vehicleid, xp, yp, zp);
  452.     SetVehicleZAngle(vehicleid, anglep);
  453.     SetTimerEx("TuneVeh", 1000, false, "i", vehicleid);
  454. }
  455.  
  456. public LoadVehicleData(vehicleID, name[], value[]) {
  457.     INI_Int("model", VehicleInfo[vehicleID][vModel]);
  458.     INI_Float("LocX", VehicleInfo[vehicleID][xSpawn]);
  459.     INI_Float("LocY", VehicleInfo[vehicleID][ySpawn]);
  460.     INI_Float("LocZ", VehicleInfo[vehicleID][zSpawn]);
  461.     INI_Float("LocAngle", VehicleInfo[vehicleID][angleSpawn]);
  462.     INI_Int("color1", VehicleInfo[vehicleID][vCol1]);
  463.     INI_Int("color2", VehicleInfo[vehicleID][vCol2]);
  464.     INI_Int("paintjob", VehicleInfo[vehicleID][vPaintjob]);
  465.  
  466.     for(new i = 0; i < 17; i++) {
  467.         new cmod[6];
  468.         format(cmod, sizeof(cmod), "mod%d", i);
  469.         INI_Int(cmod, VehicleInfo[vehicleID][vMod][i]);
  470.     }
  471.  
  472.     INI_String("plate", VehicleInfo[vehicleID][vPlate], 10);
  473.     INI_Int("respawn", VehicleInfo[vehicleID][vRespawn]);
  474.     INI_String("owner", VehicleInfo[vehicleID][vOwner], MAX_PLAYER_NAME);
  475.     INI_Int("price", VehicleInfo[vehicleID][vPrice]);
  476.  
  477.     INI_Bool("Secure", VehicleInfo[vehicleID][Secure]);
  478.     INI_Bool("owned", VehicleInfo[vehicleID][isOwned]);
  479.     INI_Bool("buyable", VehicleInfo[vehicleID][vBuyable]);
  480.     return 1;
  481. }
  482.  
  483. public SaveComponent(vehicleid, componentid)
  484. {
  485.     new playerid = GetDriverID(vehicleid);
  486.     if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
  487.         if (isOwner(playerid, vehicleid) || IsPlayerAdmin(playerid)) {
  488.             new vid = GetVID(vehicleid);
  489.             for(new s=0; s<20; s++) {
  490.                 if(componentid == spoiler[s][0]) {
  491.                     VehicleInfo[vehicleid][vMod][0] = componentid;
  492.                 }
  493.             }
  494.             for(new s=0; s<4; s++) {
  495.                 if(componentid == bscoop[s][0]) {
  496.                     VehicleInfo[vid][vMod][1] = componentid;
  497.                 }
  498.             }
  499.             for(new s=0; s<17; s++) {
  500.                 if(componentid == rscoop[s][0]) {
  501.                     VehicleInfo[vid][vMod][2] = componentid;
  502.                 }
  503.             }
  504.             for(new s=0; s<21; s++) {
  505.                 if(componentid == rskirt[s][0]) {
  506.                     VehicleInfo[vid][vMod][3] = componentid;
  507.                 }
  508.             }
  509.             for(new s=0; s<21; s++) {
  510.                 if(componentid == lskirt[s][0]) {
  511.                     VehicleInfo[vid][vMod][16] = componentid;
  512.                 }
  513.             }
  514.             for(new s=0; s<2; s++) {
  515.                 if(componentid == lights[s][0]) {
  516.                     VehicleInfo[vid][vMod][4] = componentid;
  517.                 }
  518.             }
  519.             for(new s=0; s<3; s++) {
  520.                 if(componentid == nitro[s][0]) {
  521.                     VehicleInfo[vid][vMod][5] = componentid;
  522.                 }
  523.             }
  524.             for(new s=0; s<28; s++) {
  525.                 if(componentid == exhaust[s][0]) {
  526.                     VehicleInfo[vid][vMod][6] = componentid;
  527.                 }
  528.             }
  529.             for(new s=0; s<17; s++) {
  530.                 if(componentid == wheels[s][0]) {
  531.                     VehicleInfo[vid][vMod][7] = componentid;
  532.                 }
  533.             }
  534.             for(new s=0; s<1; s++) {
  535.                 if(componentid == cbase[s][0]) {
  536.                     VehicleInfo[vid][vMod][8] = componentid;
  537.                 }
  538.             }
  539.             for(new s=0; s<1; s++) {
  540.                 if(componentid == hydraulics[s][0]) {
  541.                     VehicleInfo[vid][vMod][9] = componentid;
  542.                 }
  543.             }
  544.             for(new s=0; s<23; s++) {
  545.                 if(componentid == fbumper[s][0]) {
  546.                     VehicleInfo[vid][vMod][10] = componentid;
  547.                 }
  548.             }
  549.             for(new s=0; s<22; s++) {
  550.                 if(componentid == rbumper[s][0]) {
  551.                     VehicleInfo[vid][vMod][11] = componentid;
  552.                 }
  553.             }
  554.             for(new s=0; s<2; s++) {
  555.                 if(componentid == bventr[s][0]) {
  556.                     VehicleInfo[vid][vMod][12] = componentid;
  557.                 }
  558.             }
  559.             for(new s=0; s<2; s++) {
  560.                 if(componentid == bventl[s][0]) {
  561.                     VehicleInfo[vid][vMod][13] = componentid;
  562.                 }
  563.             }
  564.             for(new s=0; s<2; s++) {
  565.                 if(componentid == fbbars[s][0]) {
  566.                     VehicleInfo[vid][vMod][15] = componentid;
  567.                 }
  568.             }
  569.             for(new s=0; s<4; s++) {
  570.                 if(componentid == rbbars[s][0]) {
  571.                     VehicleInfo[vid][vMod][14] = componentid;
  572.                 }
  573.             }
  574.  
  575.             return 1;
  576.         }
  577.     }
  578.     return 0;
  579. }
  580.  
  581. public LoadUser_data(playerid,name[],value[])
  582. {
  583.     INI_Bool("allowed", PlayerInfo[playerid][pAllowed]);
  584.     INI_Int("totalvehs", PlayerInfo[playerid][pTotalVehs]);
  585.  
  586.     for(new i = 0; i < MAX_OWNABLE_VEHICLES; i++) {
  587.         new vslot[10];
  588.         format(vslot, sizeof(vslot), "slot%d", i);
  589.         INI_Int(vslot, PlayerInfo[playerid][pVSlot][i]);
  590.     }
  591.     return 1;
  592. }
  593.  
  594. public TeleportVehicleInfront(playerid, vehicleid)
  595. {
  596.     new Float:xa, Float:ya, Float:za, Float:facing, Float:distance, string[128];
  597.     new model = GetVehicleModel(vehicleid);
  598.  
  599.     GetPlayerPos(playerid, xa, ya, za);
  600.     GetPlayerFacingAngle(playerid, facing);
  601.  
  602.     new Float:size_x,Float:size_y,Float:size_z;
  603.     GetVehicleModelInfo(model, VEHICLE_MODEL_INFO_SIZE, size_x, size_y, size_z);
  604.    
  605.     distance = size_x + 0.5;
  606.  
  607.     xa += (distance * floatsin(-facing, degrees));
  608.     ya += (distance * floatcos(-facing, degrees));
  609.  
  610.     facing += 90.0;
  611.     if(facing > 360.0) facing -= 360.0;
  612.  
  613.     format(string, sizeof(string), "Your %s has been succesfully teleported to your location.", GetVehicleName(vehicleid));
  614.     SendClientMessage(playerid, COLOR_LAWNGREEN, string);
  615.     return SetVehiclePos(vehicleid, xa, ya, za + (size_z * 0.25));
  616. }
  617.  
  618. GetVehicleName(vehicleid)
  619. {
  620.     new String[128];
  621.     format(String, sizeof(String),"%s",VehicleNames[GetVehicleModel(vehicleid) - 400]);
  622.     return String;
  623. }
  624.  
  625.  
  626.  
  627. GetSlotFromVehicle(playerid, vehicleid) {
  628.     for(new i = 0; i < MAX_OWNABLE_VEHICLES; i++) {
  629.         if(PlayerInfo[playerid][pVSlot][i] == vehicleid) return i;
  630.     }
  631.     return -1;
  632. }
  633.  
  634. IsVehicleOccupied(vehicleid) {
  635.  
  636.     for(new i =0; i < MAX_PLAYERS; i++)
  637.     {
  638.         if(IsPlayerInVehicle(i,vehicleid)) return true;
  639.            
  640.     }
  641.     return false;
  642. }
  643.  
  644.  
  645.  
  646. Teleport(playerid, Float:x, Float:y, Float:z, Float:angle, interior, virtualworld, bool:ignoreVehicle) {
  647.     if(!ignoreVehicle && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
  648.         new vehicleid = GetPlayerVehicleID(playerid);
  649.         SetVehiclePos(vehicleid, x, y, z);
  650.         SetVehicleZAngle(vehicleid, angle);
  651.         LinkVehicleToInterior(vehicleid, interior);
  652.         SetVehicleVirtualWorld(vehicleid, virtualworld);
  653.     } else {
  654.         SetPlayerPos(playerid, x, y, z);
  655.         SetPlayerFacingAngle(playerid, angle);
  656.     }
  657.    
  658.     SetPlayerInterior(playerid, interior);
  659.     SetPlayerVirtualWorld(playerid, virtualworld);
  660. }
  661.  
  662. GetVID(vehicleID)
  663. {
  664.     for(new i = 0; i < MAX_VEHICLES; i++)
  665.     {
  666.         if((vCreated[i]) && (VehicleInfo[i][vID] == vehicleID)) return i;
  667.     }
  668.  
  669.     return -1;
  670. }
  671.  
  672. GetVehicleID(vid) {
  673.     for(new i = 1; i < MAX_VEHICLES; i++) {
  674.         if((vCreated[i]) && (VehicleInfo[vid][vID] == GetVID(i))) return i;
  675.     }
  676.     return -1;
  677. }
  678.  
  679. IsTempVehicle(vehicleID)
  680. {
  681.     new vehicleid = GetVID(vehicleID);
  682.     if(!vCreated[vehicleid] || VehicleInfo[vehicleid][vTemp]) return true;
  683.  
  684.     return false;
  685. }
  686.  
  687. GetFreeVehicleSlot() {
  688.     for(new i = 1; i < sizeof(vCreated); i ++)
  689.     {
  690.         if(!vCreated[i]) return i;
  691.     }
  692.     return -1;
  693. }
  694.  
  695. VehiclePath(vehicleid) {
  696.     new path[64];
  697.     format(path, sizeof(path), VEHICLES_PATH, vehicleid);
  698.     return path;
  699. }
  700.  
  701. UserPath(playerid) {
  702.     new path[64], name[MAX_PLAYER_NAME];
  703.     GetPlayerName(playerid, name, sizeof(name));
  704.     format(path, sizeof(path), USERS_PATH, name);
  705.     return path;
  706. }
  707.  
  708. ApplyPaintjob(vehicleid) {
  709.     new vid = GetVID(vehicleid);
  710.     if(VehicleInfo[vid][vPaintjob] != -1) {
  711.         ChangeVehiclePaintjob(vehicleid, VehicleInfo[vid][vPaintjob]);
  712.     }
  713. }
  714.  
  715. CreateVehicleEx(vehicleModel, Float:vxSpawn, Float:vySpawn, Float:vzSpawn, Float:vangleSpawn, vehicleColor1, vehicleColor2, vehiclePaintjob, vehicleMods[], vehiclePlate[], vehicleRespawn, vehicleOwner[], vehiclePrice, bool:vSecure, bool:vIsOwned, bool:vehicleBuyable) {
  716.     new vehicleid = GetFreeVehicleSlot();
  717.    
  718.     VehicleInfo[vehicleid][vModel]      = vehicleModel;
  719.     VehicleInfo[vehicleid][xSpawn]      = vxSpawn;
  720.     VehicleInfo[vehicleid][ySpawn]      = vySpawn;
  721.     VehicleInfo[vehicleid][zSpawn]      = vzSpawn;
  722.     VehicleInfo[vehicleid][angleSpawn]  = vangleSpawn;
  723.     VehicleInfo[vehicleid][vCol1]       = vehicleColor1;
  724.     VehicleInfo[vehicleid][vCol2]       = vehicleColor2;
  725.     VehicleInfo[vehicleid][vPaintjob]   = vehiclePaintjob;
  726.  
  727.     for(new i = 0; i < 17; i++) {
  728.         VehicleInfo[vehicleid][vMod][i] = vehicleMods[i];
  729.     }
  730.  
  731.     VehicleInfo[vehicleid][vRespawn]    = vehicleRespawn;
  732.  
  733.     new buffer2[10];
  734.     strcpy(buffer2, vehiclePlate);
  735.     strcpy(VehicleInfo[vehicleid][vPlate], buffer2, 10);
  736.  
  737.     new buffer[MAX_PLAYER_NAME];
  738.     strcpy(buffer, vehicleOwner);
  739.     strcpy(VehicleInfo[vehicleid][vOwner], buffer, MAX_PLAYER_NAME);
  740.    
  741.     VehicleInfo[vehicleid][vPrice]      = vehiclePrice;
  742.  
  743.     VehicleInfo[vehicleid][Secure]       = vSecure;
  744.     VehicleInfo[vehicleid][isOwned]     = vIsOwned;
  745.     VehicleInfo[vehicleid][vBuyable]    = vehicleBuyable;
  746.    
  747.    
  748.     VehicleInfo[vehicleid][vID]         = CreateVehicle(vehicleModel, vxSpawn, vySpawn, vzSpawn, vangleSpawn, vehicleColor1, vehicleColor2, vehicleRespawn);
  749.  
  750.     vCreated[vehicleid]                     = true;
  751.     VehicleInfo[vehicleid][vTemp]           = false;
  752.     VehicleInfo[vehicleid][vIsSelling]      = false;
  753.     VehicleInfo[vehicleid][vSellingPrice]   = 0;
  754.     TotalVehicles++;
  755.     SetVehicleNumberPlate(vehicleid, VehicleInfo[vehicleid][vPlate]);
  756.  
  757.     SetTimerEx("PlateSet", 1000, false, "i", vehicleid);
  758.     SetTimerEx("TuneVeh", 1000, false, "i", vehicleid);
  759.    
  760.     return vehicleid;
  761. }
  762.  
  763. stock CreateTempVehicle(model, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawntime) {
  764.     new vehicleid = GetFreeVehicleSlot();
  765.    
  766.     VehicleInfo[vehicleid][vModel]      = model;
  767.     VehicleInfo[vehicleid][xSpawn]      = x;
  768.     VehicleInfo[vehicleid][ySpawn]      = y;
  769.     VehicleInfo[vehicleid][zSpawn]      = z;
  770.     VehicleInfo[vehicleid][angleSpawn]  = angle;
  771.     VehicleInfo[vehicleid][vCol1]       = color1;
  772.     VehicleInfo[vehicleid][vCol2]       = color2;
  773.  
  774.     VehicleInfo[vehicleid][vPaintjob]   = -1;
  775.  
  776.     for(new i = 0; i < 17; i++) {
  777.         VehicleInfo[vehicleid][vMod][i] = -1;
  778.     }
  779.  
  780.     VehicleInfo[vehicleid][vRespawn]    = respawntime;
  781.  
  782.     new buffer2[10];
  783.     strcpy(buffer2, DEFAULT_PLATE);
  784.     strcpy(VehicleInfo[vehicleid][vPlate], buffer2, 10);
  785.  
  786.     new buffer[MAX_PLAYER_NAME];
  787.     strcpy(buffer, DEFAULT_OWNER);
  788.     strcpy(VehicleInfo[vehicleid][vOwner], buffer, MAX_PLAYER_NAME);
  789.    
  790.     VehicleInfo[vehicleid][vPrice]      = 0;
  791.     VehicleInfo[vehicleid][Secure]      = false;
  792.  
  793.     VehicleInfo[vehicleid][isOwned]     = false;
  794.     VehicleInfo[vehicleid][vBuyable]    = false;
  795.  
  796.     VehicleInfo[vehicleid][vID]         = CreateVehicle(model, x, y, z, angle, color1, color2, respawntime);
  797.  
  798.     vCreated[vehicleid]                     = true;
  799.     VehicleInfo[vehicleid][vTemp]           = true;
  800.     VehicleInfo[vehicleid][vIsSelling]      = false;
  801.     VehicleInfo[vehicleid][vSellingPrice]   = 0
  802.     SetVehicleNumberPlate(vehicleid, VehicleInfo[vehicleid][vPlate]);
  803.     TotalVehicles++;
  804.  
  805.     SetTimerEx("PlateSet", 1000, false, "i", vehicleid);
  806.     SetTimerEx("TuneVeh", 1000, false, "i", vehicleid);
  807.    
  808.     return vehicleid;
  809. }
  810.  
  811.  
  812. LoadVehicle(vehicleID, file[]) {
  813.     INI_ParseFile(file, "LoadVehicleData", .bExtra=true, .extra = vehicleID);
  814.  
  815.     CreateVehicleEx(VehicleInfo[vehicleID][vModel], VehicleInfo[vehicleID][xSpawn], VehicleInfo[vehicleID][ySpawn], VehicleInfo[vehicleID][zSpawn], VehicleInfo[vehicleID][angleSpawn], VehicleInfo[vehicleID][vCol1], VehicleInfo[vehicleID][vCol2], VehicleInfo[vehicleID][vPaintjob], VehicleInfo[vehicleID][vMod],VehicleInfo[vehicleID][vPlate], VehicleInfo[vehicleID][vRespawn], VehicleInfo[vehicleID][vOwner], VehicleInfo[vehicleID][vPrice], VehicleInfo[vehicleID][Secure], VehicleInfo[vehicleID][isOwned],VehicleInfo[vehicleID][vBuyable]);
  816. }
  817.  
  818.  
  819.  
  820. SaveVehicle(vehicleID) {
  821.     if(!IsTempVehicle(vehicleID)) {
  822.         new INI:dFile = INI_Open(VehiclePath(vehicleID));
  823.  
  824.         INI_WriteInt(dFile, "model", VehicleInfo[vehicleID][vModel]);
  825.         INI_WriteFloat(dFile, "LocX", VehicleInfo[vehicleID][xSpawn]);
  826.         INI_WriteFloat(dFile, "LocY", VehicleInfo[vehicleID][ySpawn]);
  827.         INI_WriteFloat(dFile, "LocZ", VehicleInfo[vehicleID][zSpawn]);
  828.         INI_WriteFloat(dFile, "LocAngle", VehicleInfo[vehicleID][angleSpawn]);
  829.         INI_WriteInt(dFile, "color1", VehicleInfo[vehicleID][vCol1]);
  830.         INI_WriteInt(dFile, "color2", VehicleInfo[vehicleID][vCol2]);
  831.         INI_WriteInt(dFile, "paintjob", VehicleInfo[vehicleID][vPaintjob]);
  832.  
  833.         for(new i = 0; i < 17; i++) {
  834.                 new cmod[6];
  835.                 format(cmod, sizeof(cmod), "mod%d", i);
  836.                 INI_WriteInt(dFile ,cmod, VehicleInfo[vehicleID][vMod][i]);
  837.         }
  838.  
  839.         INI_WriteString(dFile, "plate", VehicleInfo[vehicleID][vPlate]);
  840.         INI_WriteInt(dFile, "respawn", VehicleInfo[vehicleID][vRespawn]);
  841.         INI_WriteString(dFile, "owner", VehicleInfo[vehicleID][vOwner]);
  842.         INI_WriteInt(dFile,"price", VehicleInfo[vehicleID][vPrice]);
  843.        
  844.         INI_WriteBool(dFile, "Secure", VehicleInfo[vehicleID][Secure]);
  845.         INI_WriteBool(dFile, "owned", VehicleInfo[vehicleID][isOwned]);
  846.         INI_WriteBool(dFile, "buyable", VehicleInfo[vehicleID][vBuyable]);
  847.        
  848.         INI_Close(dFile);
  849.     }
  850.     return 1;
  851. }
  852.  
  853. LoadAllVehicle() {
  854.     new index = 0;
  855.     new loadedveh = 0;
  856.     for(new i = 0; i < MAX_VEHICLES; i++) {
  857.         if (fexist(VehiclePath(index))) {
  858.             LoadVehicle(index, VehiclePath(index));
  859.             loadedveh++;
  860.         }
  861.         index++;
  862.     }
  863.    
  864.     printf("Vehicles Loaded: %d", loadedveh);
  865. }
  866.  
  867. SaveAllVehicle() {
  868.     new index = 1;
  869.     new savedveh = 0;
  870.    
  871.     for(new i = 1; i <= TotalVehicles; i++) {
  872.         if (!IsTempVehicle(i)) {
  873.             SaveVehicle(index);
  874.             savedveh++;
  875.         }
  876.         index++;
  877.     }
  878.    
  879.     printf("Vehicles Saved: %d", savedveh);
  880. }
  881.  
  882. isVehicleForSale(vehicleid) {
  883.     if (VehicleInfo[vehicleid][vBuyable] && !VehicleInfo[vehicleid][isOwned]) return true;
  884.    
  885.     return false;
  886. }
  887.  
  888. GetDriverID(vehicleid)
  889. {
  890.     for(new i = 0; i < MAX_PLAYERS; i++)
  891.     {
  892.         if(GetPlayerVehicleID(i) == vehicleid && GetPlayerState(i) == PLAYER_STATE_DRIVER) return i;
  893.     }
  894.     return -1;
  895. }
  896.  
  897. GetName(playerid) {
  898.     new name[MAX_PLAYER_NAME];
  899.     GetPlayerName(playerid, name, sizeof(name));
  900.     return name;
  901. }
  902.  
  903. isOwner(playerid, vehicleid) {
  904.     new name[MAX_PLAYER_NAME];
  905.     GetPlayerName(playerid, name, sizeof(name));
  906.     new vid = GetVID(vehicleid);
  907.     if(VehicleInfo[vid][isOwned]) {
  908.         if(!strcmp(name, VehicleInfo[vid][vOwner], false, MAX_PLAYER_NAME)) return true;
  909.     }
  910.  
  911.     return false;
  912. }
  913.  
  914. ModVehicle(vehicleid)
  915. {
  916.     if(vehicleid <= 0 || vehicleid >= MAX_VEHICLES) return;
  917.     for(new i = 0; i < 17; i++) {
  918.         if(VehicleInfo[vehicleid][vMod][i] != 0) {
  919.             AddVehicleComponent(vehicleid, VehicleInfo[vehicleid][vMod][i]);
  920.         }
  921.     }
  922. }
  923.  
  924.  
  925. IsNumeric(const string[])
  926. {
  927.     for (new i = 0, j = strlen(string); i < j; i++)
  928.     {
  929.         if (string[i] > '9' || string[i] < '0')
  930.         return 0;
  931.     }
  932.     return true;
  933. }
  934.  
  935. GetModelVehicle(vname[])
  936. {
  937.     for(new i = 0; i < 211; i++)
  938.     {
  939.         if(strfind(VehicleNames[i], vname, true) != -1) return i + 400;
  940.     }
  941.     return -1;
  942. }
  943.  
  944. DestroyVehicleEx(vehicleid) {
  945.     new vid = GetVID(vehicleid);
  946.     if(vCreated[vid]) {
  947.         if(!IsTempVehicle(vehicleid)) {
  948.             fremove(VehiclePath(VehicleInfo[vid][vID]));
  949.         }
  950.         vCreated[vid] = false;
  951.         VehicleInfo[vid][vTemp] = false;
  952.         DestroyVehicle(vehicleid);
  953.         TotalVehicles--;
  954.     }
  955.     return 1;
  956. }
  957.  
  958. IsSlotsFull(playerid) {
  959.     for(new i = 0; i < MAX_OWNABLE_VEHICLES; i++) {
  960.         if(PlayerInfo[playerid][pVSlot][i] == 0) return false;
  961.     }
  962.  
  963.     return true;
  964. }
  965. GetPlayerFreeSlot(playerid) {
  966.     for(new i = 0; i < MAX_OWNABLE_VEHICLES; i++) {
  967.         if(PlayerInfo[playerid][pVSlot][i] == 0) return i;
  968.     }
  969.  
  970.     return -1;
  971. }
  972.  
  973. SavePlayer(playerid) {
  974.     new INI:File = INI_Open(UserPath(playerid));
  975.     INI_SetTag(File,"data");
  976.     INI_WriteBool(File, "allowed", PlayerInfo[playerid][pAllowed]);
  977.     INI_WriteInt(File, "totalvehs", PlayerInfo[playerid][pTotalVehs]);
  978.  
  979.     for(new i = 0; i < MAX_OWNABLE_VEHICLES; i++) {
  980.         new vslot[10];
  981.         format(vslot, sizeof(vslot), "slot%d", i);
  982.         INI_WriteInt(File, vslot, PlayerInfo[playerid][pVSlot][i]);
  983.     }  
  984.     INI_Close(File);
  985. }
  986.  
  987. GetVehicleSlot(playerid, vehicleid) {
  988.     new vid = GetVID(vehicleid);
  989.     for(new i = 0; i < MAX_OWNABLE_VEHICLES; i++) {
  990.         if(PlayerInfo[playerid][pVSlot][i] == vid) return i;
  991.     }
  992.     return -1;
  993. }
  994.  
  995.  
  996. //--------------------------------------------------------------------------
  997. public OnFilterScriptInit()
  998. {
  999.     print("\n_____________________________________\n");
  1000.     print("Loading... Elite Vehicle Ownership by Darkskull\n");
  1001.    
  1002.    
  1003.     LoadAllVehicle();
  1004.     print("Loading Completed\n");
  1005.     print("_____________________________________\n");
  1006.     return 1;
  1007. }
  1008.  
  1009. public OnFilterScriptExit()
  1010. {
  1011.     SaveAllVehicle();
  1012.     for(new i = 0; i < MAX_VEHICLES; i++) {
  1013.         if(vCreated[i]) {
  1014.             DestroyVehicle(i);
  1015.         }
  1016.     }
  1017.     return 1;
  1018. }
  1019.  
  1020. public OnPlayerConnect(playerid)
  1021. {
  1022.     PlayerInfo[playerid][pAllowed] = false;
  1023.     PlayerInfo[playerid][pTotalVehs] = 0;
  1024.     for(new i = 0; i < MAX_OWNABLE_VEHICLES; i++) {
  1025.         PlayerInfo[playerid][pVSlot][i] = 0;
  1026.     }
  1027.     PlayerInfo[playerid][sTo] = -1;
  1028.     PlayerInfo[playerid][sFrom] = -1;
  1029.     PlayerInfo[playerid][svID] = 0;
  1030.  
  1031.     if(fexist(UserPath(playerid)))
  1032.     {
  1033.         INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  1034.     }
  1035.     else
  1036.     {
  1037.         new INI:File = INI_Open(UserPath(playerid));
  1038.         INI_SetTag(File,"data");
  1039.         INI_WriteBool(File, "allowed", false);
  1040.         INI_WriteInt(File, "totalvehs", 0);
  1041.  
  1042.         for(new i = 0; i < MAX_OWNABLE_VEHICLES; i++) {
  1043.             new vslot[10];
  1044.             format(vslot, sizeof(vslot), "slot%d", i);
  1045.             INI_WriteInt(File, vslot, 0);
  1046.         }  
  1047.         INI_Close(File);
  1048.     }
  1049.     return 1;
  1050. }
  1051.  
  1052. public OnPlayerDisconnect(playerid, reason)
  1053. {
  1054.     if(PlayerInfo[playerid][sTo] != -1) {
  1055.         new targetid = PlayerInfo[playerid][sTo];
  1056.         new vehicleid = PlayerInfo[playerid][svID];
  1057.         SendClientMessage(targetid, COLOR_ORANGE, "[SERVER]: Your offer has timed out because the vehicle owner has left the game.");
  1058.         PlayerInfo[targetid][sFrom] = -1;
  1059.         PlayerInfo[playerid][svID] = 0;
  1060.         VehicleInfo[vehicleid][vIsSelling] = false;
  1061.         VehicleInfo[vehicleid][vSellingPrice] = 0;
  1062.         KillTimer(SellingTimer[playerid]);
  1063.     }
  1064.     if(PlayerInfo[playerid][sFrom] != -1) {
  1065.         new ownerid = PlayerInfo[playerid][sFrom];
  1066.         new vehicleid = PlayerInfo[ownerid][svID];
  1067.         SendClientMessage(ownerid, COLOR_ORANGE, "[SERVER]: Your offer has timed out because the client has left the game.");
  1068.         PlayerInfo[ownerid][sTo] = -1;
  1069.         PlayerInfo[ownerid][svID] = 0;
  1070.         VehicleInfo[vehicleid][vIsSelling] = false;
  1071.         VehicleInfo[vehicleid][vSellingPrice] = 0;
  1072.         KillTimer(SellingTimer[ownerid]);
  1073.     }
  1074.  
  1075.     new INI:File = INI_Open(UserPath(playerid));
  1076.     INI_SetTag(File,"data");
  1077.     INI_WriteBool(File, "allowed", false);
  1078.     INI_WriteInt(File, "totalvehs", PlayerInfo[playerid][pTotalVehs]);
  1079.  
  1080.     for(new i = 0; i < MAX_OWNABLE_VEHICLES; i++) {
  1081.         new vslot[10];
  1082.         format(vslot, sizeof(vslot), "slot%d", i);
  1083.         INI_WriteInt(File, vslot, PlayerInfo[playerid][pVSlot][i]);
  1084.     }  
  1085.     INI_Close(File);
  1086.     return 1;
  1087. }
  1088.  
  1089. public OnPlayerSpawn(playerid)
  1090. {
  1091.     PlayerInfo[playerid][pAllowed] = true;
  1092.     return 1;
  1093. }
  1094.  
  1095. public OnPlayerDeath(playerid, killerid, reason)
  1096. {
  1097.     PlayerInfo[playerid][pAllowed] = false;
  1098.     return 1;
  1099. }
  1100.  
  1101. public OnVehicleSpawn(vehicleid)
  1102. {
  1103.     if(!IsTempVehicle(vehicleid)) {
  1104.         SetTimerEx("TuneVeh", 500, false, "i", vehicleid);
  1105.     }  
  1106.     return 1;
  1107. }
  1108.  
  1109. public OnVehicleDeath(vehicleid, killerid)
  1110. {
  1111.     return 1;
  1112. }
  1113.  
  1114. public OnPlayerText(playerid, text[])
  1115. {
  1116.     return 1;
  1117. }
  1118.  
  1119. public OnPlayerCommandText(playerid, cmdtext[])
  1120. {
  1121.     if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  1122.     {
  1123.         // Do something here
  1124.         return 1;
  1125.     }
  1126.     return 0;
  1127. }
  1128.  
  1129. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  1130. {
  1131.     if (!IsTempVehicle(vehicleid)) {
  1132.         new vid = GetVID(vehicleid);
  1133.         new name[MAX_PLAYER_NAME];
  1134.         GetPlayerName(playerid, name, sizeof(name));
  1135.         if(VehicleInfo[vid][isOwned]) {
  1136.             if(isOwner(playerid, vehicleid)) {
  1137.                 new msg[128];
  1138.                 format(msg, sizeof(msg), "[SERVER]: Welcome to your %s, %s. %s", GetVehicleName(vehicleid), name, Messages1[random(sizeof(Messages1))]);
  1139.                 SendClientMessage(playerid, COLOR_LAWNGREEN, msg);
  1140.             } else {
  1141.                 new msg[128];
  1142.                 format(msg, sizeof(msg), "[SERVER]: This %s belongs to %s and cannot be purchased.", GetVehicleName(vehicleid), VehicleInfo[vid][vOwner]);
  1143.                 SendClientMessage(playerid, COLOR_RED, msg);
  1144.             }
  1145.         } else {
  1146.             if(VehicleInfo[vid][vBuyable]) {
  1147.                 new msg[128];
  1148.                 format(msg, sizeof(msg), "[SERVER]: This %s is for sale and costs $%d, Type /vbuy to buy this vehicle", GetVehicleName(vehicleid), VehicleInfo[vid][vPrice]);
  1149.                 SendClientMessage(playerid, COLOR_YELLOW, msg);
  1150.             } else {
  1151.                 new msg[128];
  1152.                 format(msg, sizeof(msg), "[SERVER]: This %s has been set as unbuyable by the server administrator", GetVehicleName(vehicleid));
  1153.                 SendClientMessage(playerid, COLOR_RED, msg);
  1154.             }
  1155.         }
  1156.     } else {
  1157.         new msg[128];
  1158.         format(msg, sizeof(msg), "[SERVER]: This %s is a temporary vehicle and cannot be purchased", GetVehicleName(vehicleid));
  1159.         SendClientMessage(playerid, COLOR_ORANGE, msg);
  1160.     }
  1161.     return 1;
  1162. }
  1163.  
  1164. public OnPlayerExitVehicle(playerid, vehicleid)
  1165. {
  1166.     return 1;
  1167. }
  1168.  
  1169. public OnPlayerStateChange(playerid, newstate, oldstate)
  1170. {
  1171.     if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER) {
  1172.         new vehicleid = GetPlayerVehicleID(playerid);
  1173.         new vid = GetVID(vehicleid);
  1174.         if(VehicleInfo[vid][Secure] && !isOwner(playerid, vehicleid) && !IsPlayerAdmin(playerid)) {
  1175.             RemovePlayerFromVehicle(playerid);
  1176.             SendClientMessage(playerid, COLOR_DODGERBLUE, "[SERVER]: This vehicle has been secured by its owner and has prohibited anyone from using it.");
  1177.         }
  1178.     }
  1179.     return 1;
  1180. }
  1181.  
  1182. public OnVehicleMod(playerid, vehicleid, componentid)
  1183. {
  1184.     SaveComponent(vehicleid, componentid);
  1185.     new vid = GetVID(vehicleid);
  1186.     SaveVehicle(vid);
  1187.     return 1;
  1188. }
  1189.  
  1190. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  1191. {
  1192.     if(!IsTempVehicle(vehicleid)){
  1193.         if(isOwner(playerid, vehicleid) || IsPlayerAdmin(playerid)) {
  1194.             new vid = GetVID(vehicleid);
  1195.             VehicleInfo[vid][vPaintjob] = paintjobid;
  1196.             SaveVehicle(vid);
  1197.         }
  1198.     }
  1199.     return 1;
  1200. }
  1201.  
  1202. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  1203. {
  1204.     if(!IsTempVehicle(vehicleid)){
  1205.         if(isOwner(playerid, vehicleid) || IsPlayerAdmin(playerid)) {
  1206.             new vid = GetVID(vehicleid);
  1207.             VehicleInfo[vid][vCol1] = color1;
  1208.             VehicleInfo[vid][vCol2] = color2;
  1209.             SaveVehicle(vid);
  1210.         }
  1211.     }
  1212.     return 1;
  1213. }
  1214.  
  1215. public OnVehicleStreamIn(vehicleid, forplayerid)
  1216. {
  1217.     new vid = GetVID(vehicleid);
  1218.     if(vCreated[vid]) {
  1219.         if(!VehicleInfo[vid][vTemp]) {
  1220.             SetTimerEx("TuneVeh", 1000, false, "i", vehicleid);
  1221.         }
  1222.  
  1223.     }
  1224.     return 1;
  1225. }
  1226.  
  1227. CMD:vcreate(playerid, params[])
  1228. {
  1229.     if(!PlayerInfo[playerid][pAllowed]) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not allowed to use this command right now. ");
  1230.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not authorized to use that command.");
  1231.     new model[32];
  1232.  
  1233.     if(sscanf(params, "s[32]", model)) return SendClientMessage(playerid, COLOR_DODGERBLUE, "[USAGE]: /vcreate [VehicleModel]");
  1234.  
  1235.     new vehModel;
  1236.     if(IsNumeric(model)) {
  1237.         vehModel = strval(model);
  1238.     } else {
  1239.         vehModel = GetModelVehicle(model);
  1240.     }
  1241.  
  1242.     if(vehModel < 400 || vehModel > 611) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: Invalid Vehicle.");
  1243.  
  1244.     new Float:x, Float:y, Float:z, Float:angle, mods[17], vehicleid, string[128];
  1245.     if(!IsPlayerInAnyVehicle(playerid)) {
  1246.         GetPlayerPos(playerid, x, y, z);
  1247.         GetPlayerFacingAngle(playerid, angle);
  1248.     } else {
  1249.         new tvid = GetPlayerVehicleID(playerid);
  1250.         GetVehiclePos(tvid, x, y, z);
  1251.         GetVehicleZAngle(tvid, angle);
  1252.     }  
  1253.  
  1254.     for (new i = 0; i < 17; i++) {
  1255.         mods[i] = 0;
  1256.     }
  1257.  
  1258.     vehicleid = CreateVehicleEx(vehModel, x, y, z, angle, -1, -1, -1, mods, DEFAULT_PLATE, RESPAWN_TIME*60*1000, DEFAULT_OWNER, DEFAULT_PRICE, false, false, true);
  1259.  
  1260.     new vid = GetVID(vehicleid);
  1261.  
  1262.     format(string, sizeof(string), "[SERVER]: You have succesfully create a(n) %s", GetVehicleName(vehicleid));
  1263.     SaveVehicle(vid);
  1264.     return 1;
  1265. }
  1266.  
  1267. CMD:vremove(playerid, params[])
  1268. {
  1269.     if(!PlayerInfo[playerid][pAllowed]) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not allowed to use this command right now. ");
  1270.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not authorized to use that command.");
  1271.     if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "[SERVER]: You need to be in a vehicle to use this command.");
  1272.     new vehicleid = GetPlayerVehicleID(playerid);
  1273.     new vid = GetVID(vehicleid);
  1274.     if(IsTempVehicle(vehicleid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: This is a temporary vehicle");
  1275.     if(VehicleInfo[vid][vIsSelling]) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: This vehicle has been offered to someone. Please wait until the process is completed.");
  1276.  
  1277.     DestroyVehicleEx(vehicleid);
  1278.  
  1279.     SendClientMessage(playerid, COLOR_LAWNGREEN, "[SERVER]: You have succesfully removed this vehicle.");
  1280.     return 1;
  1281. }
  1282.  
  1283.  
  1284. CMD:rac(playerid, params[]) {
  1285.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not authorized to use that command.");
  1286.     if(!PlayerInfo[playerid][pAllowed]) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not allowed to use this command right now. ");
  1287.     for(new i=1; i < MAX_VEHICLES; i++) {
  1288.         if(vCreated[i]) {
  1289.             if(!IsVehicleOccupied(i)) {
  1290.                 RespawnVehicle(i);
  1291.             }
  1292.         }
  1293.     }
  1294.  
  1295.     new name[MAX_PLAYER_NAME], string[100];
  1296.     GetPlayerName(playerid, name, sizeof(name));
  1297.     format(string, sizeof(string), "[SERVER]: All unused vehicle have been respawned by Admin %s", name);
  1298.     SendClientMessageToAll(COLOR_DODGERBLUE, string);
  1299.     return 1;
  1300. }
  1301.  
  1302. CMD:vinfo(playerid, params[]) {
  1303.     if(!PlayerInfo[playerid][pAllowed]) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not allowed to use this command right now. ");
  1304.     if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "[SERVER]: You need to be in a vehicle to use this command.");
  1305.     new str[256], mainstr[1000], title[256];
  1306.     new vehicleid = GetPlayerVehicleID(playerid);
  1307.     if(IsTempVehicle(vehicleid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: No info available as this is a temporary vehicle");
  1308.     new vid = GetVID(vehicleid);
  1309.    
  1310.     format(str, sizeof(str), "{FFD700}Vehicle Model: {FFFFFF}%d\n", GetVehicleModel(vehicleid));
  1311.     strcat(mainstr, str, sizeof(mainstr));
  1312.  
  1313.     if(VehicleInfo[vid][isOwned]) {
  1314.         format(str, sizeof(str), "{FFD700}Owned: {FFFFFF}Yes\n{FFD700}Owner: {FFFFFF}%s\n", VehicleInfo[vid][vOwner]);
  1315.         strcat(mainstr, str, sizeof(mainstr));
  1316.         if(IsPlayerAdmin(playerid)) {
  1317.             format(str, sizeof(str), "{FFD700}Price: {FFFFFF}%d\n", VehicleInfo[vid][vPrice]);
  1318.             strcat(mainstr, str, sizeof(mainstr));
  1319.         }
  1320.     } else {
  1321.         format(str, sizeof(str), "{FFD700}Owned: {FFFFFF}No\n");
  1322.         strcat(mainstr, str, sizeof(mainstr));
  1323.     }
  1324.  
  1325.     if(VehicleInfo[vid][vBuyable] && !VehicleInfo[vid][isOwned]) {
  1326.         format(str, sizeof(str), "{FFD700}Buyable: {FFFFFF}Yes\n{FFD700}Price: {FFFFFF}%d\n", VehicleInfo[vid][vPrice]);
  1327.         strcat(mainstr, str, sizeof(mainstr));
  1328.     } else {
  1329.         format(str, sizeof(str), "{FFD700}Buyable: {FFFFFF}No\n");
  1330.         strcat(mainstr, str, sizeof(mainstr));
  1331.     }
  1332.  
  1333.     format(str, sizeof(str), "{FFD700}Color 1: {FFFFFF}%i\n{FFD700}Color2: {FFFFFF}%i\n", VehicleInfo[vid][vCol1], VehicleInfo[vid][vCol2]);
  1334.     strcat(mainstr, str, sizeof(mainstr));
  1335.     if(IsPlayerAdmin(playerid)) {
  1336.         format(str, sizeof(str), "{FFD700}Paintjob: {FFFFFF}%i\n{FFD700}Respawn time: {FFFFFF}%i\n", VehicleInfo[vid][vPaintjob], VehicleInfo[vid][vRespawn]);
  1337.         strcat(mainstr, str, sizeof(mainstr));
  1338.     }
  1339.     if(VehicleInfo[vid][Secure]) {
  1340.         format(str, sizeof(str), "{FFD700}Secured: {FFFFFF}Yes\n");
  1341.         strcat(mainstr, str, sizeof(mainstr));
  1342.     } else {
  1343.         format(str, sizeof(str), "{FFD700}Secured: {FFFFFF}No\n");
  1344.         strcat(mainstr, str, sizeof(mainstr));
  1345.     }
  1346.  
  1347.     format(title, sizeof(title), "{FFD700}%s's {FFFFFF}info", GetVehicleName(vehicleid));
  1348.     return ShowPlayerDialog(playerid, DIALOG_VINFO, DIALOG_STYLE_MSGBOX, title, mainstr, "Okay", "");
  1349. }
  1350.  
  1351. CMD:vgoto(playerid, params[]) {
  1352.     if(!PlayerInfo[playerid][pAllowed]) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not allowed to use this command right now. ");
  1353.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not authorized to use that command.");
  1354.     new vehicleid;
  1355.     if(sscanf(params, "i", vehicleid)) return SendClientMessage(playerid, COLOR_DODGERBLUE, "[USAGE]: /vgoto [Vehicle ID]");
  1356.     if(vehicleid == INVALID_VEHICLE_ID) return SendClientMessage(playerid, COLOR_RED, "[SERVER]: Invalid Vehicle ID!");
  1357.     if(!vCreated[vehicleid]) return SendClientMessage(playerid, COLOR_RED, "[SERVER]: That vehicle doesn't exist!");
  1358.  
  1359.     vehicleid = GetVID(vehicleid);
  1360.     new Float:x, Float:y, Float:z, virtualworld;
  1361.     GetVehiclePos(vehicleid, x, y, z);
  1362.     GetVehicleVirtualWorld(vehicleid);
  1363.  
  1364.     TogglePlayerControllable(playerid, false);
  1365.     Teleport(playerid, x, y, z+3.5, 0, 0, virtualworld, true);
  1366.     SetTimerEx("PlayerToggle", 800, false, "i", playerid);
  1367.  
  1368.     return 1;
  1369. }
  1370.  
  1371. CMD:vpark(playerid, params[]) {
  1372.     if(!PlayerInfo[playerid][pAllowed]) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not allowed to use this command right now. ");
  1373.     if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "[SERVER]: You need to be in a vehicle to use this command.");
  1374.     if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_RED, "[SERVER]: You need to be the driver of the vehicle to park.");
  1375.  
  1376.     new vehicleid = GetPlayerVehicleID(playerid);
  1377.     if(IsTempVehicle(vehicleid)) return SendClientMessage(playerid, COLOR_RED, "[SERVER]: This is a temporary vehicle and cannot be parked!");
  1378.  
  1379.     if(!isOwner(playerid, vehicleid) && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[SERVER]: You are not the owner of this vehicle.");
  1380.     if(isVehicleForSale(vehicleid) && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[SERVER]: You are not the owner of this vehicle.");
  1381.  
  1382.    
  1383.     new Float:x, Float:y, Float:z, Float:angle;
  1384.     new vid = GetVID(vehicleid);
  1385.     GetVehiclePos(vehicleid, x, y, z);
  1386.     GetVehicleZAngle(vehicleid, angle);
  1387.  
  1388.     VehicleInfo[vid][xSpawn]     = x;
  1389.     VehicleInfo[vid][ySpawn]     = y;
  1390.     VehicleInfo[vid][zSpawn]     = z;
  1391.     VehicleInfo[vid][angleSpawn] = angle;
  1392.  
  1393.     SendClientMessage(playerid, COLOR_LAWNGREEN, "[SERVER]: You have succesfully parked this vehicle here. It will respawn here in the future.");
  1394.     SaveVehicle(vid);
  1395.     return 1;
  1396. }
  1397.  
  1398. CMD:clearmods(playerid, params[]) {
  1399.     if(!PlayerInfo[playerid][pAllowed]) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not allowed to use this command right now. ");
  1400.     if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "[SERVER]: You need to be in a vehicle to use this command.");
  1401.     if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_RED, "[SERVER]: You need to be the driver of the vehicle to remove the mods.");
  1402.  
  1403.     new vehicleid = GetPlayerVehicleID(playerid);
  1404.     if(IsTempVehicle(vehicleid)) return SendClientMessage(playerid, COLOR_RED, "[SERVER]: This is a temporary vehicle and cannot be parked!");
  1405.  
  1406.     if(!isOwner(playerid, vehicleid) && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[SERVER]: You are not the owner of this vehicle.");
  1407.     if(isVehicleForSale(vehicleid) && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[SERVER]: You are not the owner of this vehicle.");
  1408.  
  1409.     new vid = GetVID(vehicleid);
  1410.     for(new i = 0; i < 17; i++) {
  1411.         if(VehicleInfo[vid][vMod][i] != 0) {
  1412.             RemoveVehicleComponent(vehicleid, VehicleInfo[vid][vMod][i]);
  1413.             VehicleInfo[vid][vMod][i] = 0;
  1414.         }
  1415.     }
  1416.  
  1417.     ChangeVehiclePaintjob(vehicleid, 3);
  1418.     VehicleInfo[vid][vPaintjob] = -1;
  1419.  
  1420.     SendClientMessage(playerid, COLOR_LAWNGREEN, "[SERVER]: You have removed all the mods from this vehicle.");
  1421.     SaveVehicle(vid);
  1422.     return 1;
  1423. }
  1424.  
  1425. CMD:vplate(playerid, params[]) {
  1426.     if(!PlayerInfo[playerid][pAllowed]) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not allowed to use this command right now.");
  1427.     if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You need to be in a vehicle to use this command.");
  1428.     if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You need to be the driver of the vehicle to park.");
  1429.  
  1430.     new vehicleid = GetPlayerVehicleID(playerid);
  1431.     new vid = GetVID(vehicleid);
  1432.  
  1433.     if(IsTempVehicle(vehicleid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: This is a temporary vehicle and it's plate cannot be changed.");
  1434.     if(VehicleInfo[vid][vIsSelling]) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: This vehicle has been offered to someone. Please wait.");
  1435.     if(!isOwner(playerid, vehicleid) && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not the owner of this vehicle");
  1436.  
  1437.     new plate[10];
  1438.     if(sscanf(params,"s[32]",plate)) return SendClientMessage(playerid,COLOR_DODGERBLUE,"[USAGE]: /vplate [PLATE] ");
  1439.     if(strlen(plate) > 9) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: Vehicle plate must be a maximum of 9 characters.");
  1440.  
  1441.     new buffer[10];
  1442.     strcpy(buffer, plate);
  1443.     strcpy(VehicleInfo[vid][vPlate], buffer, 10);
  1444.  
  1445.     SetVehicleNumberPlate(vehicleid, VehicleInfo[vid][vPlate]);
  1446.     RemovePlayerFromVehicle(playerid);
  1447.     SaveVehicle(vid);
  1448.  
  1449.     SendClientMessage(playerid, COLOR_LAWNGREEN, "[SERVER]: You have succesfully changed this vehicle's plate.");
  1450.     SetTimerEx("PlateSet", 3000, false, "i", vehicleid);
  1451.     return 1;
  1452. }
  1453.  
  1454. CMD:vbuy(playerid, params[]) {
  1455.     if(!PlayerInfo[playerid][pAllowed]) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not allowed to use this command right now.");
  1456.     if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You need to be in a vehicle to use this command.");
  1457.     if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You need to be the driver of the vehicle to buy the vehicle.");
  1458.  
  1459.     new vehicleid = GetPlayerVehicleID(playerid);
  1460.     new vid = GetVID(vehicleid);
  1461.  
  1462.     if(IsTempVehicle(vehicleid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: This is a temporary vehicle and cannot be purchased.");
  1463.     if(isOwner(playerid, vehicleid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You already own this vehicle.");
  1464.     if(!isVehicleForSale(vid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: This vehicle is not for sale.");
  1465.  
  1466.     if(IsSlotsFull(playerid)) {
  1467.         new string[64];
  1468.         format(string, sizeof(string), "You already own %d vehicles.", MAX_OWNABLE_VEHICLES);
  1469.         return SendClientMessage(playerid, COLOR_RED, string);
  1470.     }
  1471.  
  1472.     if(VehicleInfo[vid][vPrice] > GetPlayerMoney(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You don't have enough cash to buy this vehicle.");
  1473.  
  1474.     new slot = GetPlayerFreeSlot(playerid);
  1475.  
  1476.     VehicleInfo[vid][isOwned] = true;
  1477.     VehicleInfo[vid][vBuyable] = false;
  1478.  
  1479.     new name[MAX_PLAYER_NAME], string[100];
  1480.     GetPlayerName(playerid, name, sizeof(name));
  1481.     strcpy(VehicleInfo[vid][vOwner], name, MAX_PLAYER_NAME);
  1482.  
  1483.     PlayerInfo[playerid][pVSlot][slot] = vid;
  1484.     PlayerInfo[playerid][pTotalVehs]++;
  1485.     GivePlayerMoney(playerid, -VehicleInfo[vid][vPrice]);
  1486.  
  1487.     format(string ,sizeof(string), "[SERVER]: You have succesfully purchased this %s for $%d in Slot %i.", GetVehicleName(vehicleid), VehicleInfo[vid][vPrice], slot+1);
  1488.     SendClientMessage(playerid, COLOR_LAWNGREEN, string);
  1489.     SaveVehicle(vid);
  1490.     SavePlayer(playerid);
  1491.     return 1;
  1492. }
  1493.  
  1494. CMD:vsell(playerid, params[]) {
  1495.     if(!PlayerInfo[playerid][pAllowed]) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not allowed to use this command right now.");
  1496.     if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You need to be in a vehicle to use this command.");
  1497.     if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You need to be the driver of the vehicle to buy the vehicle.");
  1498.  
  1499.     new vehicleid = GetPlayerVehicleID(playerid);
  1500.     new vid = GetVID(vehicleid);
  1501.  
  1502.     if(IsTempVehicle(vehicleid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: This is a temporary vehicle and cannot be sold.");
  1503.     if(VehicleInfo[vid][vIsSelling]) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: This vehicle has been offered to someone. Please wait");
  1504.     if(!isOwner(playerid, vehicleid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You don't own this vehicle.");
  1505.  
  1506.     new slot = GetVehicleSlot(playerid, vehicleid);
  1507.  
  1508.     VehicleInfo[vid][isOwned] = false;
  1509.     VehicleInfo[vid][vBuyable] = true;
  1510.  
  1511.     strcpy(VehicleInfo[vid][vOwner], DEFAULT_OWNER, MAX_PLAYER_NAME);
  1512.  
  1513.     PlayerInfo[playerid][pVSlot][slot] = 0;
  1514.     PlayerInfo[playerid][pTotalVehs]--;
  1515.     GivePlayerMoney(playerid, VehicleInfo[vid][vPrice]);
  1516.     RemovePlayerFromVehicle(playerid);
  1517.     new string[128];
  1518.  
  1519.     format(string ,sizeof(string), "[ERROR]: You have succesfully sold your %s. $%d has been credited to you.", GetVehicleName(vehicleid), VehicleInfo[vid][vPrice]);
  1520.     SendClientMessage(playerid, COLOR_LAWNGREEN, string);
  1521.     SaveVehicle(vid);
  1522.     SavePlayer(playerid);
  1523.     return 1;
  1524. }
  1525.  
  1526. CMD:vcall(playerid, params[]) {
  1527.     if(!PlayerInfo[playerid][pAllowed]) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not allowed to use this command right now.");
  1528.     if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You already have a vehicle.");
  1529.  
  1530.     new slot, string[100];
  1531.     format(string, sizeof(string), "USAGE: /vcall [1-%i]", MAX_OWNABLE_VEHICLES);
  1532.     if(sscanf(params,"i",slot)) return SendClientMessage(playerid, COLOR_RED, string);
  1533.  
  1534.     if(slot < 1 || slot > MAX_OWNABLE_VEHICLES) return SendClientMessage(playerid, COLOR_RED, string);
  1535.  
  1536.     slot = slot - 1;
  1537.  
  1538.     if(PlayerInfo[playerid][pVSlot][slot] == 0) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You don't have any vehicle in that slot.");
  1539.  
  1540.     new vehicleid = GetVehicleID(PlayerInfo[playerid][pVSlot][slot]);
  1541.  
  1542.     if(teleport_time == 0) {
  1543.         TeleportVehicleInfront(playerid, vehicleid);
  1544.     } else {
  1545.         new string2[128];
  1546.         SetTimerEx("TeleportVehicleInfront", TELEPORT_TIME*1000, false, "ii", playerid, vehicleid);
  1547.         format(string2, sizeof(string2), "[SERVER]: Your %s has been called. It should take about %i seconds to get to you.", GetVehicleName(vehicleid), TELEPORT_TIME);
  1548.         SendClientMessage(playerid, COLOR_ORANGE, string2);
  1549.     }
  1550.     return 1;
  1551. }
  1552.  
  1553. CMD:vlist(playerid, params[]) {
  1554.     if(!PlayerInfo[playerid][pAllowed]) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not allowed to use this command right now.");
  1555.     new targetid;
  1556.     if(!sscanf(params,"u",targetid)) {
  1557.         if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"[ERROR]: That player is not connected");
  1558.     } else {
  1559.         targetid = playerid;
  1560.     }
  1561.  
  1562.     new mainstring[MAX_OWNABLE_VEHICLES*50];
  1563.  
  1564.     for(new i = 0; i < MAX_OWNABLE_VEHICLES; i++) {
  1565.         new string[64], string2[64];
  1566.         if(PlayerInfo[targetid][pVSlot][i] == 0) {
  1567.             format(string2, sizeof(string2), "<Slot Empty>");
  1568.         } else {
  1569.             new vehicleid = GetVehicleID(PlayerInfo[targetid][pVSlot][i]);
  1570.             new vid = GetVID(vehicleid);
  1571.             format(string2, sizeof(string2), "%s {FFD700}(ID:%i)", GetVehicleName(vehicleid), VehicleInfo[vid][vID]);
  1572.         }
  1573.        
  1574.         format(string ,sizeof(string), "{FFD700}Slot %i: {FFFFFF}%s\n", i+1, string2);
  1575.  
  1576.         strcat(mainstring, string, sizeof(mainstring));
  1577.     }
  1578.     new name[MAX_PLAYER_NAME], title[100];
  1579.     GetPlayerName(targetid, name, sizeof(name));
  1580.     format(title, sizeof(title), "{FFD700}%s's {FFFFFF}Vehicles", name);
  1581.     ShowPlayerDialog(playerid, DIALOG_VLIST, DIALOG_STYLE_MSGBOX, title, mainstring, "Okay", "");
  1582.     return 1;
  1583. }
  1584.  
  1585. CMD:vsecure(playerid, params[]) {
  1586.     if(!PlayerInfo[playerid][pAllowed]) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not allowed to use this command right now.");
  1587.    
  1588.     if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You need to be in a vehicle to use this command.");
  1589.     if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You need to be the driver of the vehicle to secure the vehicle");
  1590.  
  1591.     new vehicleid = GetPlayerVehicleID(playerid);
  1592.     new vid = GetVID(vehicleid);
  1593.  
  1594.     if(IsTempVehicle(vehicleid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: This is a temporary vehicle.");
  1595.     if(VehicleInfo[vid][vIsSelling]) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: This vehicle has been offered to someone. Please wait");
  1596.     if(!isOwner(playerid, vehicleid) && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You don't own this vehicle.");
  1597.  
  1598.     new string[100], string2[100];
  1599.     if(VehicleInfo[vid][Secure]) {
  1600.         VehicleInfo[vid][Secure] = false;
  1601.         strcpy(string, "is no longer secure.", sizeof(string));
  1602.     } else {
  1603.         VehicleInfo[vid][Secure] = true;
  1604.         strcpy(string, "has been secured.", sizeof(string));
  1605.     }
  1606.  
  1607.     format(string2, sizeof(string2), "[SERVER]: This %s %s",  GetVehicleName(vehicleid), string);
  1608.     SendClientMessage(playerid, COLOR_LAWNGREEN, string2);
  1609.     return 1;
  1610. }
  1611.  
  1612. CMD:vsellto(playerid, params[]) {
  1613.     if(!PlayerInfo[playerid][pAllowed]) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not allowed to use this command right now.");
  1614.     if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You need to be in a vehicle to use this command.");
  1615.     if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You need to be the driver of the vehicle to sell the vehicle.");
  1616.  
  1617.     new vehicleid = GetPlayerVehicleID(playerid);
  1618.     new vid = GetVID(vehicleid);
  1619.     if(VehicleInfo[vid][vIsSelling]) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: This vehicle is already for sale.");
  1620.     if(IsTempVehicle(vehicleid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: This is a temporary vehicle and cannot be sold!");
  1621.  
  1622.     if(!isOwner(playerid, vehicleid) && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not the owner of this vehicle.");
  1623.     if(isVehicleForSale(vehicleid) && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not the owner of this vehicle.");
  1624.  
  1625.     if(PlayerInfo[playerid][sTo] != -1) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are already selling a vehicle, please wait till that process is completed.");
  1626.  
  1627.     new targetid, price;
  1628.     if(sscanf(params,"ud", targetid, price)) return SendClientMessage(playerid, COLOR_RED, "[USAGE]: /vsellto [playerid] [price]");
  1629.     if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: Invalid Player ID.");
  1630.     if(targetid == playerid) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You cannot sell the vehicle to yourself.");
  1631.     if(!PlayerInfo[targetid][pAllowed] || (PlayerInfo[targetid][sFrom] != -1)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: That player cannot recieve any offers at the moment.");
  1632.     if(price < 0) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: Invalid Price");
  1633.  
  1634.     PlayerInfo[playerid][sTo] = targetid;
  1635.     PlayerInfo[playerid][svID] = vid;
  1636.     PlayerInfo[targetid][sFrom] = playerid;
  1637.     VehicleInfo[vid][vIsSelling] = true;
  1638.     VehicleInfo[vid][vSellingPrice] = price;
  1639.  
  1640.     SellingTimer[playerid] = SetTimerEx("KillSale", 60000, false, "ii", playerid, targetid);
  1641.  
  1642.     new string[256], string2[256];
  1643.     format(string, sizeof(string), "[SERVER]: You have decided to sell your %s to %s for $%d. Awaiting conformation from %s. Your request will timeout in 60 seconds.", GetVehicleName(vehicleid), GetName(targetid), price, GetName(targetid));
  1644.     format(string2, sizeof(string2), "[SERVER]: %s has decided to sell his %s to you for $%d. Type /vaccept to accept his offer. This request will time out in 60 seconds.", GetName(playerid), GetVehicleName(vehicleid), price);
  1645.     SendClientMessage(playerid, COLOR_DODGERBLUE, string);
  1646.     SendClientMessage(targetid, COLOR_DODGERBLUE, string2);
  1647.     return 1;
  1648. }
  1649.  
  1650. CMD:vaccept(playerid, params[]) {
  1651.     if(!PlayerInfo[playerid][pAllowed]) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not allowed to use this command right now.");
  1652.     if(PlayerInfo[playerid][sFrom] == -1) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: No one's selling you any vehicle.");
  1653.  
  1654.     new ownerid = PlayerInfo[playerid][sFrom];
  1655.  
  1656.     if(IsSlotsFull(playerid)) {
  1657.         new string[64];
  1658.         format(string, sizeof(string), "[ERROR]: You already own %d vehicles.", MAX_OWNABLE_VEHICLES);
  1659.         return SendClientMessage(playerid, COLOR_RED, string);
  1660.     }
  1661.  
  1662.     new vid = PlayerInfo[ownerid][svID];
  1663.     if(VehicleInfo[vid][vSellingPrice] > GetPlayerMoney(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You don't have enough money to accept this offer.");
  1664.  
  1665.     new buffer1[MAX_PLAYER_NAME], string[256], string2[256];
  1666.  
  1667.     strcpy(buffer1, GetName(playerid), MAX_PLAYER_NAME);
  1668.     strcpy(VehicleInfo[vid][vOwner], buffer1, MAX_PLAYER_NAME);
  1669.  
  1670.     new pslot = GetPlayerFreeSlot(playerid);
  1671.     PlayerInfo[playerid][pVSlot][pslot] = vid;
  1672.  
  1673.     new oslot = GetSlotFromVehicle(ownerid, vid);
  1674.     PlayerInfo[ownerid][pVSlot][oslot] = 0;
  1675.  
  1676.     PlayerInfo[playerid][pTotalVehs]++;
  1677.     PlayerInfo[ownerid][pTotalVehs]--;
  1678.  
  1679.     GivePlayerMoney(ownerid, VehicleInfo[vid][vSellingPrice]);
  1680.     GivePlayerMoney(playerid, -VehicleInfo[vid][vSellingPrice]);
  1681.     VehicleInfo[vid][vIsSelling] = false;
  1682.     VehicleInfo[vid][vSellingPrice] = 0;
  1683.  
  1684.     KillTimer(SellingTimer[ownerid]);
  1685.  
  1686.     new vehicleid = GetVehicleID(vid);
  1687.     format(string, sizeof(string), "[SERVER]: You have succefully sold your %s to %s.", GetVehicleName(vehicleid), GetName(playerid));
  1688.     format(string2, sizeof(string2), "[SERVER]: You have succefully bought a %s from %s, Enjoy your new vehicle.",  GetVehicleName(vehicleid), GetName(ownerid));
  1689.  
  1690.     SendClientMessage(ownerid, COLOR_LAWNGREEN, string);
  1691.     SendClientMessage(playerid, COLOR_LAWNGREEN, string2);
  1692.  
  1693.     SaveVehicle(vid);
  1694.     SavePlayer(playerid);
  1695.     SavePlayer(ownerid);
  1696.     return 1;
  1697. }
  1698.  
  1699. CMD:vbuyable(playerid, params[]) {
  1700.     if(!PlayerInfo[playerid][pAllowed]) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not allowed to use this command right now. ");
  1701.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not authorized to use that command..");
  1702.     if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You need to be in a vehicle to use this command.");
  1703.     new vehicleid = GetPlayerVehicleID(playerid);
  1704.     new vid = GetVID(vehicleid);
  1705.     if(IsTempVehicle(vehicleid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: This is a temporary vehicle");
  1706.     if(VehicleInfo[vid][isOwned]) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: This vehicle is owned by someone.");
  1707.     if(VehicleInfo[vid][vIsSelling]) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: This vehicle has been offered to someone.");
  1708.    
  1709.     new string[15], string2[128];
  1710.     if(VehicleInfo[vid][vBuyable]) {
  1711.         VehicleInfo[vid][vBuyable] = false;
  1712.         strcpy(string, "unbuyable", sizeof(string));
  1713.     } else {
  1714.         VehicleInfo[vid][vBuyable] = true;
  1715.         strcpy(string, "buyable", sizeof(string));
  1716.     }
  1717.  
  1718.     format(string2, sizeof(string2), "[SERVER]: You have succesfully set this %s as %s", GetVehicleName(vehicleid), string);
  1719.     SendClientMessage(playerid, COLOR_LAWNGREEN, string2);
  1720.     SaveVehicle(vid);
  1721.     return 1;
  1722. }
  1723.  
  1724. CMD:vsetprice(playerid, params[]) {
  1725.     if(!PlayerInfo[playerid][pAllowed]) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not allowed to use this command right now.");
  1726.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not authorized to use that command..");
  1727.     if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You need to be in a vehicle to use this command.");
  1728.     new vehicleid = GetPlayerVehicleID(playerid);
  1729.     new vid = GetVID(vehicleid);
  1730.     if(IsTempVehicle(vehicleid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: This is a temporary vehicle");
  1731.     if(VehicleInfo[vid][vIsSelling]) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: This vehicle has been offered to someone.");
  1732.    
  1733.     new price, string[256];
  1734.     if(sscanf(params, "d", price)) return SendClientMessage(playerid, COLOR_DODGERBLUE, "[USAGE]: /vsetprice [price]");
  1735.     if(price == VehicleInfo[vid][vPrice]){
  1736.         new string2[100];
  1737.         format(string2, sizeof(string2), "[ERROR]: This cost of this vehicle is already $%d.", VehicleInfo[vid][vPrice]);
  1738.         return SendClientMessage(playerid, COLOR_RED, string2);
  1739.     }
  1740.     if(price < 1) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: Price should be atleast $1");
  1741.  
  1742.     VehicleInfo[vid][vPrice] = price;
  1743.  
  1744.     format(string, sizeof(string), "[SERVER]: You have succesfully set this %s's price to $%d.", GetVehicleName(vehicleid), price);
  1745.     SendClientMessage(playerid, COLOR_LAWNGREEN, string);
  1746.     SaveVehicle(vid);
  1747.     return 1;
  1748. }
  1749.  
  1750.  
  1751. CMD:vhelp(playerid, params[]) {
  1752.     if(!PlayerInfo[playerid][pAllowed]) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You are not allowed to use this command right now.");
  1753.     new hdialog[1000];
  1754.     strcat(hdialog, "{FFD700}/vbuy  - {FFFFFF}buys a vehicle.\n", sizeof(hdialog));
  1755.     strcat(hdialog, "{FFD700}/vsell - {FFFFFF}sells your vehicle.\n", sizeof(hdialog));
  1756.     strcat(hdialog, "{FFD700}/vcall - {FFFFFF}calls your vehicle.\n", sizeof(hdialog));
  1757.     strcat(hdialog, "{FFD700}/vpark - {FFFFFF}parks your vehicle.\n", sizeof(hdialog));
  1758.     strcat(hdialog, "{FFD700}/vinfo - {FFFFFF}shows vehicle info.\n", sizeof(hdialog));
  1759.     strcat(hdialog, "{FFD700}/vlist [ID] - {FFFFFF}shows vehicle list.\n", sizeof(hdialog));
  1760.     strcat(hdialog, "{FFD700}/vplate - {FFFFFF}changes your vehicle plate.\n", sizeof(hdialog));
  1761.     strcat(hdialog, "{FFD700}/vsellto - {FFFFFF}sells your vehicle to a specific player.\n", sizeof(hdialog));
  1762.     strcat(hdialog, "{FFD700}/vaccept - {FFFFFF}accepts a vehicle if you've been offered one.\n", sizeof(hdialog));
  1763.     strcat(hdialog, "{FFD700}/vsecure - {FFFFFF}secures/unsecures your vehicle.\n", sizeof(hdialog));
  1764.     strcat(hdialog, "{FFD700}/clearmods - {FFFFFF}clears your vehicle mods.\n", sizeof(hdialog));
  1765.  
  1766.     if(IsPlayerAdmin(playerid)) {
  1767.         strcat(hdialog, "\t\t{FFD700}-Admin {FFFFFF}Commands-\n", sizeof(hdialog));
  1768.         strcat(hdialog, "{FFD700}/vcreate - {FFFFFF}creates a vehicle.\n", sizeof(hdialog));   
  1769.         strcat(hdialog, "{FFD700}/vremove - {FFFFFF}removes a vehicle.\n", sizeof(hdialog));
  1770.         strcat(hdialog, "{FFD700}/vbuyable - {FFFFFF}sets a vehicle to buyable/unbuyable.\n", sizeof(hdialog));
  1771.         strcat(hdialog, "{FFD700}/vsetprice - {FFFFFF}sets a vehicle price.\n", sizeof(hdialog));
  1772.         strcat(hdialog, "{FFD700}/rac - {FFFFFF}respawns all cars.\n", sizeof(hdialog));
  1773.         strcat(hdialog, "{FFD700}/vgoto - {FFFFFF}go to a vehicle.\n", sizeof(hdialog));
  1774.     }
  1775.  
  1776.     ShowPlayerDialog(playerid, DIALOG_VHELP, DIALOG_STYLE_MSGBOX, "{FFD700}Vehicle {FFFFFF}Help", hdialog, "Okay", "");
  1777.     return 1;
  1778. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement