Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //===========================Section: Includes==================================
- #include <a_samp>
- #include <utils>
- //===========================Section: Definations===============================
- #define COLOR_GRAD1 0xB4B5B7FF
- #define COLOR_GRAD2 0xBFC0C2FF
- #define COLOR_GRAD3 0xCBCCCEFF
- #define COLOR_GRAD4 0xD8D8D8FF
- #define COLOR_GRAD5 0xE3E3E3FF
- #define COLOR_GRAD6 0xF0F0F0FF
- #define COLOR_GREEN 0x33AA33AA
- #define COLOR_GREY 0xAFAFAFAA
- #define COLOR_WHITE 0xFFFFFFAA
- #define COLOR_YELLOW 0xFFFF00AA
- #define COLOR_YELLOW2 0xF5DEB3AA
- #define COLOR_BLUE 0x2641FEAA
- #pragma tabsize 0
- //===========================Section: Forwards==================================
- forward LoadCar();
- forward SaveCarCoords();
- forward OnPropUpdate();
- forward IsAnOwnableCar(vehicleid);
- forward CarKeys(playerid);
- forward SavePlayerData(playerid);
- new carsonserver = 290;
- new OwnableCarID[MAX_PLAYERS];
- new vehName[][] = {
- "Landstalker",
- "Bravura",
- "Buffalo",
- "Linerunner",
- "Perrenial",
- "Sentinel",
- "Dumper",
- "Firetruck",
- "Trashmaster",
- "Stretch",
- "Manana",
- "Infernus",
- "Voodoo",
- "Pony",
- "Mule",
- "Cheetah",
- "Ambulance",
- "Leviathan",
- "Moonbeam",
- "Esperanto",
- "Taxi",
- "Washington",
- "Bobcat",
- "Whoopee",
- "BF Injection",
- "Hunter",
- "Premier",
- "Enforcer",
- "Securicar",
- "Banshee",
- "Predator",
- "Bus",
- "Rhino",
- "Barracks",
- "Hotknife",
- "Trailer",
- "Previon",
- "Coach",
- "Cabbie",
- "Stallion",
- "Rumpo",
- "RC Bandit",
- "Romero",
- "Packer",
- "Monster",
- "Admiral",
- "Squalo",
- "Seasparrow",
- "Pizzaboy",
- "Tram",
- "Trailer",
- "Turismo",
- "Speeder",
- "Reefer",
- "Tropic",
- "Flatbed",
- "Yankee",
- "Caddy",
- "Solair",
- "Berkley's RC Van",
- "Skimmer",
- "PCJ-600",
- "Faggio",
- "Freeway",
- "RC Baron",
- "RC Raider",
- "Glendale",
- "Oceanic",
- "Sanchez",
- "Sparrow",
- "Patriot",
- "ATV",
- "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",
- "Boxvillde",
- "Benson",
- "Mesa",
- "RC Goblin",
- "Hotring Racer A",
- "Hotring Racer B",
- "Bloodring Banger",
- "Rancher",
- "Super GT",
- "Elegant",
- "Journey",
- "Bike",
- "Mountain Bike",
- "Beagle",
- "Cropduster",
- "Stunt",
- "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",
- "Hustler",
- "Intruder",
- "Primo",
- "Cargobob",
- "Tampa",
- "Sunrise",
- "Merit",
- "Utility",
- "Nevada",
- "Jeep",
- "Windsor",
- "Monster",
- "Monster",
- "Uranus",
- "Jester",
- "Sultan",
- "Stratum",
- "Elegy",
- "Raindance",
- "RC Tiger",
- "Flash",
- "Tahoma",
- "Savanna",
- "Bandito",
- "Freight Flat",
- "Streak Carriage",
- "Kart",
- "Mower",
- "Dune",
- "Sweeper",
- "Broadway",
- "Tornado",
- "AT-400",
- "DFT-30",
- "Huntley",
- "Stafford",
- "BF-400",
- "News Van",
- "Tug",
- "Trailer",
- "Emperor",
- "Wayfarer",
- "Euros",
- "Hotdog",
- "Club",
- "Freight Box",
- "Trailer",
- "Andromada",
- "Dodo",
- "RC Cam",
- "Launch",
- "Police Car LSPD",
- "Police Car SFPD",
- "Police Car LVPD",
- "Police Ranger",
- "Picador",
- "S.W.A.T",
- "Alpha",
- "Phoenix",
- "Glendale",
- "Sadler",
- "Luggage",
- "Luggage",
- "Stairs",
- "Boxville",
- "Tiller",
- "Utility Trailer"
- };
- //===========================Section: Variables=================================
- enum pInfo
- {
- pPcarkey,
- pPcarkey2,
- pPcarkey3,
- }
- new PlayerInfo[256][pInfo];
- enum cInfo
- {
- cModel,
- Float:cLocationx,
- Float:cLocationy,
- Float:cLocationz,
- Float:cAngle,
- cColorOne,
- cColorTwo,
- cOwner[MAX_PLAYER_NAME],
- cDescription[12],
- cOwned,
- cLock
- };
- new CarInfo[1000][cInfo];
- //===========================Section: Callbacks & Functions=====================
- public OnFilterScriptInit()
- {
- for(new h = carsonserver; h < sizeof(CarInfo); h++)
- {
- AddStaticVehicleEx(CarInfo[h][cModel],CarInfo[h][cLocationx],CarInfo[h][cLocationy],CarInfo[h][cLocationz]+1.0,CarInfo[h][cAngle],CarInfo[h][cColorOne],CarInfo[h][cColorTwo],60000);
- }
- return 1;
- }
- public SavePlayerData(playerid)
- {
- if(IsPlayerConnected(playerid))
- {
- new string3[32];
- new playername3[MAX_PLAYER_NAME];
- GetPlayerName(playerid, playername3, sizeof(playername3));
- format(string3, sizeof(string3), "carkeys/%s.ini", playername3);
- new File: hFile = fopen(string3, io_write);
- if (hFile)
- {
- new var[32];
- format(var, 32, "CarKey=%d\n",PlayerInfo[playerid][pPcarkey]);fwrite(hFile, var);
- format(var, 32, "CarKey2=%d\n",PlayerInfo[playerid][pPcarkey2]);fwrite(hFile, var);
- format(var, 32, "CarKey3=%d\n",PlayerInfo[playerid][pPcarkey3]);fwrite(hFile, var);
- fclose(hFile);
- }
- }
- return 1;
- }
- public OnPropUpdate()
- {
- new idx;
- new File: file2;
- idx = carsonserver;
- while (idx < sizeof(CarInfo))
- {
- new coordsstring[256];
- format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%s\n",
- CarInfo[idx][cModel],
- CarInfo[idx][cLocationx],
- CarInfo[idx][cLocationy],
- CarInfo[idx][cLocationz],
- CarInfo[idx][cAngle],
- CarInfo[idx][cColorOne],
- CarInfo[idx][cColorTwo],
- CarInfo[idx][cOwner],
- CarInfo[idx][cDescription],
- CarInfo[idx][cOwned],
- CarInfo[idx][cLock],
- if(idx == carsonserver)
- {
- file2 = fopen("masini.cfg", io_write);
- }
- else
- {
- file2 = fopen("masini.cfg", io_append);
- }
- fwrite(file2, coordsstring);
- idx++;
- fclose(file2);
- }
- return 0;
- }
- public IsAnOwnableCar(vehicleid)
- {
- if(vehicleid >= carsonserver && vehicleid <= 1000) { return 1; }
- return 0;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- if(IsAnOwnableCar(vehicleid) && CarInfo[vehicleid][cLock] == 1 && CarInfo[vehicleid][cOwned] == 1)
- {
- if(IsPlayerAdmin(playerid)) { }
- else
- {
- new Float:cx, Float:cy, Float:cz;
- GetPlayerPos(playerid, cx, cy, cz);
- SetPlayerPos(playerid, cx, cy, cz);
- }
- }
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- CarKeys(playerid);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- PlayerInfo[playerid][pPcarkey] = -1;
- PlayerInfo[playerid][pPcarkey2] = -1;
- PlayerInfo[playerid][pPcarkey3] = -1;
- for(new h = carsonserver; h < sizeof(CarInfo); h++)
- {
- SetVehicleParamsForPlayer(h,playerid,0,CarInfo[h][cLock]);
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new idx;
- new string[256];
- new cmd[256];
- new tmp[256];
- new sendername[MAX_PLAYER_NAME];
- new playername[MAX_PLAYER_NAME];
- new giveplayer[MAX_PLAYER_NAME];
- new giveplayerid;
- new idcar = GetPlayerVehicleID(playerid);
- cmd = strtok(cmdtext, idx);
- new vehid;
- vehid = GetPlayerVehicleID(playerid);
- if (strcmp(cmd, "/mycars", true) == 0)
- {
- if(IsPlayerConnected(playerid))
- {
- new carkey = PlayerInfo[playerid][pPcarkey];
- new carkey2 = PlayerInfo[playerid][pPcarkey2];
- new carkey3 = PlayerInfo[playerid][pPcarkey3];
- if (PlayerInfo[playerid][pPcarkey] != -1)
- {
- format(string, sizeof(string), "1| VehModel:[%s] VehValue:[%d] VehColor1:[%d] VehColor2:[%d] VehLocked:[%d]", CarInfo[carkey][cDescription], CarInfo[carkey][cColorOne], CarInfo[carkey][cColorTwo], CarInfo[carkey][cLock]);
- SendClientMessage(playerid, COLOR_GRAD5,string);
- }
- if (PlayerInfo[playerid][pPcarkey2] != -1)
- {
- format(string, sizeof(string), "2| VehModel:[%s] VehValue:[%d] VehColor1:[%d] VehColor2:[%d] VehLocked:[%d]", CarInfo[carkey2][cDescription], CarInfo[carkey2][cColorOne], CarInfo[carkey2][cColorTwo], CarInfo[carkey2][cLock]);
- SendClientMessage(playerid, COLOR_GRAD5,string);
- }
- if (PlayerInfo[playerid][pPcarkey3] != -1)
- {
- format(string, sizeof(string), "3| VehModel:[%s] VehValue:[%d] VehColor1:[%d] VehColor2:[%d] VehLocked:[%d]", CarInfo[carkey3][cDescription], CarInfo[carkey3][cColorOne], CarInfo[carkey3][cColorTwo], CarInfo[carkey3][cLock]);
- SendClientMessage(playerid, COLOR_GRAD5,string);
- }
- }
- return 1;
- }
- if(strcmp(cmd, "/apark", true) == 0)
- {
- if(IsPlayerConnected(playerid))
- {
- new Float:x,Float:y,Float:z;
- new Float:a;
- new carid;
- carid = GetPlayerVehicleID(playerid);
- GetPlayerName(playerid, playername, sizeof(playername));
- GetVehiclePos(carid, x, y, z);
- GetVehicleZAngle(carid, a);
- if(IsPlayerAdmin(playerid))
- {
- CarInfo[carid][cLocationx] = x;
- CarInfo[carid][cLocationy] = y;
- CarInfo[carid][cLocationz] = z;
- CarInfo[carid][cAngle] = a;
- format(string, sizeof(string), "~n~ You have parked your car in this location. ~n~");
- GameTextForPlayer(playerid, "You have parked this car in this position. It will respawn here.", 10000, 3);
- OnPropUpdate(); SavePlayerData(playerid);
- DestroyVehicle(carid);
- new thiscar = CreateVehicle(CarInfo[carid][cModel],CarInfo[carid][cLocationx],CarInfo[carid][cLocationy],CarInfo[carid][cLocationz]+1.0,CarInfo[carid][cAngle],CarInfo[carid][cColorOne],CarInfo[carid][cColorTwo],60000);
- return 1;
- }
- else
- {
- SendClientMessage(playerid, COLOR_GREY, " You are not authorized to use that command !");
- return 1;
- }
- }
- return 1;
- }
- if(strcmp(cmd, "/acreatecar", true) == 0)
- {
- if(IsPlayerAdmin(playerid))
- {
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /acreatecar [carid] [culoare1] [culoare2] ");
- return 1;
- }
- new car;
- car = strval(tmp);
- if(car < 400 || car > 611) { SendClientMessage(playerid, COLOR_WHITE, " Vehicle Number can't be below 400 or above 611 !"); return 1; }
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /acreatecar [carid] [culoare1] [culoare2] ");
- return 1;
- }
- new color1;
- color1 = strval(tmp);
- if(color1 < 0 || color1 > 126) { SendClientMessage(playerid, COLOR_WHITE, " Color Number can't be below 0 or above 126 !"); return 1; }
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /acreatecar [carid] [culoare1] [culoare2]");
- return 1;
- }
- new color2;
- color2 = strval(tmp);
- if(color2 < 0 || color2 > 126) { SendClientMessage(playerid, COLOR_WHITE, " Color Number can't be below 0 or above 126 !"); return 1; }
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /acreatecar [carid] [culoare1] [culoare2] ");
- return 1;
- }
- new value;
- value = strval(tmp);
- new Float:X,Float:Y,Float:Z; GetPlayerPos(playerid, X,Y,Z);
- new thiscar = CreateVehicle(car,X,Y,Z,1,color1,color2,99999999);
- CarInfo[thiscar][cOwned] = 0; CarInfo[thiscar][cModel] = car; CarInfo[thiscar][cColorOne] = color1; CarInfo[thiscar][cColorTwo] = color2;
- CarInfo[thiscar][cLocationx] = X; CarInfo[thiscar][cLocationy] = Y; CarInfo[thiscar][cLocationz] = Z; CarInfo[thiscar][cAngle] = 1;
- PutPlayerInVehicle(playerid,thiscar,0);
- strmid(CarInfo[vehid][cOwner], "Dealership", 0, strlen("Dealership"), 999);
- format(CarInfo[thiscar][cDescription], 32, "%s",vehName[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
- format(string, sizeof(string), " Masina %d a fost creata cu succes!.", thiscar);
- SendClientMessage(playerid, COLOR_BLUE, string);
- }
- else
- {
- SendClientMessage(playerid, COLOR_GRAD1, " you are not authorized to use that command!");
- return 1;
- }
- }
- if(strcmp(cmd, "/v", true) == 0 || strcmp(cmd, "/vehicle", true) == 0)
- {
- if(IsPlayerConnected(playerid))
- {
- new x_nr[64];
- x_nr = strtok(cmdtext, idx);
- if(!strlen(x_nr))
- {
- SendClientMessage(playerid, COLOR_WHITE, "HINT: (/v)ehicle [name]");
- SendClientMessage(playerid, COLOR_WHITE, "Available names: park, lock(1-3), color, locate(1-3), tow(1-3)");
- return 1;
- }
- else if(strcmp(x_nr,"buy",true) == 0)
- {
- if(IsAnOwnableCar(idcar))
- {
- if(PlayerInfo[playerid][pPcarkey] == -1) { }
- else if(PlayerInfo[playerid][pPcarkey2] == -1) { }
- else if(PlayerInfo[playerid][pPcarkey3] == -1) { }
- else { SendClientMessage(playerid, COLOR_GREY, " Ai deja 3 masini!!"); return 1; }
- if(CarInfo[idcar][cOwned]==1)
- {
- SendClientMessage(playerid, COLOR_GREY, "Someone already owns this car");
- return 1;
- }
- if(GetPlayerMoney(playerid) >= CarInfo[idcar][cValue])
- {
- if(PlayerInfo[playerid][pPcarkey] == -1) { PlayerInfo[playerid][pPcarkey] = idcar; }
- else if(PlayerInfo[playerid][pPcarkey2] == -1) { PlayerInfo[playerid][pPcarkey2] = idcar; }
- else if(PlayerInfo[playerid][pPcarkey3] == -1) { PlayerInfo[playerid][pPcarkey3] = idcar; }
- else { return 1; }
- CarInfo[idcar][cOwned] = 1;
- GetPlayerName(playerid, sendername, sizeof(sendername));
- strmid(CarInfo[idcar][cOwner], sendername, 0, strlen(sendername), 999);
- PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
- GameTextForPlayer(playerid, "~w~Felicitari~n~Nu uita sa o parchezi cu /v park!", 5000, 3);
- SendClientMessage(playerid, COLOR_GRAD2, "Felicitari ti-ai cumparat o masina noua!");
- TogglePlayerControllable(playerid, 1);
- OnPropUpdate(); SavePlayerData(playerid);
- return 1;
- }
- else
- }
- }
- else if(strcmp(x_nr,"park",true) == 0)
- {
- new Float:x,Float:y,Float:z;
- new Float:a;
- new carid;
- new getcarid;
- if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { carid = PlayerInfo[playerid][pPcarkey]; }
- else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2]) { carid = PlayerInfo[playerid][pPcarkey2]; }
- else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey3]) { carid = PlayerInfo[playerid][pPcarkey3]; }
- else { return 1; }
- getcarid = GetPlayerVehicleID(playerid);
- GetPlayerName(playerid, playername, sizeof(playername));
- GetVehiclePos(carid, x, y, z);
- GetVehicleZAngle(carid, a);
- if(IsPlayerInVehicle(playerid,carid) && CarInfo[carid][cOwned] == 1)
- {
- if(PlayerInfo[playerid][pPcarkey] == -1 && PlayerInfo[playerid][pPcarkey2] == -1 && PlayerInfo[playerid][pPcarkey3] == -1)
- {
- SendClientMessage(playerid, COLOR_GREY, "You don't own a car.");
- return 1;
- }
- if(getcarid == carid)
- {
- new Float:CarHP, Float:OldCarHP; new panels,doors,lights,tires;
- CarInfo[carid][cLocationx] = x;
- CarInfo[carid][cLocationy] = y;
- CarInfo[carid][cLocationz] = z;
- CarInfo[carid][cAngle] = a;
- GetVehicleDamageStatus(carid,panels,doors,lights,tires);
- GetVehicleHealth(carid, CarHP); OldCarHP = CarHP;
- format(string, sizeof(string), "~n~ You have parked your vehicle in this location. ~n~");
- GameTextForPlayer(playerid, "You have parked your vehicle in this position. It will respawn here.", 10000, 3);
- OnPropUpdate(); SavePlayerData(playerid); DestroyVehicle(carid);
- CreateVehicle(CarInfo[carid][cModel],CarInfo[carid][cLocationx],CarInfo[carid][cLocationy],CarInfo[carid][cLocationz]+1.0,CarInfo[carid][cAngle],CarInfo[carid][cColorOne],CarInfo[carid][cColorTwo],60000);
- PutPlayerInVehicle(playerid,carid,0); SetVehicleHealth(carid, OldCarHP);
- UpdateVehicleDamageStatus(carid,panels,doors,lights,tires);
- TogglePlayerControllable(playerid, 1);
- return 1;
- }
- }
- }
- else if(strcmp(x_nr,"lock1",true) == 0)
- {
- new keycar = PlayerInfo[playerid][pPcarkey];
- if(keycar != -1)
- {
- new locked[256];
- locked = strtok(cmdtext, idx);
- if(CarInfo[keycar][cLock] == 1)
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if (IsPlayerConnected(i))
- {
- SetVehicleParamsForPlayer(keycar,i,0,0);
- }
- }
- format(string, sizeof(string), "~w~Vehicle~n~~g~Unlocked");
- GameTextForPlayer(playerid, string, 4000, 3);
- CarInfo[keycar][cLock] = 0;
- OnPropUpdate(); SavePlayerData(playerid);
- return 1;
- }
- else if(CarInfo[keycar][cLock] == 0)
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if (IsPlayerConnected(i))
- {
- SetVehicleParamsForPlayer(keycar,i,0,1);
- }
- }
- format(string, sizeof(string), "~w~Vehicle~n~~r~Locked");
- GameTextForPlayer(playerid, string, 4000, 3);
- CarInfo[keycar][cLock] = 1;
- OnPropUpdate(); SavePlayerData(playerid);
- return 1;
- }
- }
- else
- {
- SendClientMessage(playerid, COLOR_GREY, " You don't have a vehicle at slot 1");
- return 1;
- }
- }
- else if(strcmp(x_nr,"lock2",true) == 0)
- {
- new keycar = PlayerInfo[playerid][pPcarkey2];
- if(keycar != -1)
- {
- new locked[256];
- locked = strtok(cmdtext, idx);
- if(CarInfo[keycar][cLock] == 1)
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if (IsPlayerConnected(i))
- {
- SetVehicleParamsForPlayer(keycar,i,0,0);
- }
- }
- format(string, sizeof(string), "~w~Vehicle~n~~g~Unlocked");
- GameTextForPlayer(playerid, string, 4000, 3);
- CarInfo[keycar][cLock] = 0;
- OnPropUpdate(); SavePlayerData(playerid);
- return 1;
- }
- else if(CarInfo[keycar][cLock] == 0)
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if (IsPlayerConnected(i))
- {
- SetVehicleParamsForPlayer(keycar,i,0,1);
- }
- }
- format(string, sizeof(string), "~w~Vehicle~n~~r~Locked");
- GameTextForPlayer(playerid, string, 4000, 3);
- CarInfo[keycar][cLock] = 1;
- OnPropUpdate(); SavePlayerData(playerid);
- return 1;
- }
- }
- else
- {
- SendClientMessage(playerid, COLOR_GREY, " You don't have a vehicle at slot 2");
- return 1;
- }
- }
- else if(strcmp(x_nr,"lock3",true) == 0)
- {
- new keycar = PlayerInfo[playerid][pPcarkey3];
- if(keycar != -1)
- {
- new locked[256];
- locked = strtok(cmdtext, idx);
- if(CarInfo[keycar][cLock] == 1)
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if (IsPlayerConnected(i))
- {
- SetVehicleParamsForPlayer(keycar,i,0,0);
- }
- }
- format(string, sizeof(string), "~w~Vehicle~n~~g~Unlocked");
- GameTextForPlayer(playerid, string, 4000, 3);
- CarInfo[keycar][cLock] = 0;
- OnPropUpdate(); SavePlayerData(playerid);
- return 1;
- }
- else if(CarInfo[keycar][cLock] == 0)
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if (IsPlayerConnected(i))
- {
- SetVehicleParamsForPlayer(keycar,i,0,1);
- }
- }
- format(string, sizeof(string), "~w~Vehicle~n~~r~Locked");
- GameTextForPlayer(playerid, string, 4000, 3);
- CarInfo[keycar][cLock] = 1;
- OnPropUpdate(); SavePlayerData(playerid);
- return 1;
- }
- }
- else
- {
- SendClientMessage(playerid, COLOR_GREY, " You don't have a vehicle at slot 3");
- return 1;
- }
- }
- else if(strcmp(x_nr,"color",true) == 0)
- {
- if(PlayerInfo[playerid][pPcarkey] == -1 && PlayerInfo[playerid][pPcarkey2] == -1 && PlayerInfo[playerid][pPcarkey3] == -1)
- {
- SendClientMessage(playerid, COLOR_GREY," You don't have a vehicle to respray.");
- return 1;
- }
- if(GetPlayerMoney(playerid) < 1000)
- {
- SendClientMessage(playerid, COLOR_GREY," You don't have enough money for vehicle respray.");
- return 1;
- }
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, COLOR_WHITE, "USAGE: /v color [ColorOneID] [ColorTwoID]");
- return 1;
- }
- new color1;
- color1 = strval(tmp);
- if(color1 < 0 && color1 > 126)
- {
- SendClientMessage(playerid, COLOR_GREY, " Wrong color id!");
- return 1;
- }
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, COLOR_WHITE, "USAGE: /v color [ColorOneID] [ColorTwoID]");
- return 1;
- }
- new color2;
- color2 = strval(tmp);
- if(color2 < 0 && color2 > 126)
- {
- SendClientMessage(playerid, COLOR_GREY, " Wrong color id!");
- return 1;
- }
- if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { vehid = PlayerInfo[playerid][pPcarkey]; }
- else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2]) { vehid = PlayerInfo[playerid][pPcarkey2]; }
- else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey3]) { vehid = PlayerInfo[playerid][pPcarkey3]; }
- else { return 1; }
- if(IsPlayerInVehicle(playerid, vehid))
- {
- CarInfo[vehid][cColorOne] = color1;
- CarInfo[vehid][cColorTwo] = color2;
- GivePlayerMoney(playerid, -1000);
- GameTextForPlayer(playerid, "~w~Bill for a Paint Respray~n~~r~-$1000", 5000, 1);
- ChangeVehicleColor(vehid, color1, color2);
- OnPropUpdate(); SavePlayerData(playerid);
- return 1;
- }
- else
- {
- SendClientMessage(playerid, COLOR_GREY," You are not in your vehicle.");
- return 1;
- }
- }
- else if(strcmp(x_nr,"locate1",true) == 0)
- {
- if(!IsPlayerConnected(playerid)) { return 1; }
- new Float:x,Float:y,Float:z;
- new car = PlayerInfo[playerid][pPcarkey];
- if(PlayerInfo[playerid][pPcarkey]==-1) { GameTextForPlayer(playerid, "~w~Nu ai o masina pentru a putea fi localizata", 2500, 3); return 1; }
- SendClientMessage(playerid,COLOR_WHITE,"Locatia masinii a fost gasita.");
- GetVehiclePos(car, x, y, z);
- SetPlayerCheckpoint(playerid, x, y, z, 6);
- return 1;
- }
- else if(strcmp(x_nr,"locate2",true) == 0)
- {
- if(!IsPlayerConnected(playerid)) { return 1; }
- new Float:x,Float:y,Float:z;
- new car = PlayerInfo[playerid][pPcarkey2];
- if(PlayerInfo[playerid][pPcarkey]==-1) { GameTextForPlayer(playerid, "~w~Nu ai o masina pentru a putea fi localizata", 2500, 3); return 1; }
- SendClientMessage(playerid,COLOR_WHITE,"Locatia masinii a fost gasita.");
- GetVehiclePos(car, x, y, z);
- SetPlayerCheckpoint(playerid, x, y, z, 6);
- return 1;
- }
- else if(strcmp(x_nr,"locate3",true) == 0)
- {
- if(!IsPlayerConnected(playerid)) { return 1; }
- new Float:x,Float:y,Float:z;
- new car = PlayerInfo[playerid][pPcarkey3];
- if(PlayerInfo[playerid][pPcarkey]==-1) { GameTextForPlayer(playerid, "~w~Nu ai o masina pentru a putea fi localizata", 2500, 3); return 1; }
- SendClientMessage(playerid,COLOR_WHITE,"Locatia masinii a fost gasita.");
- GetVehiclePos(car, x, y, z);
- SetPlayerCheckpoint(playerid, x, y, z, 6);
- return 1;
- }
- else if(strcmp(x_nr,"tow1",true) == 0)
- {
- if(IsPlayerConnected(playerid))
- {
- new car = PlayerInfo[playerid][pPcarkey];
- GetPlayerName(playerid, playername, sizeof(playername));
- if (car != -1 && strcmp(playername, CarInfo[PlayerInfo[playerid][pPcarkey]][cOwner], true) == 0)
- {
- GameTextForPlayer(playerid, "~w~Masina a fost~n~~g~Tractata cu succes~n~~r~$-1500", 5000, 1);
- GivePlayerMoney(playerid,-1500);
- SetVehicleToRespawn(car);
- PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
- }
- else
- {
- GameTextForPlayer(playerid, "~w~Nu detii o masina personala.", 5000, 1);
- }
- }
- }
- else if(strcmp(x_nr,"tow2",true) == 0)
- {
- if(IsPlayerConnected(playerid))
- {
- new car = PlayerInfo[playerid][pPcarkey2];
- GetPlayerName(playerid, playername, sizeof(playername));
- if (car != -1 && strcmp(playername, CarInfo[PlayerInfo[playerid][pPcarkey2]][cOwner], true) == 0)
- {
- GameTextForPlayer(playerid, "~w~Masina a fost~n~~g~Tractata cu succes~n~~r~$-1500", 5000, 1);
- GivePlayerMoney(playerid,-1500);
- SetVehicleToRespawn(car);
- PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
- }
- else
- {
- GameTextForPlayer(playerid, "~w~Nu detii o masina personala.", 5000, 1);
- }
- }
- }
- else if(strcmp(x_nr,"tow3",true) == 0)
- {
- if(IsPlayerConnected(playerid))
- {
- new car = PlayerInfo[playerid][pPcarkey3];
- GetPlayerName(playerid, playername, sizeof(playername));
- if (car != -1 && strcmp(playername, CarInfo[PlayerInfo[playerid][pPcarkey3]][cOwner], true) == 0)
- {
- GameTextForPlayer(playerid, "~w~Masina a fost~n~~g~Tractata cu succes~n~~r~$-1500", 5000, 1);
- GivePlayerMoney(playerid,-1500);
- SetVehicleToRespawn(car);
- PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
- }
- else
- {
- GameTextForPlayer(playerid, "~w~Nu detii o masina personala.", 5000, 1);
- }
- }
- }
- else
- {
- SendClientMessage(playerid, COLOR_WHITE, "HINT: (/v)ehicle [name]");
- SendClientMessage(playerid, COLOR_WHITE, "Available names: park, lock(1-3) color, locate(1-3), tow(1-3)");
- return 1;
- }
- }
- return 1;
- }
- return 0;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- DisablePlayerCheckpoint(playerid);
- return 1;
- }
- /*----------Car Save Functions----------*/
- public LoadCar()
- {
- new arrCoords[31][64];
- new strFromFile2[256];
- new File: file = fopen("masini.cfg", io_read);
- if (file)
- {
- new idx = carsonserver;
- while (idx < sizeof(CarInfo))
- {
- fread(file, strFromFile2);
- CarInfo[idx][cModel] = strval(arrCoords[0]);
- CarInfo[idx][cLocationx] = floatstr(arrCoords[1]);
- CarInfo[idx][cLocationy] = floatstr(arrCoords[2]);
- CarInfo[idx][cLocationz] = floatstr(arrCoords[3]);
- CarInfo[idx][cAngle] = floatstr(arrCoords[4]);
- CarInfo[idx][cColorOne] = strval(arrCoords[5]);
- CarInfo[idx][cColorTwo] = strval(arrCoords[6]);
- strmid(CarInfo[idx][cOwner], arrCoords[7], 0, strlen(arrCoords[7]), 255);
- strmid(CarInfo[idx][cDescription], arrCoords[8], 0, strlen(arrCoords[8]), 255);
- CarInfo[idx][cOwned] = strval(arrCoords[11]);
- CarInfo[idx][cLock] = strval(arrCoords[12]);
- idx++;
- }
- }
- return 1;
- }
- public SaveCarCoords()
- {
- new idx;
- new File: file2;
- while (idx < sizeof(CarInfo))
- {
- new coordsstring[256];
- format(coordsstring, sizeof(coordsstring), "%d|%f|%f|%f|%f|%d|%d\n",
- CarInfo[idx][cModel],
- CarInfo[idx][cLocationx],
- CarInfo[idx][cLocationy],
- CarInfo[idx][cLocationz],
- CarInfo[idx][cAngle],
- CarInfo[idx][cColorOne],
- CarInfo[idx][cColorTwo],
- if(idx == carsonserver)
- {
- file2 = fopen("masini.cfg", io_write);
- }
- else
- {
- file2 = fopen("masini.cfg", io_append);
- }
- fwrite(file2, coordsstring);
- idx++;
- fclose(file2);
- }
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- new string[128];
- new vehicle = GetPlayerVehicleID(playerid);
- new newcar = GetPlayerVehicleID(playerid);
- if(newstate == PLAYER_STATE_DRIVER)
- {
- if(IsAnOwnableCar(newcar))
- {
- if(CarInfo[newcar][cOwned]==0)
- {
- TogglePlayerControllable(playerid, 0);
- format(string,sizeof(string),"%s Price: %d /v buy to buy this vehicle",CarInfo[newcar][cDescription]);
- SendClientMessage(playerid, COLOR_BLUE, string);
- SendClientMessage(playerid, COLOR_BLUE, "or press Enter to exit this vehicle");
- }
- if(CarInfo[newcar][cOwned]==1)
- {
- format(string,sizeof(string),"Vehicle registered to %s",CarInfo[newcar][cOwner]);
- SendClientMessage(playerid, COLOR_BLUE, string);
- if(PlayerInfo[playerid][pPcarkey] == vehicle) { }
- else if(PlayerInfo[playerid][pPcarkey2] == vehicle) { }
- else if(PlayerInfo[playerid][pPcarkey3] == vehicle) { }
- else
- {
- if(IsPlayerAdmin(playerid))
- {
- SendClientMessage(playerid, COLOR_GREY, " You can drive this car because you are admin");
- }
- else
- {
- RemovePlayerFromVehicle(playerid);
- SendClientMessage(playerid, COLOR_GREY, "You don't have a key of this vehicle");
- }
- }
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement