19.01.2016, 04:32
Код:
CMD:v(playerid, params[]) return cmd_vehicle(playerid, params); CMD:vehicle(playerid, params[]) { new option[24], secoption, thirdoption, fourthoption; if(gettime() - GetIntVar(playerid, "VehicleDelay") < 3) return SCM(playerid, COLOR_LIGHTRED, "Please wait 3 seconds between each vehicle operation."); SetIntVar(playerid, "VehicleDelay", gettime()); if(sscanf(params, "s[24]D(-1)D(-1)D(-1)", option, secoption, thirdoption, fourthoption)) { SCM(playerid, COLOR_YELLOW3, "_____________________________________________"); SyntaxMSG(playerid, "(/v)ehicle [usage]"); SCM(playerid, COLOR_GRAD2, "[Actions] list, get, park, sell, accept, refuse, lock, info, colour, faction"); SCM(playerid, COLOR_GRAD2, "[Actions] buylock, buyalarm, buyimmob, buyinsurance, buygps, buypark, tow"); SCM(playerid, COLOR_GRAD2, "[Actions] find, duplicatekey, lights, sell, refuse, buy, mod, tickets, payticket"); SCM(playerid, COLOR_GRAD2, "[Actions] packages putpackage takepackage"); SCM(playerid, COLOR_GRAD2, "[Delete] scrap (warning: deletes your vehicle permanently)"); SCM(playerid, COLOR_YELLOW3, "_____________________________________________"); return 1; } if(!strcmp(option, "packages", true)) { new id = GetNearestVehicle(playerid); if (id == INVALID_VEHICLE_ID) return SCM(playerid, COLOR_INFO, "You are not near any vehicle."); if (PlayerInfo[playerid][pCarKey] != id) return SCM(playerid, COLOR_INFO, "You don't own this vehicle."); SCM(playerid, COLOR_GREEN, "| ________________ Weapon Packages ________________"); SCMEx(playerid, COLOR_WHITE, "| [1. %s (%d/1000)] | [2. %s (%d/1000)] | [3. %s (%d/1000)] | [4. %s (%d/1000)]", GetPackageType(VehicleInfo[id][carPackages][0]), VehicleInfo[id][carPackageAmmo][0], GetPackageType(VehicleInfo[id][carPackages][1]), VehicleInfo[id][carPackageAmmo][1], GetPackageType(VehicleInfo[id][carPackages][2]), VehicleInfo[id][carPackageAmmo][2], GetPackageType(VehicleInfo[id][carPackages][3]), VehicleInfo[id][carPackageAmmo][3]); SCMEx(playerid, COLOR_WHITE, "| [5. %s (%d/1000)] | [6. %s (%d/1000)] | [7. %s (%d/1000)] | [8. %s (%d/1000)]", GetPackageType(VehicleInfo[id][carPackages][4]), VehicleInfo[id][carPackageAmmo][4], GetPackageType(VehicleInfo[id][carPackages][5]), VehicleInfo[id][carPackageAmmo][5], GetPackageType(VehicleInfo[id][carPackages][6]), VehicleInfo[id][carPackageAmmo][6], GetPackageType(VehicleInfo[id][carPackages][7]), VehicleInfo[id][carPackageAmmo][7]); SCMEx(playerid, COLOR_WHITE, "| [9. %s (%d/1000)] | [10. %s (%d/1000)]", GetPackageType(VehicleInfo[id][carPackages][8]), VehicleInfo[id][carPackageAmmo][8], GetPackageType(VehicleInfo[playerid][carPackages][9]), VehicleInfo[id][carPackageAmmo][9]); SCM(playerid, COLOR_GREEN, "** Type /takepackage [slot] to take a package."); return 1; } if(!strcmp(option, "putpackage", true)) { new id = GetNearestVehicle(playerid), slotid; if (sscanf(params, "d", slotid)) return SyntaxMSG(playerid, "/storepackage [slotid]"); if (id == INVALID_VEHICLE_ID) return SCM(playerid, COLOR_INFO, "You are not near any vehicle."); if (PlayerInfo[playerid][pCarKey] != id) return SCM(playerid, COLOR_INFO, "You don't own this vehicle."); if (slotid < 1 || slotid > 10) return SCM(playerid, COLOR_LIGHTRED, "Error: The package slot must be between 1 and 10."); if (!PlayerInfo[playerid][pGunPackages][slotid-1]) return SCM(playerid, COLOR_LIGHTRED, "Error: There is no package in this slot."); for (new i = 0; i < 10; i ++) { if (!VehicleInfo[id][carPackages][slotid-1]) { VehicleInfo[id][carPackages][slotid-1] = PlayerInfo[playerid][pGunPackages][slotid-1]; VehicleInfo[id][carPackageAmmo][slotid-1] = PlayerInfo[playerid][pPackageAmmo][slotid-1]; SCMEx(playerid, COLOR_ADGREEN, "* You have stored a %s with %d ammo into this vehicle.", GetPackageType(PlayerInfo[playerid][pGunPackages][slotid-1]), PlayerInfo[playerid][pPackageAmmo][slotid-1]); SaveVehicle(id); return 1; } } SCM(playerid, COLOR_INFO, "There is no room in the vehicle."); return 1; } if(!strcmp(option, "takepackage", true)) { new id = GetNearestVehicle(playerid), slotid; if (sscanf(params, "d", slotid)) return SyntaxMSG(playerid, "/takepackage [slotid]"); if (id == INVALID_VEHICLE_ID) return SCM(playerid, COLOR_INFO, "You are not near any vehicle."); if (PlayerInfo[playerid][pCarKey] != id) return SCM(playerid, COLOR_INFO, "You don't own this vehicle."); if (slotid < 1 || slotid > 10) return SCM(playerid, COLOR_LIGHTRED, "Error: The package slot must be between 1 and 10."); if (!VehicleInfo[id][carPackages][slotid-1]) return SCM(playerid, COLOR_LIGHTRED, "Error: There is no package in that slot."); if (GetAvailablePackage(playerid) == -1) return SCM(playerid, COLOR_LIGHTRED, "Error: You don't have any room for a weapon package."); GiveWeaponPackage(playerid, VehicleInfo[id][carPackages][slotid-1], VehicleInfo[id][carPackageAmmo][slotid-1]); SCMEx(playerid, COLOR_ADGREEN, "* You have taken a %s with %d ammo from this vehicle.", GetPackageType(VehicleInfo[id][carPackages][slotid-1]), VehicleInfo[id][carPackageAmmo][slotid-1]); VehicleInfo[id][carPackages][slotid-1] = 0; VehicleInfo[id][carPackageAmmo][slotid-1] = 0; SaveVehicle(id); return 1; } if(!strcmp(option, "list", true)) { if(PlayerInfo[playerid][pVehicles] == 0) return SCM(playerid, COLOR_LIGHTRED, "You do not own any vehicles."); SCMEx(playerid, COLOR_GREEN, "______________Your Vehicles(%d)______________", PlayerInfo[playerid][pVehicles]); for(new i = 1; i <= PlayerInfo[playerid][pVehicles]; i++) { if(VehicleStatus[playerid][i][carOn] == 1) { if(FindVehicleByPlate(VehicleStatus[playerid][i][carPlate])) { SCMEx(playerid, COLOR_GREEN, "Vehicle %d: %s, Lock[%d], Alarm[%d], Immobiliser[%d], Insurances[%d], Times Destroyed[%d], Next Insurance Price[$%d]", i, VehicleNames[VehicleStatus[playerid][i][carModel]-400],VehicleStatus[playerid][i][carLock],VehicleStatus[playerid][i][carAlarm],VehicleStatus[playerid][i][carImmob],VehicleStatus[playerid][i][carInsurances],VehicleStatus[playerid][i][carDestroyed],GetInsurancePrice2(playerid, i)); } else { SCMEx(playerid, COLOR_WHITE, "Vehicle %d: %s, Lock[%d], Alarm[%d], Immobiliser[%d], Insurances[%d], Times Destroyed[%d], Next Insurance Price[$%d]", i, VehicleNames[VehicleStatus[playerid][i][carModel]-400], VehicleStatus[playerid][i][carLock],VehicleStatus[playerid][i][carAlarm],VehicleStatus[playerid][i][carImmob],VehicleStatus[playerid][i][carInsurances],VehicleStatus[playerid][i][carDestroyed],GetInsurancePrice2(playerid, i)); } } } return 1; } if(!strcmp(option, "tickets", true)) { new vehicle = GetPlayerVehicleID(playerid), string[500]; if(!IsVehicleSpawned(PlayerInfo[playerid][pCarKey])) return ErrorMsg(playerid, "You don't have a spawned vehicle."); if(!PlayerInCar(playerid)) return NotInCarMSG(playerid); if(!PlayerOwnVehicle(playerid, vehicle)) return SCM(playerid, -1, "You don't own this vehicle."); for(new i = 0; i < MAX_CAR_TICKETS; i++) { if(VehicleInfo[vehicle][carTicket][i] != 0) format(string, sizeof(string), "%s\n(Ticket %d) Amount: $%d.", string, i, VehicleInfo[vehicle][carTicket][i]); else format(string, sizeof(string), "%s\nNone.", string, i, VehicleInfo[vehicle][carTicket][i]); } Dialog_Show(playerid, CarTickets, DIALOG_STYLE_LIST, "Vehicle Tickets", string, "O", "K"); return 1; } if(!strcmp(option, "tow", true)) { if(!IsVehicleSpawned(PlayerInfo[playerid][pCarKey])) return ErrorMsg(playerid, "You don't have a spawned vehicle."); if(GetCash(playerid) < 1500) return SCM(playerid, COLOR_LIGHTRED, "Towing a car costs $1,500."); SetIntVar(playerid, "TowingCar", 30); SCM(playerid, COLOR_YELLOWG, "Towing your car to the parking place..."); return 1; } if(!strcmp(option, "faction", true)) { new vehicle = GetPlayerVehicleID(playerid); if(!IsVehicleSpawned(PlayerInfo[playerid][pCarKey])) return ErrorMsg(playerid, "You don't have a spawned vehicle."); if(!PlayerInCar(playerid)) return NotInCarMSG(playerid); if(!PlayerOwnVehicle(playerid, vehicle)) return SCM(playerid, -1, "You don't own this vehicle."); if(PlayerInfo[playerid][pFaction] == CIVILIAN) return SCM(playerid, COLOR_GREY, "You are not in a faction."); VehicleInfo[vehicle][carFaction] = PlayerInfo[playerid][pFaction]; SCMEx(playerid, COLOR_GREEN, "Your car has been successfully changed to faction [%d] - %s", PlayerInfo[playerid][pFaction], Factions[PlayerInfo[playerid][pFaction]][fName]); return 1; } if(!strcmp(option, "payticket", true)) { new vehicle = GetPlayerVehicleID(playerid), slot, id; if(sscanf(params, "{s[16]}dd", slot, id)) return SyntaxMSG(playerid, "/v payticket [slot(0-9)] [OfficerID]"); if(!IsVehicleSpawned(PlayerInfo[playerid][pCarKey])) return ErrorMsg(playerid, "You don't have a spawned vehicle."); if(!PlayerInCar(playerid)) return NotInCarMSG(playerid); if(!PlayerOwnVehicle(playerid, vehicle)) return SCM(playerid, -1, "You don't own this vehicle."); if(VehicleInfo[vehicle][carTicket][slot] == 0) return SCM(playerid, COLOR_LIGHTRED, "You don't have a ticket in this slot."); if(id == playerid) return SCM(playerid, COLOR_LIGHTRED, "Not possible."); if(!PlayerIsOn(id)) return NotConnectedMSG(playerid); if(!PlayerNearPlayer(3.0, playerid, id)) return NotNearPlayerMSG(playerid); if(PlayerInfo[id][pFaction] != LSPD) return SCM(playerid, COLOR_GREY, "This player is not an officer in the LSPD."); format(msg, sizeof(msg), "You have successfully paid a ticket in slot %d, amount: $%d to officer %s.", slot, VehicleInfo[vehicle][carTicket][slot], GetNameWithMask(id)); SCM(playerid, COLOR_LIGHTBLUE, msg); format(msg, sizeof(msg), "%s has paid you for his ticket, amount: $%d.", GetNameWithMask(playerid), VehicleInfo[vehicle][carTicket][slot]); SCM(id, COLOR_LIGHTBLUE, msg); GiveCash(playerid, -VehicleInfo[vehicle][carTicket][slot]); GiveCash(id, VehicleInfo[vehicle][carTicket][slot]); VehicleInfo[vehicle][carTicket][slot] = 0; return 1; } if(!strcmp(option, "mod", true)) { new vehicle = GetPlayerVehicleID(playerid); if(!IsVehicleSpawned(PlayerInfo[playerid][pCarKey])) return ErrorMsg(playerid, "You don't have a spawned vehicle."); if(!PlayerInCar(playerid)) return NotInCarMSG(playerid); if(!PlayerOwnVehicle(playerid, vehicle)) return SCM(playerid, -1, "You don't own this vehicle."); new dealerid = GetClosestDealerShip(playerid); if(dealerid == -1) return SCM(playerid, COLOR_FADE2, "Not near any car dealerships."); Dialog_Show(playerid, ModDialog, DIALOG_STYLE_LIST, "Vehicle Modification", "Wheels\nSpoilers\nScoops\nRoofs\nNitro\nPaintJobs\nSideskirts\nExhausts\nHydraulics $10,000\nBoomBox $20,000", "Select", "Cancel"); return 1; } if(!strcmp(option, "buy", true)) { new dealerid = GetClosestDealerShip(playerid); if(dealerid == -1) return SCM(playerid, COLOR_FADE2, "Not near any car dealerships."); if(GetOwnedVehicles(playerid) == MAX_OWNED_VEHICLES-1) return SCM(playerid, COLOR_GRAY, "You have reached to your maximum owned vehicles."); ShowBuyableCars(playerid); } if(!strcmp(option, "get", true)) { new slot; if(sscanf(params, "{s[7]}d", slot)) return SyntaxMSG(playerid, "/v get [slot(1-3)]"); if(slot < 1 || slot > MAX_OWNED_VEHICLES) return SCM(playerid, -1, "Invalid slot."); if(IsVehicleSpawned(PlayerInfo[playerid][pCarKey])) return ErrorMsg(playerid, "You already have a spawned vehicle."); if(VehSpawned != 0) return SCM(playerid, COLOR_LIGHTRED, "Someone has just spawned a vehicle, please wait 3 seconds."); LoadVehicleFromSlot(playerid, slot); return 1; } if(!strcmp(option, "park", true)) { new veh = PlayerInfo[playerid][pCarKey]; if(!IsVehicleSpawned(veh)) return ErrorMsg(playerid, "You don't have a spawned vehicle."); if(!PlayerInCar(playerid)) return NotInCarMSG(playerid); if(!PlayerOwnVehicle(playerid, GetPlayerVehicleID(playerid))) return SCM(playerid, -1, "You don't own this vehicle."); if(!PlayerToPoint(5.0, playerid, VehicleInfo[veh][carParkX],VehicleInfo[veh][carParkY],VehicleInfo[veh][carParkZ])) { SCM(playerid, COLOR_WHITE, "You are not near the parking spot, here is a checkpoint."); SetCheckPoint(playerid, FINEVEH, VehicleInfo[veh][carParkX],VehicleInfo[veh][carParkY],VehicleInfo[veh][carParkZ], 6.0); return 1; } new Float:hp; GetVehicleHealth(veh, hp); if(hp < 400.0) return SCM(playerid, COLOR_LIGHTRED, "The car is near death so you can't park it."); SaveVehicle(veh); VehicleInfo[veh][carSpawned] = 0; VehicleInfo[veh][carOwned] = 0; StopCarBoomBox(veh); format(msg, sizeof(msg), "Your %s has been parked (despawned)", VehicleNames[VehicleInfo[veh][carModel]-400]); SCM(playerid, COLOR_GREEN, msg); DestoryCar(veh); PlayerInfo[playerid][pCarKey] = 0; PlayerInfo[playerid][pVehSlot] = 0; return 1; } if(!strcmp(option, "buypark", true)) { new veh = PlayerInfo[playerid][pCarKey]; new vehicle = GetPlayerVehicleID(playerid); new house = PlayerInfo[playerid][pHouseKey]; if(!IsVehicleSpawned(veh)) return ErrorMsg(playerid, "You don't have a spawned vehicle."); if(!PlayerInCar(playerid)) return NotInCarMSG(playerid); if(!PlayerOwnVehicle(playerid, vehicle)) return SCM(playerid, -1, "You don't own this vehicle."); new Float:X, Float:Y, Float:Z, Float:A; GetVehiclePos(vehicle, X, Y, Z); GetVehicleZAngle(vehicle, A); VehicleInfo[vehicle][carParkX] = X; VehicleInfo[vehicle][carParkY] = Y; VehicleInfo[vehicle][carParkZ] = Z; VehicleInfo[vehicle][carParkA] = A; if(house != -1 && PlayerToPoint(30.0, playerid, HouseInfo[house][hEntranceX], HouseInfo[house][hEntranceY], HouseInfo[house][hEntranceZ])) { SCM(playerid, COLOR_GREY, "Parking place purchased for $0 (Area change)."); SCM(playerid, COLOR_ADGREEN, "You can now use /v park"); } else if(GetCash(playerid) >= 2500) { SCM(playerid, COLOR_GREY, "Parking place purchased for $2,500 (Area change)."); SCM(playerid, COLOR_ADGREEN, "You can now use /v park"); GiveCash(playerid, -2500); } else { SCM(playerid, COLOR_GREEN, "Parking changing costs $2,500."); } format(query, sizeof(query), "UPDATE `ownedvehicles` SET `parkx` = %f, `parky` = %f, `parkz` = %f, `parka` = %f WHERE `owner` = '%s' AND `slot` = %d", X, Y, Z, A, GetName(playerid), PlayerInfo[playerid][pVehSlot]); mysql_function_query(dbHandle, query, false, "", ""); return 1; } if(!strcmp(option, "buylock", true)) { new vehicle = GetPlayerVehicleID(playerid); if(!IsVehicleSpawned(PlayerInfo[playerid][pCarKey])) return ErrorMsg(playerid, "You don't have a spawned vehicle."); if(!PlayerInCar(playerid)) return NotInCarMSG(playerid); if(!PlayerOwnVehicle(playerid, vehicle)) return SCM(playerid, -1, "You don't own this vehicle."); new dealerid = GetClosestDealerShip(playerid); new level; if(dealerid == -1) return SCM(playerid, COLOR_FADE2, "Not near any car dealerships."); if(sscanf(params, "{s[64]}d", level)) { SyntaxMSG(playerid, "/v buylock [level]"); SCM(playerid, COLOR_INFO, "Level-1: $1500"); SCM(playerid, COLOR_INFO, "Level-2: $3500"); SCM(playerid, COLOR_INFO, "Level-3: $5500"); SCM(playerid, COLOR_INFO, "Level-4: $7500"); SCM(playerid, COLOR_INFO, "Level-5: $9500"); return 1; } if(level < 1 || level > 5) return SCM(playerid, COLOR_INFO, "Lock level can't be below 1 or above 5 !"); if(level > VehicleInfo[vehicle][carLock]+1) return SCM(playerid, COLOR_LIGHTRED, "You must buy the locks in the right order."); if(VehicleInfo[vehicle][carLock] >= level) { format(msg, sizeof(msg), "You already own a lock level %d or more !", level); SCM(playerid, COLOR_LIGHTRED, msg); return 1; } new lockcost; if(level == 1) lockcost = 1500; if(level == 2) lockcost = 3500; if(level == 3) lockcost = 5500; if(level == 4) lockcost = 7500; if(level == 5) lockcost = 9500; if(GetCash(playerid) < lockcost) return NoCashMSG(playerid); format(msg, sizeof(msg), "You have succefully bought lock level %d.", level); SCM(playerid, COLOR_INFO, msg); GiveCash(playerid, -lockcost); VehicleInfo[vehicle][carLock] = level; format(query, sizeof(query), "UPDATE `ownedvehicles` SET `lock` = %d WHERE `owner` = '%s' AND `slot` = %d", level, GetName(playerid), PlayerInfo[playerid][pVehSlot]); mysql_function_query(dbHandle, query, false, "", ""); UpdateVehicleStatus(playerid, vehicle); return 1; } if(!strcmp(option, "buyalarm", true)) { new vehicle = GetPlayerVehicleID(playerid); if(!IsVehicleSpawned(PlayerInfo[playerid][pCarKey])) return ErrorMsg(playerid, "You don't have a spawned vehicle."); if(!PlayerInCar(playerid)) return NotInCarMSG(playerid); if(!PlayerOwnVehicle(playerid, vehicle)) return SCM(playerid, -1, "You don't own this vehicle."); new dealerid = GetClosestDealerShip(playerid); new level; if(dealerid == -1) return SCM(playerid, COLOR_FADE2, "Not near any car dealerships."); if(sscanf(params, "{s[64]}d", level)) { SyntaxMSG(playerid, "/v buyalarm [level]"); SCM(playerid, COLOR_INFO, "Level-1: $2000"); SCM(playerid, COLOR_INFO, "Level-2: $4000"); SCM(playerid, COLOR_INFO, "Level-3: $6000"); SCM(playerid, COLOR_INFO, "Level-4: $8000"); SCM(playerid, COLOR_INFO, "Level-5: $10000"); return 1; } if(level < 1 || level > 5) return SCM(playerid, COLOR_INFO, "Alarm level can't be below 1 or above 5 !"); if(level > VehicleInfo[vehicle][carAlarm]+1) return SCM(playerid, COLOR_LIGHTRED, "You must buy the alarm in the right order."); if(VehicleInfo[vehicle][carAlarm] >= level) { format(msg, sizeof(msg), "You already own a alarm level %d or more !", level); SCM(playerid, COLOR_LIGHTRED, msg); return 1; } new alarmcost; if(level == 1) alarmcost = 2000; if(level == 2) alarmcost = 4000; if(level == 3) alarmcost = 6000; if(level == 4) alarmcost = 8000; if(level == 5) alarmcost = 10000; if(GetCash(playerid) < alarmcost) return NoCashMSG(playerid); format(msg, sizeof(msg), "You have succefully bought alarm level %d.", level); SCM(playerid, COLOR_INFO, msg); GiveCash(playerid, -alarmcost); VehicleInfo[vehicle][carAlarm] = level; format(query, sizeof(query), "UPDATE `ownedvehicles` SET `alarm` = %d WHERE `owner` = '%s' AND `slot` = %d", level, GetName(playerid), PlayerInfo[playerid][pVehSlot]); mysql_function_query(dbHandle, query, false, "", ""); UpdateVehicleStatus(playerid, vehicle); return 1; } if(!strcmp(option, "buyimmob", true)) { new vehicle = GetPlayerVehicleID(playerid); if(!IsVehicleSpawned(PlayerInfo[playerid][pCarKey])) return ErrorMsg(playerid, "You don't have a spawned vehicle."); if(!PlayerInCar(playerid)) return NotInCarMSG(playerid); if(!PlayerOwnVehicle(playerid, vehicle)) return SCM(playerid, -1, "You don't own this vehicle."); new dealerid = GetClosestDealerShip(playerid); new level; if(dealerid == -1) return SCM(playerid, COLOR_FADE2, "Not near any car dealerships."); if(sscanf(params, "{s[64]}d", level)) { SyntaxMSG(playerid, "/v buyimmob [level]"); SCM(playerid, COLOR_INFO, "Level-1: $900"); SCM(playerid, COLOR_INFO, "Level-2: $1800"); SCM(playerid, COLOR_INFO, "Level-3: $2700"); SCM(playerid, COLOR_INFO, "Level-4: $3600"); SCM(playerid, COLOR_INFO, "Level-5: $4500"); return 1; } if(level < 1 || level > 5) return SCM(playerid, COLOR_INFO, "Immob level can't be below 1 or above 5 !"); if(level > VehicleInfo[vehicle][carImmob]+1) return SCM(playerid, COLOR_LIGHTRED, "You must buy the immob in the right order."); if(VehicleInfo[vehicle][carImmob] >= level) { format(msg, sizeof(msg), "You already own a immob level %d or more !", level); SCM(playerid, COLOR_LIGHTRED, msg); return 1; } new immobcost; if(level == 1) immobcost = 900; if(level == 2) immobcost = 1800; if(level == 3) immobcost = 2700; if(level == 4) immobcost = 3600; if(level == 5) immobcost = 4500; if(GetCash(playerid) < immobcost) return NoCashMSG(playerid); format(msg, sizeof(msg), "You have succefully bought immob level %d.", level); SCM(playerid, COLOR_INFO, msg); GiveCash(playerid, -immobcost); VehicleInfo[vehicle][carImmob] = level; format(query, sizeof(query), "UPDATE `ownedvehicles` SET `immob` = %d WHERE `owner` = '%s' AND `slot` = %d", level, GetName(playerid), PlayerInfo[playerid][pVehSlot]); mysql_function_query(dbHandle, query, false, "", ""); UpdateVehicleStatus(playerid, vehicle); return 1; } if(!strcmp(option, "duplicatekey", true)) { new vehicle = GetPlayerVehicleID(playerid); if(!IsVehicleSpawned(PlayerInfo[playerid][pCarKey])) return ErrorMsg(playerid, "You don't have a spawned vehicle."); if(!PlayerInCar(playerid)) return NotInCarMSG(playerid); if(!PlayerOwnVehicle(playerid, vehicle)) return SCM(playerid, -1, "You don't own this vehicle."); new id; if(sscanf(params, "{s[64]}d", id)) return SyntaxMSG(playerid, "/v duplicatekey [playerid]"); if(id == playerid) return ErrorMsg(playerid, "You may not duplicate a key to yourself."); if(!PlayerIsOn(id)) return NotConnectedMSG(playerid); if(!PlayerNearPlayer(3.0, playerid, id)) return NotNearPlayerMSG(playerid); if(GetCash(playerid) < 2000) return SCM(playerid, COLOR_LIGHTRED, "Duplicating key costs $2,000."); if(PlayerInfo[id][pSpareKey] != 0) return SCM(playerid, COLOR_INFO, "This player has another key, '/dropkey'"); format(msg, sizeof(msg), "%s has given you a duplicated vehicle key to his vehicle.", GetNameWithMask(playerid)); SCM(id, COLOR_INFO, msg); format(msg, sizeof(msg), "You have given %s a duplicated vehicle key to your vehicle.", GetNameWithMask(id)); SCM(playerid, COLOR_INFO, msg); PlayerInfo[id][pSpareKey] = VehicleInfo[vehicle][carDupKey]; GiveCash(playerid, -2000); return 1; } if(!strcmp(option, "sell", true)) { new vehicle = GetPlayerVehicleID(playerid), id, price; if(!IsVehicleSpawned(PlayerInfo[playerid][pCarKey])) return ErrorMsg(playerid, "You don't have a spawned vehicle."); if(!PlayerInCar(playerid)) return NotInCarMSG(playerid); if(!PlayerOwnVehicle(playerid, vehicle)) return SCM(playerid, -1, "You don't own this vehicle."); if(sscanf(params, "{s[64]}ud", id, price)) return SyntaxMSG(playerid, "/v sell [playerid/PartOfName] [price]"); if(IsADonateCar(vehicle)) return SCM(playerid, COLOR_INFO, "You may not sell donating vehicles."); if(id == playerid) return ErrorMsg(playerid, "You may not sell the vehicle to yourself."); if(!PlayerNearPlayer(3.0, playerid, id)) return NotNearPlayerMSG(playerid); if(PlayerInfo[id][pCarKey] != 0) return SCM(playerid, COLOR_GRAD2, "That player has already spawned a car."); if(GetOwnedVehicles(id) == MAX_OWNED_VEHICLES-1) return SCMEx(playerid, COLOR_GRAD2, "That player has already %d owned vehicles.", MAX_OWNED_VEHICLES); if(price < 0) return ErrorMsg(playerid, "Invalid price."); format(msg, sizeof(msg), "%s offers you his %s for $%d, use '/v accept' or '/v refuse'.", GetNameWithMask(playerid), VehicleNames[GetVehicleModel(vehicle)-400], price); SCM(id, COLOR_YELLOW, msg); format(msg, sizeof(msg), "%s, Alarm[%d], Lock[%d], Immobilizer[%d], GPS[%d], Insurances[%d], Times destroyed[%d], Insurance price[%d]", VehicleNames[GetVehicleModel(vehicle)-400], VehicleInfo[vehicle][carAlarm], VehicleInfo[vehicle][carLock], VehicleInfo[vehicle][carImmob], VehicleInfo[vehicle][carGps], VehicleInfo[vehicle][carInsurances], VehicleInfo[vehicle][carDestroyed], GetInsurancePrice(vehicle)); SCM(id, COLOR_YELLOW, msg); format(msg, sizeof(msg), "you offered your %s to %s for $%d.", VehicleNames[GetVehicleModel(vehicle)-400], GetNameWithMask(id), price); SCM(playerid, COLOR_GREEN, msg); pToAccept[id] = playerid; vToAccept[id] = vehicle; prToAccept[id] = price; return 1; } if(!strcmp(option, "refuse", true)) { if(pToAccept[playerid] == INVALID_PLAYER_ID) return SCM(playerid, COLOR_LIGHTRED, "You haven't anything to accept"); format(msg, sizeof(msg), "You refused the %s of %s.", VehicleNames[GetVehicleModel(vToAccept[playerid])-400], GetNameWithMask(vToAccept[playerid])); SCM(playerid, COLOR_LIGHTRED, msg); format(msg, sizeof(msg), "%s has refused your %s.", GetNameWithMask(playerid), VehicleNames[GetVehicleModel(vToAccept[playerid])-400]); SCM(pToAccept[playerid], COLOR_LIGHTRED, msg); pToAccept[playerid] = INVALID_PLAYER_ID; vToAccept[playerid] = INVALID_VEHICLE_ID; prToAccept[playerid] = 0; return 1; } if(!strcmp(option, "accept", true)) { new slot = GetNextPlayerVehSlot(playerid); new sid = pToAccept[playerid]; if(sid == INVALID_PLAYER_ID) return SCM(playerid, COLOR_LIGHTRED, "You haven't anything to accept"); if(GetOwnedVehicles(playerid) == MAX_OWNED_VEHICLES-1) { SCM(playerid, COLOR_YELLOWG, "You can't accept any vehicles since you're having the maximum."); SCM(sid, COLOR_LIGHTRED, "You're vehicle cannot be sold because that player does not have enough slots."); pToAccept[playerid] = INVALID_PLAYER_ID; vToAccept[playerid] = INVALID_VEHICLE_ID; prToAccept[playerid] = 0; return 1; } if(GetCash(playerid) >= prToAccept[playerid]) { format(msg, sizeof(msg), "You accepted the %s of %s for $%d.", VehicleNames[GetVehicleModel(vToAccept[playerid])-400], GetNameWithMask(sid), prToAccept[playerid]); SCM(playerid, COLOR_GREEN, msg); format(msg, sizeof(msg), "%s has accepted your %s for $%d.", GetNameWithMask(playerid), VehicleNames[GetVehicleModel(vToAccept[playerid])-400], prToAccept[playerid]); SCM(sid, COLOR_GREEN, msg); GiveCash(sid, prToAccept[playerid]); GiveCash(playerid, -prToAccept[playerid]); PlayerInfo[playerid][pCarKey] = vToAccept[playerid]; PlayerInfo[sid][pCarKey] = 0; format(VehicleInfo[PlayerInfo[playerid][pCarKey]][carPlate], 128, "%s%d", FirstNameLetters(GetName(playerid)), randomEx(10000, 99999)); format(VehicleInfo[PlayerInfo[playerid][pCarKey]][carOwner], 128, "%s", GetName(playerid)); PlayerInfo[playerid][pVehicles]++; PlayerInfo[sid][pVehicles]--; format(query, sizeof(query), "UPDATE `users` SET `vehicles` = %d WHERE `name` = '%s'", PlayerInfo[playerid][pVehicles], GetName(playerid)); mysql_function_query(dbHandle, query, false, "", ""); format(query, sizeof(query), "UPDATE `users` SET `vehicles` = %d WHERE `name` = '%s'", PlayerInfo[sid][pVehicles], GetName(sid)); mysql_function_query(dbHandle, query, false, "", ""); format(query, sizeof(query), "UPDATE `ownedvehicles` SET `owner` = '%s', `plate` = '%s', `slot` = %d WHERE `owner` = '%s' AND `id` = %d", VehicleInfo[PlayerInfo[playerid][pCarKey]][carOwner], VehicleInfo[PlayerInfo[playerid][pCarKey]][carPlate], slot, GetName(sid), VehicleInfo[vToAccept[playerid]][carID]); mysql_function_query(dbHandle, query, false, "", ""); PlayerInfo[playerid][pVehs][slot] = 1; new slot2 = PlayerInfo[pToAccept[playerid]][pVehSlot]; PlayerInfo[sid][pVehs][slot2] = 0; ReAssignPlayerVehicles(sid); CheckOwnedVehicles(playerid); CheckOwnedVehicles(pToAccept[playerid]); pToAccept[playerid] = INVALID_PLAYER_ID; vToAccept[playerid] = INVALID_VEHICLE_ID; prToAccept[playerid] = 0; } else { SCM(playerid, COLOR_LIGHTRED, "You do not have enough money for that."); SCM(pToAccept[playerid], COLOR_LIGHTRED, "You're vehicle cannot be sold because that player does not have enough money."); pToAccept[playerid] = INVALID_PLAYER_ID; vToAccept[playerid] = INVALID_VEHICLE_ID; prToAccept[playerid] = 0; } return 1; } if(!strcmp(option, "lights", true)) { if(!IsDriver(playerid)) return NotInCarMSG(playerid); new vehicleid = GetPlayerVehicleID(playerid); new param[7]; GetVehicleParamsEx(vehicleid,param[0],param[1],param[2],param[3],param[4],param[5],param[6]); if(param[1]) { SetVehicleParamsEx(vehicleid,param[0],0,param[2],param[3],param[4],param[5],param[6]); ActionMessage(playerid, 15.0, "turns the lights in their vehicle off."); return 1; } else { SetVehicleParamsEx(vehicleid,param[0],1,param[2],param[3],param[4],param[5],param[6]); ActionMessage(playerid, 15.0, "turns the lights in their vehicle on."); return 1; } } if(!strcmp(option, "buygps", true)) { new vehicle = GetPlayerVehicleID(playerid); if(!IsVehicleSpawned(PlayerInfo[playerid][pCarKey])) return ErrorMsg(playerid, "You don't have a spawned vehicle."); if(!PlayerInCar(playerid)) return NotInCarMSG(playerid); if(!PlayerOwnVehicle(playerid, vehicle)) return SCM(playerid, -1, "You don't own this vehicle."); new dealerid = GetClosestDealerShip(playerid); if(dealerid == -1) return SCM(playerid, COLOR_FADE2, "Not near any car dealerships."); if(VehicleInfo[vehicle][carGps] == 1) return SCM(playerid, COLOR_LIGHTRED, "Your vehicle has a GPS already."); if(GetCash(playerid) < 3500) return SCM(playerid, COLOR_INFO, "GPS costs $3,500."); SCM(playerid, COLOR_INFO, "You have succefully bought a GPS for $3,500."); GiveCash(playerid, -3500); VehicleInfo[vehicle][carGps] = 1; format(query, sizeof(query), "UPDATE `ownedvehicles` SET `gps` = %d WHERE `owner` = '%s' AND `slot` = %d", 1, GetName(playerid), PlayerInfo[playerid][pVehSlot]); mysql_function_query(dbHandle, query, false, "", ""); UpdateVehicleStatus(playerid, vehicle); return 1; } if(!strcmp(option, "buyinsurance", true)) { new vehicle = GetPlayerVehicleID(playerid); if(!IsVehicleSpawned(PlayerInfo[playerid][pCarKey])) return ErrorMsg(playerid, "You don't have a spawned vehicle."); if(!PlayerInCar(playerid)) return NotInCarMSG(playerid); if(!PlayerOwnVehicle(playerid, vehicle)) return SCM(playerid, -1, "You don't own this vehicle."); new dealerid = GetClosestDealerShip(playerid); if(dealerid == -1) return SCM(playerid, COLOR_FADE2, "Not near any car dealerships."); if(VehicleInfo[vehicle][carInsurances] >= 5) return SCM(playerid, COLOR_INFO, "You already have 5 insurances on this vehicle."); new price = GetInsurancePrice(vehicle); if(GetCash(playerid) < price) NoCashMSG(playerid); GiveCash(playerid, -price); VehicleInfo[vehicle][carInsurances] += 1; format(msg, sizeof(msg), "You have succefully bought an insurance for $%d.", price); SCM(playerid, COLOR_GREEN, msg); format(query, sizeof(query), "UPDATE `ownedvehicles` SET `insurances` = %d WHERE `owner` = '%s' AND `slot` = %d", VehicleInfo[vehicle][carInsurances], GetName(playerid), PlayerInfo[playerid][pVehSlot]); mysql_function_query(dbHandle, query, false, "", ""); UpdateVehicleStatus(playerid, vehicle); return 1; } if(!strcmp(option, "colour", true)) { new vehicle = GetPlayerVehicleID(playerid); new color1, color2; if(!IsVehicleSpawned(PlayerInfo[playerid][pCarKey])) return ErrorMsg(playerid, "You don't have a spawned vehicle."); if(!PlayerInCar(playerid)) return NotInCarMSG(playerid); if(!PlayerOwnVehicle(playerid, vehicle)) return SCM(playerid, -1, "You don't own this vehicle."); new dealerid = GetClosestDealerShip(playerid); if(dealerid == -1) return SCM(playerid, COLOR_FADE2, "Not near any car dealerships."); if(sscanf(params, "{s[64]}dd", color1, color2)) return SyntaxMSG(playerid, "/v colour [color 1] [color 2]"); if(color2 < 0 || color2 > 126 || color1 < 0 || color1 > 126) return SCM(playerid, COLOR_LIGHTRED, "Invalid color ID, (0-126)!"); if(GetCash(playerid) < 500) SCM(playerid, COLOR_INFO, "Color changing costs $500."); VehColor1{playerid} = color1; VehColor2{playerid} = color2; Painting{playerid} = 12; return 1; } if(!strcmp(option, "lock", true)) { if(PlayerNearVehicle(3.0, playerid, PlayerInfo[playerid][pCarKey])) { if(vLocked{PlayerInfo[playerid][pCarKey]}) { PlaySound(playerid, 1145); ToggleVehicleLock(PlayerInfo[playerid][pCarKey], false); ToggleVehicleLockForPlayer(playerid, PlayerInfo[playerid][pCarKey], false); format(msg, sizeof(msg), "~b~%s ~n~~g~Unlocked", VehicleNames[GetVehicleModel(PlayerInfo[playerid][pCarKey])-400]); GameTextForPlayer(playerid, msg, 2000, 4); return 1; } else { PlaySound(playerid, 1145); ToggleVehicleLock(PlayerInfo[playerid][pCarKey], true); ToggleVehicleLockForPlayer(playerid, PlayerInfo[playerid][pCarKey], true); format(msg, sizeof(msg), "~b~%s ~n~~r~Locked", VehicleNames[GetVehicleModel(PlayerInfo[playerid][pCarKey])-400]); GameTextForPlayer(playerid, msg, 2000, 4); return 1; } } return 1; } if(!strcmp(option, "find", true)) { if(!IsVehicleSpawned(PlayerInfo[playerid][pCarKey])) return ErrorMsg(playerid, "You don't have a spawned vehicle."); if(!VehicleEmpty(PlayerInfo[playerid][pCarKey])) return SCM(playerid, COLOR_GREY, "Somebody is inside your vehicle, cannot find it then."); if(VehicleInfo[PlayerInfo[playerid][pCarKey]][carGps] == 0) return SCM(playerid, COLOR_GREY, "Your car does not have a GPS installed."); new Float:x, Float:y, Float:z; GetVehiclePos(PlayerInfo[playerid][pCarKey], x, y, z); new vZone[MAX_ZONE_NAME]; GetVehicleZone(PlayerInfo[playerid][pCarKey], vZone, MAX_ZONE_NAME); format(msg, sizeof(msg), "[GPS] Your %s is located in %s.", VehicleNames[GetVehicleModel(PlayerInfo[playerid][pCarKey])-400], vZone); SCM(playerid, COLOR_WHITE, msg); SetCheckPoint(playerid, FINEVEH, x, y, z, 6.0); return 1; } if(!strcmp(option, "info", true)) { new veh = PlayerInfo[playerid][pCarKey]; if(!IsVehicleSpawned(veh)) return ErrorMsg(playerid, "You don't have a spawned vehicle."); if(!PlayerInCar(playerid)) return NotInCarMSG(playerid); if(!PlayerOwnVehicle(playerid, GetPlayerVehicleID(playerid))) return SCM(playerid, -1, "You don't own this vehicle."); format(msg, sizeof(msg), "%s, Alarm[%d], Lock[%d], Immobilizer[%d], GPS[%d], Insurances[%d], Times destroyed[%d], Insurance price[$%d]", VehicleNames[GetVehicleModel(veh)-400], VehicleInfo[veh][carAlarm], VehicleInfo[veh][carLock], VehicleInfo[veh][carImmob], VehicleInfo[veh][carGps], VehicleInfo[veh][carInsurances], VehicleInfo[veh][carDestroyed], GetInsurancePrice(veh)); SCM(playerid, COLOR_LIGHTGREEN, msg); return 1; } if(!strcmp(option, "scrap", true)) { new veh = PlayerInfo[playerid][pCarKey]; new slot = PlayerInfo[playerid][pVehSlot]; if(!IsVehicleSpawned(veh)) return ErrorMsg(playerid, "You don't have a spawned vehicle."); if(!PlayerInCar(playerid)) return NotInCarMSG(playerid); if(!PlayerOwnVehicle(playerid, GetPlayerVehicleID(playerid))) return SCM(playerid, -1, "You don't own this vehicle."); VehicleInfo[veh][carOwnerSlot] = 0; VehicleInfo[veh][carOwned] = 0; PlayerInfo[playerid][pCarKey] = 0; PlayerInfo[playerid][pVehicles]--; StopCarBoomBox(veh); format(msg, sizeof(msg), "You have scrapped your {FFFF00}%s{FFFFFF}, and got ${FFFF00}%d{FFFFFF} from it.", VehicleNames[VehicleInfo[veh][carModel]-400], GetVehiclePrice(VehicleInfo[veh][carModel])/2); ServerMSG(playerid, msg); GiveCash(playerid, GetVehiclePrice(VehicleInfo[veh][carModel])/2); DestoryCar(veh); format(query, sizeof(query), "DELETE FROM `ownedvehicles` WHERE `owner` = '%s' AND `slot` = %d", GetName(playerid), PlayerInfo[playerid][pVehSlot]); mysql_function_query(dbHandle, query, false, "", ""); format(query, sizeof(query), "UPDATE `users` SET `vehicles` = %d WHERE `name` = '%s'", PlayerInfo[playerid][pVehicles], GetName(playerid)); mysql_function_query(dbHandle, query, false, "", ""); PlayerInfo[playerid][pVehs][slot] = 0; ReAssignPlayerVehicles(playerid); PlayerInfo[playerid][pVehSlot] = 0; CheckOwnedVehicles(playerid); return 1; } return 1; }