Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********************************
- ++ Created by Bondowocopz ++
- ++ Credits to all samp players ++
- ++ Vehicle System for ++
- ++ MySQL R39-2 ++
- ********************************/
- #include <a_samp>
- #include <a_mysql>
- #include <streamer>
- #include <vsystem/formatnumber>
- #include <vsystem/zcmd>
- #define HOST "localhost"
- #define USER "bondowocopz"
- #define PASSWORD "bondowocopz"
- #define DBNAME "filterscript"
- #define MAX_VEH 500
- #define MAX_PLAYER_VEHICLES 5
- #define DEFAULT_NUMBER_PLATE "CCNR"
- #define SPORTVEHICLES 0
- #define SALOONS 1
- #define BIKES 2
- #define UNIQUE 3
- #define INDUSTRIAL 4
- #define LOWRIDER 5
- #define OFFROAD 6
- #define AIR 7
- #define DIALOG_BUYCAR 1
- #define DIALOG_DEALERSHIP 2
- #define DIALOG_VCP 3
- #define DIALOG_CHANGEPLATE 4
- #define DIALOG_CHANGECOLOR 5
- #define DIALOG_CHANGECOLOR2 6
- #define DIALOG_MYVEHICLES 7
- #define DIALOG_MYVEHICLES2 8
- #define DIALOG_SALESERVER 9
- #define DIALOG_VSELL 10
- #define DIALOG_VSELL2 11
- #define DIALOG_CONFVS 12
- #define DIALOG_CONFIRMVSELL 13
- #define DIALOG_UNUSED 14
- #define CHAT_YELLOW "{FFFF00}"
- #define CHAT_WHITE "{FFFFFF}"
- #define CHAT_SERVER "{808080}"
- #define CHAT_RED "{FF0000}"
- #define COLOR_WHITE 0xFFFFFFFF
- new koneksi = -1, buycarCP, Text:buycarTD[4],
- Float:dealX = -1663.640014, Float:dealY = 1208.253662, Float:dealZ = 7.254645,
- GPSObject[MAX_PLAYERS];
- new Float:airX = -1665.9714,
- Float:airY = 1210.7313,
- Float:airZ = 32.9239,
- Float:airA = 280.6097; // Change this for Helicopter & Plane Spawn
- new Float:normalX = -1643.3745,
- Float:normalY = 1213.0620,
- Float:normalZ = 6.8095,
- Float:normalA = 225.2126; // Change this for normal car spawn
- enum __vehicleInfo
- {
- bool:vehStatus,
- vehID,
- vehModel,
- Float:vehPos[4],
- vehColor[2],
- vehInt,
- vehVW,
- vehOwner[MAX_PLAYER_NAME],
- bool:vehLock,
- bool:vehAlarm,
- vehicleData,
- vehPlate[16],
- vehMods[14],
- vehPaint
- }
- new Vehicles[MAX_VEH][__vehicleInfo];
- enum __dealerInfo
- {
- dialogID,
- dealerModel,
- dealerPrice,
- dealerType
- }
- new Dealership[][__dealerInfo] =
- {
- {0, 451, 3000000, SPORTVEHICLES},
- {1, 411, 3000000, SPORTVEHICLES},
- {2, 415, 3000000, SPORTVEHICLES},
- {3, 402, 3000000, SPORTVEHICLES},
- {4, 541, 3000000, SPORTVEHICLES},
- {5, 477, 3000000, SPORTVEHICLES},
- {6, 603, 3000000, SPORTVEHICLES},
- {7, 565, 4000000, SPORTVEHICLES},
- {8, 429, 3000000, SPORTVEHICLES},
- {9, 506, 3000000, SPORTVEHICLES},
- {10, 589, 3000000, SPORTVEHICLES},
- {11, 559, 4000000, SPORTVEHICLES},
- {0, 560, 3000000, SALOONS},
- {1, 562, 3000000, SALOONS},
- {2, 426, 1500000, SALOONS},
- {3, 516, 1500000, SALOONS},
- {4, 518, 1500000, SALOONS},
- {5, 526, 1500000, SALOONS},
- {6, 550, 1500000, SALOONS},
- {7, 540, 1500000, SALOONS},
- {8, 542, 750000, SALOONS},
- {9, 547, 1500000, SALOONS},
- {10, 434, 750000, SALOONS},
- {0, 522, 5000000, BIKES},
- {1, 463, 2000000, BIKES},
- {2, 468, 1000000, BIKES},
- {3, 471, 1000000, BIKES},
- {4, 462, 500000, BIKES},
- {5, 481, 100000, BIKES},
- {0, 556, 7000000, UNIQUE},
- {1, 557, 7000000, UNIQUE},
- {2, 539, 5000000, UNIQUE},
- {3, 588, 1000000, UNIQUE},
- {4, 571, 5000000, UNIQUE},
- {5, 572, 500000, UNIQUE},
- {6, 508, 1000000, UNIQUE},
- {7, 457, 500000, UNIQUE},
- {0, 455, 250000, INDUSTRIAL},
- {1, 456, 250000, INDUSTRIAL},
- {2, 499, 250000, INDUSTRIAL},
- {3, 482, 500000, INDUSTRIAL},
- {4, 543, 500000, INDUSTRIAL},
- {5, 478, 200000, INDUSTRIAL},
- {0, 412, 1000000, LOWRIDER},
- {1, 534, 1000000, LOWRIDER},
- {2, 535, 1000000, LOWRIDER},
- {3, 536, 1000000, LOWRIDER},
- {4, 566, 1000000, LOWRIDER},
- {5, 567, 1000000, LOWRIDER},
- {6, 576, 1000000, LOWRIDER},
- {7, 575, 1000000, LOWRIDER},
- {0, 489, 750000, OFFROAD},
- {1, 495, 750000, OFFROAD},
- {2, 579, 750000, OFFROAD},
- {3, 400, 750000, OFFROAD},
- {0, 469, 15000000, AIR},
- {1, 487, 15000000, AIR},
- {2, 513, 15000000, AIR}
- };
- enum _playerStats
- {
- carVCP,
- dealershipChoice,
- timerSpeed,
- vsellTo,
- vsellPrice,
- vsellFrom,
- vsellCar
- }
- new Player[MAX_PLAYERS][_playerStats];
- new namaCar[213][] =
- {
- {"Landstalker"}, {"Bravura"}, {"Buffalo"}, {"Linerunner"}, {"Perrenial"}, {"Sentinel"}, {"Dumper"}, {"Firetruck"}, {"Trashmaster"}, {"Stretch"},
- {"Manana"}, {"Infernus"}, {"Voodoo"}, {"Pony"}, {"Mule"}, {"Cheetah"}, {"Ambulance"}, {"Leviathan"}, {"Moonbeam"}, {"Esperanto"},
- {"Taxi"}, {"Washington"}, {"Bobcat"}, {"Mr Whoopee"}, {"BF Injection"}, {"Hunter"}, {"Premier"}, {"Enforcer"}, {"Securicar"}, {"Banshee"},
- {"Predator"}, {"Bus"}, {"Rhino"}, {"Barracks"}, {"Hotknife"}, {"Trailer 1"}, {"Previon"}, {"Coach"}, {"Cabbie"}, {"Stallion"},
- {"Rumpo"}, {"RC Bandit"}, {"Romero"}, {"Packer"}, {"Monster"}, {"Admiral"}, {"Squalo"}, {"Seasparrow"}, {"Pizzaboy"}, {"Tram"},
- {"Trailer 2"}, {"Turismo"}, {"Speeder"}, {"Reefer"}, {"Tropic"}, {"Flatbed"}, {"Yankee"}, {"Caddy"}, {"Solair"}, {"Berkley's RC Van"},
- {"Skimmer"}, {"PCJ-600"}, {"Faggio"}, {"Freeway"}, {"RC Baron"}, {"RC Raider"}, {"Glendale"}, {"Oceanic"}, {"Sanchez"}, {"Standard Sparrow"},
- {"Patriot"}, {"Quad"}, {"Coastguard"}, {"Dinghy"}, {"Hermes"}, {"Sabre"}, {"Rustler"}, {"ZR-350"}, {"Walton"}, {"Regina"},
- {"Comet"}, {"BMX"}, {"Burrito"}, {"Camper"}, {"Marquis"}, {"Baggage"}, {"Dozer"}, {"Maverick"}, {"News Chopper"}, {"Rancher"},
- {"FBI Rancher"}, {"Virgo"}, {"Greenwood"}, {"Jetmax"}, {"Hotring"}, {"Sandking"}, {"Blista Compact"}, {"Police Maverick"}, {"Boxville"}, {"Benson"},
- {"Mesa"}, {"RC Goblin"}, {"Hotring Racer A"}, {"Hotring Racer B"}, {"Bloodring Banger"}, {"Rancher"}, {"Super GT"}, {"Elegant"}, {"Journey"}, {"Bike"},
- {"Mountain Bike"}, {"Beagle"}, {"Cropdust"}, {"Stunt Plane"}, {"Tanker"}, {"Roadtrain"}, {"Nebula"}, {"Majestic"}, {"Buccaneer"}, {"Shamal"},
- {"Hydra"}, {"FCR-900"}, {"NRG-500"}, {"HPV1000"}, {"Cement Truck"}, {"Tow Truck"}, {"Fortune"}, {"Cadrona"}, {"FBI Truck"}, {"Willard"},
- {"Forklift"}, {"Tractor"}, {"Combine"}, {"Feltzer"}, {"Remington"}, {"Slamvan"}, {"Blade"}, {"Freight"}, {"Streak"}, {"Vortex"},
- {"Vincent"}, {"Bullet"}, {"Clover"}, {"Sadler"}, {"Firetruck LA"}, {"Hustler"}, {"Intruder"}, {"Primo"}, {"Cargobob"}, {"Tampa"},
- {"Sunrise"}, {"Merit"}, {"Utility"}, {"Nevada"}, {"Yosemite"}, {"Windsor"}, {"Monster A"}, {"Monster B"}, {"Uranus"}, {"Jester"},
- {"Sultan"}, {"Stratum"}, {"Elegy"}, {"Raindance"}, {"RC Tiger"}, {"Flash"}, {"Tahoma"}, {"Savanna"}, {"Bandito"}, {"Freight Flat"},
- {"Streak Carriage"}, {"Kart"}, {"Mower"}, {"Duneride"}, {"Sweeper"}, {"Broadway"}, {"Tornado"}, {"AT-400"}, {"DFT-30"}, {"Huntley"},
- {"Stafford"}, {"BF-400"}, {"Newsvan"}, {"Tug"}, {"Trailer 3"}, {"Emperor"}, {"Wayfarer"}, {"Euros"}, {"Hotdog"}, {"Club"},
- {"Freight Carriage"}, {"Trailer 3"}, {"Andromada"}, {"Dodo"}, {"RC Cam"}, {"Launch"}, {"Police Car (LSPD)"}, {"Police Car (SFPD)"}, {"Police Car (LVPD)"}, {"Police Ranger"},
- {"Picador"}, {"S.W.A.T. Van"}, {"Alpha"}, {"Phoenix"}, {"Glendale"}, {"Sadler"}, {"Luggage Trailer A"}, {"Luggage Trailer B"}, {"Stair Trailer"}, {"Boxville"},
- {"Farm Plow"}, {"Utility Trailer"}, {"Jetpack"}
- };
- stock GetName(playerid)
- {
- new pName[24];
- GetPlayerName(playerid, pName, 24);
- return pName;
- }
- stock loadVehicles(playerid)
- {
- new query[128];
- Player[playerid][carVCP] = -1;
- Player[playerid][dealershipChoice] = -1;
- Player[playerid][timerSpeed] = -1;
- Player[playerid][vsellTo] = INVALID_PLAYER_ID;
- Player[playerid][vsellPrice] = -1;
- Player[playerid][vsellFrom] = INVALID_PLAYER_ID;
- Player[playerid][vsellCar] = -1;
- mysql_format(koneksi, query, sizeof(query), "SELECT * FROM `vehicle` where `owner` = '%s'", GetName(playerid));
- mysql_tquery(koneksi, query, "OnPlayerLoadVehicles", "d", playerid);
- return 1;
- }
- stock createVehicle(vehicleid, bool:removeold = false)
- {
- if(removeold)
- {
- DestroyVehicle(Vehicles[vehicleid][vehicleData]);
- }
- Vehicles[vehicleid][vehicleData] = CreateVehicle(Vehicles[vehicleid][vehModel], Vehicles[vehicleid][vehPos][0], Vehicles[vehicleid][vehPos][1], Vehicles[vehicleid][vehPos][2], Vehicles[vehicleid][vehPos][3], Vehicles[vehicleid][vehColor][0], Vehicles[vehicleid][vehColor][1], 360000);
- SetVehicleNumberPlate(Vehicles[vehicleid][vehicleData], Vehicles[vehicleid][vehPlate]);
- LinkVehicleToInterior(Vehicles[vehicleid][vehicleData], Vehicles[vehicleid][vehInt]);
- SetVehicleVirtualWorld(Vehicles[vehicleid][vehicleData], Vehicles[vehicleid][vehVW]);
- for(new i = 0; i < 14; i++)
- {
- AddVehicleComponent(Vehicles[vehicleid][vehicleData], Vehicles[vehicleid][vehMods][i]);
- }
- ChangeVehicleColor(Vehicles[vehicleid][vehicleData], Vehicles[vehicleid][vehColor][0], Vehicles[vehicleid][vehColor][1]);
- ChangeVehiclePaintjob(Vehicles[vehicleid][vehicleData], Vehicles[vehicleid][vehPaint]);
- return 1;
- }
- stock showDealership(playerid, category)
- {
- new msg2[1000];
- Player[playerid][dealershipChoice] = category;
- for(new i = 0; i < sizeof(Dealership); i++)
- {
- if(Dealership[i][dealerType] == category)
- {
- format(msg2, sizeof(msg2), "%s\n%s "CHAT_YELLOW"$%s {FFFFFF}", msg2, namaCar[Dealership[i][dealerModel] - 400], FormatNumber(Dealership[i][dealerPrice]));
- }
- }
- ShowPlayerDialog(playerid, DIALOG_DEALERSHIP, DIALOG_STYLE_LIST, "Bondowocopz Dealership - Choose Car", msg2, "Buy", "Cancel");
- return 1;
- }
- stock __createVehicle(model, playerid, Float:x, Float:y, Float:z, Float:a)
- {
- new query[512];
- mysql_format(koneksi, query, sizeof(query), "INSERT INTO `vehicle` (`owner`, `model`, `posX`, `posY`, `posZ`, `posA`) VALUES ('%s', '%d', '%f', '%f', '%f', '%f')", GetName(playerid), model, x, y, z, a);
- mysql_tquery(koneksi, query, "OnSavedVehicleCreated", "ddffff", model, playerid, x, y, z, a);
- return 1;
- }
- stock giveMoney(playerid, amount)
- {
- return GivePlayerMoney(playerid, GetPlayerMoney(playerid) - amount);
- }
- stock takeMoney(playerid, amount)
- {
- return GivePlayerMoney(playerid, GetPlayerMoney(playerid) + amount);
- }
- stock Server(playerid, message[])
- {
- new pesan[200];
- format(pesan, sizeof(pesan), ""CHAT_SERVER"[SERVER] "CHAT_WHITE"%s", message);
- return SendClientMessage(playerid, COLOR_WHITE, pesan);
- }
- stock countplayerVeh(playerid)
- {
- new query[256], count;
- mysql_format(koneksi, query, sizeof(query), "SELECT count(*) as `total` from `vehicle` where `owner` = '%s'", GetName(playerid));
- mysql_query(koneksi, query, true);
- count = cache_get_field_content_int(0, "total");
- return count;
- }
- stock initTD()
- {
- buycarTD[0] = TextDrawCreate(434.000000, 166.699996, "usebox");
- TextDrawLetterSize(buycarTD[0], 0.000000, 6.546296);
- TextDrawTextSize(buycarTD[0], 220.000000, 0.000000);
- TextDrawAlignment(buycarTD[0], 1);
- TextDrawColor(buycarTD[0], 0);
- TextDrawUseBox(buycarTD[0], true);
- TextDrawBoxColor(buycarTD[0], -1378294017);
- TextDrawSetShadow(buycarTD[0], 0);
- TextDrawSetOutline(buycarTD[0], 0);
- TextDrawFont(buycarTD[0], 0);
- buycarTD[1] = TextDrawCreate(432.000000, 168.633331, "usebox");
- TextDrawLetterSize(buycarTD[1], 0.000000, 6.046302);
- TextDrawTextSize(buycarTD[1], 222.000000, 0.000000);
- TextDrawAlignment(buycarTD[1], 1);
- TextDrawColor(buycarTD[1], 0);
- TextDrawUseBox(buycarTD[1], true);
- TextDrawBoxColor(buycarTD[1], 255);
- TextDrawSetShadow(buycarTD[1], 0);
- TextDrawSetOutline(buycarTD[1], 0);
- TextDrawFont(buycarTD[1], 0);
- buycarTD[2] = TextDrawCreate(279.000000, 168.933273, "Please Wait");
- TextDrawLetterSize(buycarTD[2], 0.569000, 2.225334);
- TextDrawAlignment(buycarTD[2], 1);
- TextDrawColor(buycarTD[2], -1);
- TextDrawSetShadow(buycarTD[2], 0);
- TextDrawSetOutline(buycarTD[2], 1);
- TextDrawBackgroundColor(buycarTD[2], 51);
- TextDrawFont(buycarTD[2], 0);
- TextDrawSetProportional(buycarTD[2], 1);
- buycarTD[3] = TextDrawCreate(236.000000, 202.533325, "Your vehicle is being created");
- TextDrawLetterSize(buycarTD[3], 0.256999, 1.198666);
- TextDrawAlignment(buycarTD[3], 1);
- TextDrawColor(buycarTD[3], -1);
- TextDrawSetShadow(buycarTD[3], 0);
- TextDrawSetOutline(buycarTD[3], 1);
- TextDrawBackgroundColor(buycarTD[3], 51);
- TextDrawFont(buycarTD[3], 2);
- TextDrawSetProportional(buycarTD[3], 1);
- return 1;
- }
- stock parkVehicles(vehicleid, int, vw)
- {
- GetVehiclePos(Vehicles[vehicleid][vehicleData], Vehicles[vehicleid][vehPos][0], Vehicles[vehicleid][vehPos][1], Vehicles[vehicleid][vehPos][2]);
- GetVehicleZAngle(Vehicles[vehicleid][vehicleData], Vehicles[vehicleid][vehPos][3]);
- Vehicles[vehicleid][vehInt] = int;
- Vehicles[vehicleid][vehVW] = vw;
- return 1;
- }
- stock destroyCar(playerid)
- {
- for(new i = 0; i < MAX_VEH; i++)
- {
- if(!Vehicles[i][vehStatus]) continue;
- if(!strcmp(Vehicles[i][vehOwner], GetName(playerid)))
- {
- saveVehicles(i);
- removeVehicle(i);
- }
- }
- return 1;
- }
- stock saveVehicles(vehicleid)
- {
- new query[1000];
- format(query, sizeof(query), "UPDATE `vehicle` set");
- format(query, sizeof(query), "%s `owner` = '%s',", query, Vehicles[vehicleid][vehOwner]);
- format(query, sizeof(query), "%s `posX` = '%f',", query, Vehicles[vehicleid][vehPos][0]);
- format(query, sizeof(query), "%s `posY` = '%f',", query, Vehicles[vehicleid][vehPos][1]);
- format(query, sizeof(query), "%s `posZ` = '%f',", query, Vehicles[vehicleid][vehPos][2]);
- format(query, sizeof(query), "%s `posA` = '%f',", query, Vehicles[vehicleid][vehPos][3]);
- if(Vehicles[vehicleid][vehLock])
- format(query, sizeof(query), "%s `locked` = '1',", query);
- else
- format(query, sizeof(query), "%s `locked` = '0',", query);
- if(Vehicles[vehicleid][vehAlarm])
- format(query, sizeof(query), "%s `alarm` = '1',", query);
- else
- format(query, sizeof(query), "%s `alarm` = '0',", query);
- format(query, sizeof(query), "%s `color1` = '%d',", query, Vehicles[vehicleid][vehColor][0]);
- format(query, sizeof(query), "%s `color2` = '%d',", query, Vehicles[vehicleid][vehColor][1]);
- format(query, sizeof(query), "%s `plate` = '%s',", query, safeString(Vehicles[vehicleid][vehPlate]));
- format(query, sizeof(query), "%s `int` = '%d',", query, Vehicles[vehicleid][vehInt]);
- format(query, sizeof(query), "%s `vw` = '%d',", query, Vehicles[vehicleid][vehVW]);
- format(query, sizeof(query), "%s `mod1` = '%d',", query, Vehicles[vehicleid][vehMods][0]);
- format(query, sizeof(query), "%s `mod2` = '%d',", query, Vehicles[vehicleid][vehMods][1]);
- format(query, sizeof(query), "%s `mod3` = '%d',", query, Vehicles[vehicleid][vehMods][2]);
- format(query, sizeof(query), "%s `mod4` = '%d',", query, Vehicles[vehicleid][vehMods][3]);
- format(query, sizeof(query), "%s `mod5` = '%d',", query, Vehicles[vehicleid][vehMods][4]);
- format(query, sizeof(query), "%s `mod6` = '%d',", query, Vehicles[vehicleid][vehMods][5]);
- format(query, sizeof(query), "%s `mod7` = '%d',", query, Vehicles[vehicleid][vehMods][6]);
- format(query, sizeof(query), "%s `mod8` = '%d',", query, Vehicles[vehicleid][vehMods][7]);
- format(query, sizeof(query), "%s `mod9` = '%d',", query, Vehicles[vehicleid][vehMods][8]);
- format(query, sizeof(query), "%s `mod10` = '%d',", query, Vehicles[vehicleid][vehMods][9]);
- format(query, sizeof(query), "%s `mod11` = '%d',", query, Vehicles[vehicleid][vehMods][10]);
- format(query, sizeof(query), "%s `mod12` = '%d',", query, Vehicles[vehicleid][vehMods][11]);
- format(query, sizeof(query), "%s `mod13` = '%d',", query, Vehicles[vehicleid][vehMods][12]);
- format(query, sizeof(query), "%s `mod14` = '%d',", query, Vehicles[vehicleid][vehMods][13]);
- format(query, sizeof(query), "%s `paintjob` = '%d'", query, Vehicles[vehicleid][vehPaint]);
- format(query, sizeof(query), "%s WHERE `id` = '%d'", query, Vehicles[vehicleid][vehID]);
- mysql_format(koneksi, query, sizeof(query), "%s", query);
- mysql_query(koneksi, query, false);
- return 1;
- }
- stock removeVehicle(i)
- {
- DestroyVehicle(Vehicles[i][vehicleData]);
- Vehicles[i][vehStatus] = false;
- Vehicles[i][vehID] = INVALID_VEHICLE_ID;
- Vehicles[i][vehModel] = -1;
- Vehicles[i][vehPos][0] = 0.0;
- Vehicles[i][vehPos][1] = 0.0;
- Vehicles[i][vehPos][2] = 0.0;
- Vehicles[i][vehPos][3] = 0.0;
- Vehicles[i][vehColor][0] = -1;
- Vehicles[i][vehColor][1] = -1;
- Vehicles[i][vehInt] = -1;
- Vehicles[i][vehVW] = -1;
- format(Vehicles[i][vehOwner], MAX_PLAYER_NAME, " ");
- Vehicles[i][vehLock] = false;
- Vehicles[i][vehAlarm] = false;
- for(new w = 0; w < 14; w++)
- {
- Vehicles[i][vehMods][w] = 0;
- }
- Vehicles[i][vehPaint] = 255;
- return 1;
- }
- stock safeString(exploit[])
- {
- new safe[128];
- mysql_real_escape_string(exploit, safe, koneksi, 128);
- return safe;
- }
- stock isConnected(otherID)
- {
- if(IsPlayerConnected(otherID))
- return true;
- else
- return false;
- }
- stock bool:isMe(playerid, otherid)
- {
- if(playerid == otherid)
- return true;
- return false;
- }
- stock __deleteVehicle(i)
- {
- new query[256];
- mysql_format(koneksi, query, sizeof(query), "DELETE FROM `vehicle` where `id` = '%d'", Vehicles[i][vehID]);
- mysql_query(koneksi, query, false);
- removeVehicle(i);
- return 1;
- }
- stock Float:PointAngle(playerid, Float:xa, Float:ya, Float:xb, Float:yb)
- {
- new Float:carangle;
- new Float:xc, Float:yc;
- new Float:angle;
- xc = floatabs(floatsub(xa,xb));
- yc = floatabs(floatsub(ya,yb));
- if (yc == 0.0 || xc == 0.0)
- {
- if(yc == 0 && xc > 0) angle = 0.0;
- else if(yc == 0 && xc < 0) angle = 180.0;
- else if(yc > 0 && xc == 0) angle = 90.0;
- else if(yc < 0 && xc == 0) angle = 270.0;
- else if(yc == 0 && xc == 0) angle = 0.0;
- }
- else
- {
- angle = atan(xc/yc);
- if(xb > xa && yb <= ya) angle += 90.0;
- else if(xb <= xa && yb < ya) angle = floatsub(90.0, angle);
- else if(xb < xa && yb >= ya) angle -= 90.0;
- else if(xb >= xa && yb > ya) angle = floatsub(270.0, angle);
- }
- GetVehicleZAngle(GetPlayerVehicleID(playerid), carangle);
- return floatadd(angle, -carangle);
- }
- stock disableGPS(playerid)
- {
- if(GetPVarInt(playerid,"YEAH") == 1)
- {
- DestroyObject(GPSObject[playerid]);
- SetPVarInt(playerid, "YEAH",0);
- DeletePVar(playerid, "Spongebob");
- DeletePVar(playerid, "Mario");
- DeletePVar(playerid, "SpiderPig");
- DeletePVar(playerid, "FAIL");
- }
- return 1;
- }
- stock checkVehicle(playerid, vehicleid)
- {
- if(strcmp(Vehicles[vehicleid][vehOwner], GetName(playerid)))
- {
- if(Vehicles[vehicleid][vehLock])
- {
- Server(playerid, "This vehicle is locked.");
- RemovePlayerFromVehicle(playerid);
- }
- else
- {
- new msg[128];
- format(msg, sizeof(msg), "This vehicle belongs to "CHAT_YELLOW"%s"CHAT_WHITE".", Vehicles[vehicleid][vehOwner]);
- Server(playerid, msg);
- }
- if(Vehicles[vehicleid][vehAlarm])
- {
- ToggleAlarm(Vehicles[vehicleid][vehicleData], VEHICLE_PARAMS_ON);
- SetTimerEx("offAlarm", 5000, false, "d", Vehicles[vehicleid][vehicleData]);
- }
- }
- else
- {
- Server(playerid, "Welcome to your vehicle, type /vcp to view vehicle control panel.");
- }
- return 1;
- }
- stock ToggleAlarm(vehicleid, toggle)
- {
- new engine, lights, alarm, doors, bonnet, boot, objective;
- GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
- SetVehicleParamsEx(vehicleid, engine, lights, toggle, doors, bonnet, boot, objective);
- }
- forward OnSavedVehicleCreated(model, playerid, Float:x, Float:y, Float:z, Float:a);
- forward putinVehicle(playerid, vehicleid);
- forward OnPlayerLoadVehicles(playerid);
- forward offAlarm(vehicleid);
- public OnSavedVehicleCreated(model, playerid, Float:x, Float:y, Float:z, Float:a)
- {
- for(new i = 0; i < MAX_VEH; i++)
- {
- if(Vehicles[i][vehStatus]) continue;
- Vehicles[i][vehStatus] = true;
- Vehicles[i][vehID] = cache_insert_id();
- Vehicles[i][vehModel] = model;
- Vehicles[i][vehPos][0] = x;
- Vehicles[i][vehPos][1] = y;
- Vehicles[i][vehPos][2] = z;
- Vehicles[i][vehPos][3] = a;
- Vehicles[i][vehColor][0] = 1;
- Vehicles[i][vehColor][1] = 1;
- Vehicles[i][vehInt] = 0;
- Vehicles[i][vehVW] = 0;
- format(Vehicles[i][vehOwner], MAX_PLAYER_NAME, "%s", GetName(playerid));
- Vehicles[i][vehLock] = true;
- Vehicles[i][vehAlarm] = true;
- for(new w = 0; w < 14; w++)
- {
- Vehicles[i][vehMods][w] = 0;
- }
- Vehicles[i][vehPaint] = 255;
- format(Vehicles[i][vehPlate], 16, DEFAULT_NUMBER_PLATE);
- createVehicle(i);
- TextDrawShowForPlayer(playerid, buycarTD[0]);
- TextDrawShowForPlayer(playerid, buycarTD[1]);
- TextDrawShowForPlayer(playerid, buycarTD[2]);
- TextDrawShowForPlayer(playerid, buycarTD[3]);
- SetTimerEx("putinVehicle", 2000, false, "dd", playerid, Vehicles[i][vehicleData]);
- break;
- }
- return 1;
- }
- public putinVehicle(playerid, vehicleid)
- {
- TextDrawHideForPlayer(playerid, buycarTD[0]);
- TextDrawHideForPlayer(playerid, buycarTD[1]);
- TextDrawHideForPlayer(playerid, buycarTD[2]);
- TextDrawHideForPlayer(playerid, buycarTD[3]);
- PutPlayerInVehicle(playerid, vehicleid, 0);
- return 1;
- }
- public OnPlayerLoadVehicles(playerid)
- {
- new rows = cache_num_rows(koneksi), count = 0, tempString[16];
- if(rows > 0)
- {
- new tempInt;
- for(new z = 0; z < rows; z++)
- {
- for(new i = 0; i < MAX_VEH; i++)
- {
- if(Vehicles[i][vehStatus]) continue;
- Vehicles[i][vehStatus] = true;
- Vehicles[i][vehID] = cache_get_field_content_int(z, "id");
- Vehicles[i][vehModel] = cache_get_field_content_int(z, "model");
- cache_get_field_content(z, "owner", tempString);
- format(Vehicles[i][vehOwner], MAX_PLAYER_NAME, "%s", tempString);
- Vehicles[i][vehPos][0] = cache_get_field_content_float(z, "posX");
- Vehicles[i][vehPos][1] = cache_get_field_content_float(z, "posY");
- Vehicles[i][vehPos][2] = cache_get_field_content_float(z, "posZ");
- Vehicles[i][vehPos][3] = cache_get_field_content_float(z, "posA");
- Vehicles[i][vehColor][0] = cache_get_field_content_int(z, "color1");
- Vehicles[i][vehColor][1] = cache_get_field_content_int(z, "color2");
- Vehicles[i][vehInt] = cache_get_field_content_int(z, "int");
- Vehicles[i][vehVW] = cache_get_field_content_int(z, "vw");
- new a = 1;
- for(new w = 0; w < 14; w++)
- {
- format(tempString, sizeof(tempString), "mod%d", a);
- Vehicles[i][vehMods][w] = cache_get_field_content_int(z, tempString);
- a++;
- }
- tempInt = cache_get_field_content_int(z, "locked");
- if(tempInt == 1)
- Vehicles[i][vehLock] = true;
- else
- Vehicles[i][vehLock] = false;
- tempInt = cache_get_field_content_int(z, "alarm");
- if(tempInt == 1)
- Vehicles[i][vehAlarm] = true;
- else
- Vehicles[i][vehAlarm] = false;
- cache_get_field_content(z, "plate", tempString);
- format(Vehicles[i][vehPlate], 16, "%s", tempString);
- createVehicle(i);
- count++;
- break;
- }
- }
- }
- printf("Loaded %d vehicles from %s", count, GetName(playerid));
- return 1;
- }
- public offAlarm(vehicleid)
- {
- ToggleAlarm(vehicleid, VEHICLE_PARAMS_OFF);
- return 1;
- }
- COMMAND:gotodealership(playerid, params[])
- {
- if(!IsPlayerAdmin(playerid))
- return 0;
- SetPlayerPos(playerid, dealX, dealY, dealZ);
- return 1;
- }
- COMMAND:vcp(playerid, params[])
- {
- if(IsPlayerInAnyVehicle(playerid))
- {
- new bool:found = false;
- for(new i = 0; i < MAX_VEH; i++)
- {
- if(Vehicles[i][vehicleData] == GetPlayerVehicleID(playerid) && Vehicles[i][vehStatus])
- {
- if(!strcmp(Vehicles[i][vehOwner], GetName(playerid)))
- {
- new message[256];
- format(message, sizeof(message), "Status \t\t\t");
- if(Vehicles[i][vehLock])
- format(message, sizeof(message), "%s"CHAT_YELLOW"Locked", message);
- else
- format(message, sizeof(message), "%s"CHAT_RED"Unlocked", message);
- format(message, sizeof(message), "%s\nAlarm \t\t\t", message);
- if(Vehicles[i][vehAlarm])
- format(message, sizeof(message), "%s"CHAT_YELLOW"On", message);
- else
- format(message, sizeof(message), "%s"CHAT_RED"Off", message);
- format(message, sizeof(message), "%s\nPlate \t\t\t"CHAT_YELLOW"%s", message, Vehicles[i][vehPlate]);
- format(message, sizeof(message), "%s\nPark your vehicle here", message);
- format(message, sizeof(message), "%s\nColour 1\t\t"CHAT_YELLOW"%d", message, Vehicles[i][vehColor][0]);
- format(message, sizeof(message), "%s\nColour 2\t\t"CHAT_YELLOW"%d", message, Vehicles[i][vehColor][1]);
- Player[playerid][carVCP] = i;
- ShowPlayerDialog(playerid, DIALOG_VCP, DIALOG_STYLE_LIST, "Vehicle Control Panel", message, "Choose", "Cancel");
- }
- else
- {
- Server(playerid, "You're not owner of this vehicle.");
- }
- found = true;
- break;
- }
- }
- if(!found)
- {
- Server(playerid, "This command only for private vehicles.");
- }
- }
- else
- {
- Server(playerid, "You must be in any vehicles to use this command.");
- }
- return 1;
- }
- COMMAND:myvehicles(playerid, params[])
- {
- new bool:found = false, msg[256];
- for(new i = 0; i < MAX_VEH; i++)
- {
- if(!Vehicles[i][vehStatus]) continue;
- if(!strcmp(Vehicles[i][vehOwner], GetName(playerid)))
- {
- found = true;
- format(msg, sizeof(msg), "%s%s ID : "CHAT_YELLOW"%d"CHAT_WHITE"\n", msg, namaCar[Vehicles[i][vehModel] - 400], Vehicles[i][vehID]);
- }
- }
- if(found)
- {
- ShowPlayerDialog(playerid, DIALOG_MYVEHICLES, DIALOG_STYLE_LIST, "My Vehicles", msg, "Choose", "Cancel");
- }
- else
- {
- Server(playerid, "You didn't have any vehicles.");
- }
- return 1;
- }
- public OnFilterScriptInit()
- {
- print("\n-----------------------------------------");
- print(" Vehicle System by Bondowocopz ");
- print("-----------------------------------------\n");
- mysql_log(LOG_ERROR | LOG_WARNING, LOG_TYPE_HTML);
- koneksi = mysql_connect(HOST, USER, DBNAME, PASSWORD);
- buycarCP = CreateDynamicCP(dealX, dealY, dealZ, 1.0); // Checkpoint for buy vehicles
- initTD();
- return 1;
- }
- public OnFilterScriptExit()
- {
- mysql_close();
- for(new i = 0; i < MAX_VEH; i++)
- {
- Vehicles[i][vehStatus] = false;
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- //GivePlayerMoney(playerid, 999999999);
- loadVehicles(playerid);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- disableGPS(playerid);
- destroyCar(playerid);
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if(GetPVarInt(playerid, "YEAH") == 1)
- {
- DestroyObject(GPSObject[playerid]);
- SetPVarInt(playerid, "YEAH",0);
- DeletePVar(playerid, "Spongebob");
- DeletePVar(playerid, "Mario");
- DeletePVar(playerid, "SpiderPig");
- DeletePVar(playerid, "FAIL");
- }
- return 1;
- }
- public OnPlayerEnterDynamicCP(playerid, checkpointid)
- {
- if(checkpointid == buycarCP)
- {
- ShowPlayerDialog(playerid, DIALOG_BUYCAR, DIALOG_STYLE_LIST, "Bondowocopz Dealership", "Fast Cars\nSaloons\nMotorbikes\nUnique Cars\nIndustry Cars\nLowriders \nOff Road \nHelicopter & Plane", "Select", "Cancel");
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- new message[256];
- switch(dialogid)
- {
- case DIALOG_BUYCAR:
- {
- if(response)
- {
- showDealership(playerid, listitem);
- }
- }
- case DIALOG_DEALERSHIP:
- {
- if(response)
- {
- for(new i = 0; i < sizeof(Dealership); i++)
- {
- if(Dealership[i][dealerType] == Player[playerid][dealershipChoice])
- {
- new bool:success = false;
- if(Dealership[i][dialogID] == listitem)
- {
- if(GetPlayerMoney(playerid) >= Dealership[i][dealerPrice])
- {
- takeMoney(playerid, Dealership[i][dealerPrice]);
- success = true;
- }
- else
- {
- Server(playerid, "You didn't have enough money to buy this vehicles.");
- success = false;
- }
- if(success)
- {
- new count2 = countplayerVeh(playerid);
- if(count2 <= MAX_PLAYER_VEHICLES)
- {
- if (Dealership[i][dealerType] != AIR)
- {
- __createVehicle(Dealership[i][dealerModel], playerid, airX, airY, airZ, airA);
- }
- else
- {
- __createVehicle(Dealership[i][dealerModel], playerid, normalX, normalY, normalZ, normalA);
- }
- }
- else
- {
- Server(playerid, "You've reached maximum car limit.");
- }
- }
- Player[playerid][dealershipChoice] = -1;
- }
- }
- }
- }
- }
- case DIALOG_VCP:
- {
- if(response)
- {
- new i = Player[playerid][carVCP];
- if(i == INVALID_VEHICLE_ID)
- {
- Server(playerid, "Error when receiving vehicle data.");
- return 1;
- }
- switch(listitem)
- {
- case 0:
- {
- if(Vehicles[i][vehLock])
- {
- Vehicles[i][vehLock] = false;
- Server(playerid, "You "CHAT_RED"unlocked"CHAT_WHITE" this vehicle.");
- }
- else
- {
- Vehicles[i][vehLock] = true;
- Server(playerid, "You "CHAT_YELLOW"locked"CHAT_WHITE" this vehicle.");
- }
- cmd_vcp(playerid, "");
- }
- case 1:
- {
- if(Vehicles[i][vehAlarm])
- {
- Vehicles[i][vehAlarm] = false;
- Server(playerid, "You toggle the alarm "CHAT_RED"off"CHAT_WHITE".");
- }
- else
- {
- Vehicles[i][vehAlarm] = true;
- Server(playerid, "You toggle the alarm "CHAT_YELLOW"on"CHAT_WHITE".");
- }
- cmd_vcp(playerid, "");
- }
- case 2:
- {
- format(message, sizeof(message), "Current Plate : "CHAT_YELLOW"%s", Vehicles[i][vehPlate]);
- ShowPlayerDialog(playerid, DIALOG_CHANGEPLATE, DIALOG_STYLE_INPUT, "Change Plate", message, "Change", "Cancel");
- }
- case 3:
- {
- parkVehicles(i, GetPlayerInterior(playerid), GetPlayerVirtualWorld(playerid));
- Server(playerid, "Your vehicle will be spawned here next time.");
- }
- case 4:
- {
- format(message, sizeof(message), "Current Color : "CHAT_YELLOW"%d", Vehicles[i][vehColor][0]);
- ShowPlayerDialog(playerid, DIALOG_CHANGECOLOR, DIALOG_STYLE_INPUT, "Change Color", message, "Change", "Cancel");
- }
- case 5:
- {
- format(message, sizeof(message), "Current Color : "CHAT_YELLOW"%d", Vehicles[i][vehColor][1]);
- ShowPlayerDialog(playerid, DIALOG_CHANGECOLOR2, DIALOG_STYLE_INPUT, "Change Color", message, "Change", "Cancel");
- }
- }
- }
- }
- case DIALOG_CHANGEPLATE:
- {
- if(response)
- {
- if(strlen(inputtext) > 10 || strlen(inputtext) < 3)
- {
- Server(playerid, "Please insert 3-10 character.");
- }
- else
- {
- new i = Player[playerid][carVCP];
- if(i == INVALID_VEHICLE_ID)
- {
- Server(playerid, "Error when receiving vehicle data.");
- return 1;
- }
- format(Vehicles[i][vehPlate], 16, "%s", inputtext);
- SetVehicleNumberPlate(Vehicles[i][vehicleData], Vehicles[i][vehPlate]);
- createVehicle(Vehicles[i][vehicleData], true);
- }
- }
- cmd_vcp(playerid, "");
- }
- case DIALOG_CHANGECOLOR:
- {
- if(response)
- {
- if(strval(inputtext) >= 0 && strval(inputtext) <= 255)
- {
- new i = Player[playerid][carVCP];
- Vehicles[i][vehColor][0] = strval(inputtext);
- ChangeVehicleColor(Vehicles[i][vehicleData], Vehicles[i][vehColor][0], Vehicles[i][vehColor][1]);
- }
- else
- {
- Server(playerid, "Please input between 0 - 255.");
- }
- }
- }
- case DIALOG_CHANGECOLOR2:
- {
- if(response)
- {
- if(strval(inputtext) >= 0 && strval(inputtext) <= 255)
- {
- new i = Player[playerid][carVCP];
- Vehicles[i][vehColor][1] = strval(inputtext);
- ChangeVehicleColor(Vehicles[i][vehicleData], Vehicles[i][vehColor][0], Vehicles[i][vehColor][1]);
- }
- else
- {
- Server(playerid, "Please input between 0 - 255.");
- }
- }
- }
- case DIALOG_MYVEHICLES:
- {
- if(response)
- {
- new count = 0;
- for(new i = 0; i < MAX_VEH; i++)
- {
- if(!Vehicles[i][vehStatus]) continue;
- if(!strcmp(Vehicles[i][vehOwner], GetName(playerid)))
- {
- if(count == listitem)
- {
- Player[playerid][carVCP] = i;
- format(message, sizeof(message), "%s - %d", namaCar[Vehicles[i][vehModel] - 400], Vehicles[i][vehID]);
- ShowPlayerDialog(playerid, DIALOG_MYVEHICLES2, DIALOG_STYLE_LIST, message, "Locate Vehicle\nRespawn Vehicle\nSell Vehicle To Server\nSell Vehicle To Player", "Choose", "Back");
- break;
- }
- else
- {
- count++;
- }
- }
- }
- }
- }
- case DIALOG_MYVEHICLES2:
- {
- if(response)
- {
- new i = Player[playerid][carVCP];
- switch(listitem)
- {
- case 0:
- {
- if(IsPlayerInAnyVehicle(playerid))
- {
- new Float:x, Float:y, Float:z;
- GetVehiclePos(Vehicles[i][vehicleData], x, y, z);
- SetPVarFloat(playerid, "Spongebob", x);
- SetPVarFloat(playerid, "Mario", y);
- SetPVarFloat(playerid, "SpiderPig", z);
- SetPVarString(playerid, "FAIL", "Your Car");
- Server(playerid, "Follow the arrow to find your car.");
- GPSObject[playerid] = CreateObject(1318, 0, 0, 0, 0.0, 0.0, 0);
- SetPVarInt(playerid, "YEAH", 1);
- }
- else
- {
- Server(playerid, "You must be in vehicle to locate your car.");
- }
- }
- case 1:
- {
- createVehicle(i, true);
- Server(playerid, "Your vehicle has been respawned.");
- }
- case 2:
- {
- new price = 0;
- for(new m = 0; m < sizeof(Dealership); m++)
- {
- if(Dealership[m][dealerModel] == Vehicles[i][vehModel])
- {
- price = Dealership[m][dealerPrice];
- break;
- }
- }
- price = price - floatround(price * 0.20, floatround_round);
- format(message, sizeof(message), "Are you sure you want to sell your vehicle for "CHAT_YELLOW"$%s"CHAT_WHITE"?", FormatNumber(price));
- ShowPlayerDialog(playerid, DIALOG_SALESERVER, DIALOG_STYLE_MSGBOX, "Sell Vehicle", message, "Sell", "Cancel");
- }
- case 3:
- {
- Player[playerid][vsellCar] = Player[playerid][carVCP];
- ShowPlayerDialog(playerid, DIALOG_VSELL, DIALOG_STYLE_INPUT, "Sell Vehicle", "Insert player ID", "Sell", "Cancel");
- }
- }
- }
- else
- {
- cmd_myvehicles(playerid, "");
- }
- }
- case DIALOG_SALESERVER:
- {
- if(response)
- {
- new i = Player[playerid][carVCP], price = 0;
- for(new m = 0; m < sizeof(Dealership); m++)
- {
- if(Dealership[m][dealerModel] == Vehicles[i][vehModel])
- {
- price = Dealership[m][dealerPrice];
- break;
- }
- }
- price = price - floatround(price * 0.20, floatround_round);
- format(message, sizeof(message), CHAT_WHITE"You sold your vehicle for "CHAT_YELLOW"$%s"CHAT_WHITE".", FormatNumber(price));
- Server(playerid, message);
- giveMoney(playerid, price);
- __deleteVehicle(i);
- }
- }
- case DIALOG_VSELL:
- {
- if(response)
- {
- if(!isConnected(strval(inputtext)))
- {
- ShowPlayerDialog(playerid, DIALOG_VSELL, DIALOG_STYLE_INPUT, "Sell Vehicle", CHAT_WHITE"That player isn't connected!\nInsert player ID", "Sell", "Cancel");
- }
- else if(isMe(playerid, strval(inputtext)))
- {
- ShowPlayerDialog(playerid, DIALOG_VSELL, DIALOG_STYLE_INPUT, "Sell Vehicle", CHAT_WHITE"You can't sell to yourself!\nInsert player ID", "Sell", "Cancel");
- }
- else
- {
- Player[playerid][vsellTo] = strval(inputtext);
- format(message, sizeof(message), CHAT_WHITE"You want to sell your vehicle to "CHAT_YELLOW"%s"CHAT_WHITE".\nInsert price for your vehicle", GetName(Player[playerid][vsellTo]));
- ShowPlayerDialog(playerid, DIALOG_VSELL2, DIALOG_STYLE_INPUT, "Sell Vehicle", message, "Sell", "Cancel");
- }
- }
- }
- case DIALOG_VSELL2:
- {
- if(response)
- {
- if(!isConnected(Player[playerid][vsellTo]))
- {
- Server(playerid, "That player isn't connected.");
- return 1;
- }
- if(strval(inputtext) >= 100000)
- {
- new msg2[512];
- Player[playerid][vsellPrice] = strval(inputtext);
- format(msg2, sizeof(msg2), CHAT_WHITE"Are you sure you want to sell your vehicle to "CHAT_YELLOW"%s"CHAT_WHITE".\nWith price "CHAT_YELLOW"%s", GetName(Player[playerid][vsellTo]), FormatNumber(Player[playerid][vsellPrice]));
- ShowPlayerDialog(playerid, DIALOG_CONFVS, DIALOG_STYLE_MSGBOX, "Sell Vehicle", msg2, "Sell", "Cancel");
- }
- else
- {
- format(message, sizeof(message), CHAT_WHITE"Minimum price is 100.000!\nYou want to sell your vehicle to "CHAT_YELLOW"%s"CHAT_WHITE".\nInsert price for your vehicle", GetName(Player[playerid][vsellTo]));
- ShowPlayerDialog(playerid, DIALOG_VSELL2, DIALOG_STYLE_INPUT, "Sell Vehicle", message, "Sell", "Cancel");
- }
- }
- }
- case DIALOG_CONFVS:
- {
- if(response)
- {
- new otherID = Player[playerid][vsellTo];
- if(!isConnected(Player[playerid][vsellTo]))
- {
- Server(playerid, "That player isn't connected.");
- return 1;
- }
- if(Player[otherID][vsellFrom] == INVALID_PLAYER_ID)
- {
- Player[otherID][vsellFrom] = playerid;
- new msg2[512], i = Player[playerid][vsellCar];
- format(msg2, sizeof(msg2), CHAT_YELLOW"%s "CHAT_WHITE" want to sell "CHAT_YELLOW"%s"CHAT_WHITE".\nWith price "CHAT_YELLOW"%s"CHAT_WHITE".\nDo you want to buy?", GetName(playerid), namaCar[Vehicles[i][vehModel] - 400], FormatNumber(Player[playerid][vsellPrice]));
- ShowPlayerDialog(otherID, DIALOG_CONFIRMVSELL, DIALOG_STYLE_MSGBOX, "Buy Vehicle", msg2, "Buy", "Cancel");
- }
- else
- {
- Server(playerid, "That player already in transaction.");
- }
- }
- }
- case DIALOG_CONFIRMVSELL:
- {
- new otherID = Player[playerid][vsellFrom], i = Player[otherID][vsellCar];
- if(response && Player[playerid][vsellFrom] != INVALID_PLAYER_ID)
- {
- if(!isConnected(Player[playerid][vsellFrom]))
- {
- Server(playerid, "Request is expired.");
- return 1;
- }
- new count2 = countplayerVeh(playerid);
- if(count2 < MAX_PLAYER_VEHICLES)
- {
- if(GetPlayerMoney(playerid) >= Player[otherID][vsellPrice])
- {
- giveMoney(otherID, Player[otherID][vsellPrice]);
- takeMoney(playerid, Player[otherID][vsellPrice]);
- RemovePlayerFromVehicle(otherID);
- format(message, sizeof(message), CHAT_YELLOW"%s bought your car for "CHAT_YELLOW"%s"CHAT_WHITE".", GetName(playerid), FormatNumber(Player[otherID][vsellPrice]));
- ShowPlayerDialog(otherID, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Congratulations!!!", message, "Confirm", "");
- format(message, sizeof(message), CHAT_YELLOW"Succesfully bought "CHAT_YELLOW"%s "CHAT_WHITE"car for "CHAT_YELLOW"%s"CHAT_WHITE".", GetName(otherID), Player[otherID][vsellPrice]);
- Server(playerid, message);
- format(Vehicles[i][vehOwner], MAX_PLAYER_NAME, GetName(playerid));
- saveVehicles(i);
- Player[playerid][vsellFrom] = INVALID_PLAYER_ID;
- Player[otherID][vsellCar] = -1;
- Player[otherID][vsellPrice] = -1;
- }
- else
- {
- Server(playerid, "You didn't have enough money to buy that vehicle.");
- Server(otherID, "That player didn't have enough money to buy your vehicle.");
- }
- }
- else
- {
- Server(playerid, "You've reached maximum car limit.");
- Server(otherID, "That player has reached maximum car limit.");
- }
- }
- else
- {
- if(isConnected(Player[playerid][vsellFrom]))
- {
- Server(otherID, "Your vehicle sell request has been denied.");
- }
- }
- Player[playerid][vsellFrom] = INVALID_PLAYER_ID;
- }
- }
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- if(GetPVarInt(playerid,"YEAH") == 1)
- {
- new
- Float:VPos[3],
- Float:Rotation
- ;
- GetVehiclePos(GetPlayerVehicleID(playerid), VPos[0], VPos[1], VPos[2]);
- Rotation = PointAngle(playerid, VPos[0], VPos[1], GetPVarFloat(playerid, "Spongebob"), GetPVarFloat(playerid, "Mario"));
- AttachObjectToVehicle(GPSObject[playerid], GetPlayerVehicleID(playerid), 0.0, 0.0, 1.5, 0.0, 90.0, Rotation);
- if(IsPlayerInRangeOfPoint(playerid, 10.0, GetPVarFloat(playerid, "Spongebob"), GetPVarFloat(playerid, "Mario"), GetPVarFloat(playerid, "SpiderPig")))
- {
- DestroyObject(GPSObject[playerid]);
- SetPVarInt(playerid,"YEAH",0);
- DeletePVar(playerid,"Spongebob");
- DeletePVar(playerid,"Mario");
- DeletePVar(playerid,"SpiderPig");
- DeletePVar(playerid,"FAIL");
- Server(playerid, "You've reached your destination.");
- }
- }
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- disableGPS(playerid);
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- disableGPS(playerid);
- if(newstate == PLAYER_STATE_DRIVER)
- {
- new vehicleid = GetPlayerVehicleID(playerid);
- for(new i = 0; i < MAX_VEH; i++)
- {
- if(Vehicles[i][vehicleData] == vehicleid)
- {
- checkVehicle(playerid, i);
- break;
- }
- }
- }
- return 1;
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- for(new i = 0; i < MAX_VEH; i++)
- {
- if(Vehicles[i][vehicleData] == vehicleid)
- {
- Vehicles[i][vehMods][GetVehicleComponentType(componentid)] = componentid;
- break;
- }
- }
- return 1;
- }
- public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- for(new i = 0; i < MAX_VEH; i++)
- {
- if(Vehicles[i][vehicleData] == vehicleid)
- {
- Vehicles[i][vehPaint] = paintjobid;
- break;
- }
- }
- return 1;
- }
- //Hope you like it!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement