Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ---------------- LoadCar (não sei se é importante) ----------------
- public LoadCar()
- {
- new arrCoords[13][64];
- new strFromFile2[256];
- new File: file = fopen("cars.cfg", io_read);
- if (file)
- {
- new idx = 184;
- while (idx < sizeof(CarInfo))
- {
- fread(file, strFromFile2);
- split(strFromFile2, arrCoords, ',');
- 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][cValue] = strval(arrCoords[9]);
- CarInfo[idx][cLicense] = strval(arrCoords[10]);
- CarInfo[idx][cOwned] = strval(arrCoords[11]);
- CarInfo[idx][cLock] = strval(arrCoords[12]);
- printf("CarInfo: %d Owner:%s LicensePlate %s",idx,CarInfo[idx][cOwner],CarInfo[idx][cLicense]);
- 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 == 0)
- {
- file2 = fopen("cars.cfg", io_write);
- }
- else
- {
- file2 = fopen("cars.cfg", io_append);
- }
- fwrite(file2, coordsstring);
- idx++;
- fclose(file2);
- }
- return 1;
- }
- // ---------------- IsAtDealership ----------------
- public IsAtDealership(playerid)
- {
- if(IsPlayerConnected(playerid))
- {
- if(PlayerToPoint(50,playerid,114.9868, 1063.8870, 18.8080))
- {
- return 1;
- }
- }
- return 0;
- }
- // ---------------- Comando /v (apenas a parte de vender) ----------------
- if(strcmp(cmd, "/v", true) == 0 || strcmp(cmd, "/vehicle", true) == 0) //
- {
- if(IsPlayerConnected(playerid))
- {
- if(gPlayerLogged[playerid] == 0)
- {
- SendClientMessage(playerid, COLOR_GREY, " You need to login first ! ");
- return 1;
- }
- 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), sell, sellto, color, carowner");
- return 1;
- }
- if(strcmp(x_nr,"sell",true) == 0)
- {
- if(IsAtDealership(playerid))
- {
- if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey] || GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2] || GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey3])
- {
- GetPlayerName(playerid, sendername, sizeof(sendername));
- new ownvehkey;
- if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { ownvehkey = PlayerInfo[playerid][pPcarkey]; }
- else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2]) { ownvehkey = PlayerInfo[playerid][pPcarkey2]; }
- else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey3]) { ownvehkey = PlayerInfo[playerid][pPcarkey3]; }
- else { return 1; }
- if(strcmp(sendername, CarInfo[ownvehkey][cOwner], true) == 0)
- {
- new carsellprice = CarInfo[ownvehkey][cValue] / 4 * 3;
- new Float:x,Float:y,Float:z;
- new Float:a;
- CarInfo[ownvehkey][cOwned] = 0;
- strmid(CarInfo[ownvehkey][cOwner], "Dealership", 0, strlen("Dealership"), 999);
- SafeGivePlayerMoney(playerid,carsellprice);
- PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
- format(string, sizeof(string), "~w~You have sold your car for: ~n~~g~$%d", carsellprice);
- GameTextForPlayer(playerid, string, 10000, 3);
- GetVehiclePos(ownvehkey, x, y, z);
- GetVehicleZAngle(ownvehkey, a);
- CarInfo[ownvehkey][cLocationx] = x;
- CarInfo[ownvehkey][cLocationy] = y;
- CarInfo[ownvehkey][cLocationz] = z;
- CarInfo[ownvehkey][cAngle] = a;
- if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { PlayerInfo[playerid][pPcarkey] = 999; }
- else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2]) { PlayerInfo[playerid][pPcarkey2] = 999; }
- else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey3]) { PlayerInfo[playerid][pPcarkey3] = 999; }
- RemovePlayerFromVehicle(playerid);
- TogglePlayerControllable(playerid, 1);
- if(PlayerInfo[playerid][pLocal] == ownvehkey)
- {
- SetPlayerInterior(playerid,0);
- SetPlayerPos(playerid,CarInfo[ownvehkey][cLocationx],CarInfo[ownvehkey][cLocationy],CarInfo[ownvehkey][cLocationz]);
- PlayerInfo[playerid][pInt] = 0;
- }
- OnPropUpdate();
- OnPlayerUpdate(playerid);
- DestroyVehicle(ownvehkey);
- CreateVehicle(CarInfo[ownvehkey][cModel],CarInfo[ownvehkey][cLocationx],CarInfo[ownvehkey][cLocationy],CarInfo[ownvehkey][cLocationz]+1.0,CarInfo[ownvehkey][cAngle],CarInfo[ownvehkey][cColorOne],CarInfo[ownvehkey][cColorTwo],60000);
- return 1;
- }
- }
- else
- {
- SendClientMessage(playerid, COLOR_GREY, " You have to sit at your own car to sell it! ");
- return 1;
- }
- }
- else
- {
- SendClientMessage(playerid, COLOR_GREY, "You are not at a dealership");
- return 1;
- }
- }
- else if(strcmp(x_nr,"sellto",true) == 0)
- {
- if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey] || GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2] || GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey3])
- {
- GetPlayerName(playerid, sendername, sizeof(sendername));
- new ownvehkey;
- if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { ownvehkey = PlayerInfo[playerid][pPcarkey]; }
- else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2]) { ownvehkey = PlayerInfo[playerid][pPcarkey2]; }
- else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey3]) { ownvehkey = PlayerInfo[playerid][pPcarkey3]; }
- else { return 1; }
- if(strcmp(sendername, CarInfo[ownvehkey][cOwner], true) == 0)
- {
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, COLOR_WHITE, "HINT: /v sellto [playerid/PartOfName] [price]");
- return 1;
- }
- giveplayerid = ReturnUser(tmp);
- if(IsPlayerConnected(giveplayerid))
- {
- if(giveplayerid != INVALID_PLAYER_ID)
- {
- if(ProxDetectorS(8.0, playerid, giveplayerid))
- {
- if(PlayerInfo[giveplayerid][pPcarkey] == 999)
- {
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, COLOR_WHITE, "HINT: /v sellto [playerid/PartOfName] [price]");
- return 1;
- }
- new price;
- price = strval(tmp);
- if(price < 1 || price > 1500000)
- {
- SendClientMessage(playerid, COLOR_GREY, " Price not lower then 1 and not higher then 1500000. ");
- return 1;
- }
- GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
- format(string, sizeof(string), "* You offerd %s to buy your car for $%d .", giveplayer, price);
- SendClientMessage(playerid, COLOR_WHITE, string);
- format(string, sizeof(string), "* Car Owner %s offered you to buy his/her car for $%d (type /accept ownablecar) to buy.", playername, price);
- SendClientMessage(giveplayerid, COLOR_WHITE, string);
- OwnableCarOffer[giveplayerid] = playerid;
- OwnableCarID[giveplayerid] = ownvehkey;
- OwnableCarPrice[giveplayerid] = price;
- return 1;
- }
- else if(PlayerInfo[giveplayerid][pPcarkey2] == 999)
- {
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, COLOR_WHITE, "HINT: /v sellto [playerid/PartOfName] [price]");
- return 1;
- }
- new price;
- price = strval(tmp);
- if(price < 1 || price > 1500000)
- {
- SendClientMessage(playerid, COLOR_GREY, " Price not lower then 1 and not higher then 1500000. ");
- return 1;
- }
- GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
- format(string, sizeof(string), "* You offerd %s to buy your car for $%d .", giveplayer, price);
- SendClientMessage(playerid, COLOR_WHITE, string);
- format(string, sizeof(string), "* Car Owner %s offered you to buy his/her car for $%d (type /accept ownablecar) to buy.", playername, price);
- SendClientMessage(giveplayerid, COLOR_WHITE, string);
- OwnableCarOffer[giveplayerid] = playerid;
- OwnableCarID[giveplayerid] = ownvehkey;
- OwnableCarPrice[giveplayerid] = price;
- return 1;
- }
- else if(PlayerInfo[giveplayerid][pPcarkey3] == 999)
- {
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, COLOR_WHITE, "HINT: /v sellto [playerid/PartOfName] [price]");
- return 1;
- }
- new price;
- price = strval(tmp);
- if(price < 1 || price > 1500000)
- {
- SendClientMessage(playerid, COLOR_GREY, " Price not lower then 1 and not higher then 1500000. ");
- return 1;
- }
- GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
- format(string, sizeof(string), "* You offerd %s to buy your car for $%d .", giveplayer, price);
- SendClientMessage(playerid, COLOR_WHITE, string);
- format(string, sizeof(string), "* Car Owner %s offered you to buy his/her car for $%d (type /accept ownablecar) to buy.", playername, price);
- SendClientMessage(giveplayerid, COLOR_WHITE, string);
- OwnableCarOffer[giveplayerid] = playerid;
- OwnableCarID[giveplayerid] = ownvehkey;
- OwnableCarPrice[giveplayerid] = price;
- return 1;
- }
- else
- {
- SendClientMessage(playerid, COLOR_GREY, " Player has 3 cars already ! ");
- return 1;
- }
- }
- else
- {
- SendClientMessage(playerid, COLOR_GREY, " Player is not near you ! ");
- return 1;
- }
- }
- }
- }
- else
- {
- SendClientMessage(playerid, COLOR_GREY, " This is not your car");
- return 1;
- }
- }
- else
- {
- SendClientMessage(playerid, COLOR_GREY, " You have to sit at your own car to sell it");
- return 1;
- }
- }
- // ---------------- Comando /asellcar e /acarsell (admin vender um carro)(penso que são comandos iguais) ----------------
- if(!strcmp(cmdtext, "/asellcar", true))
- {
- if(IsPlayerConnected(playerid))
- {
- if(gPlayerLogged[playerid] == 0)
- {
- SendClientMessage(playerid, COLOR_GREY, " You need to login first !");
- return 1;
- }
- if(!IsAtDealership(playerid))
- {
- SendClientMessage(playerid, COLOR_GREY, " You are not at dealership ! ");
- return 1;
- }
- if(PlayerInfo[playerid][pAdmin] >= 1337)
- {
- new vehid = GetPlayerVehicleID(playerid);
- new Float:x,Float:y,Float:z;
- new Float:a;
- CarInfo[vehid][cOwned] = 0;
- strmid(CarInfo[vehid][cOwner], "Dealership", 0, strlen("Dealership"), 999);
- PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
- GameTextForPlayer(playerid, "~w~You have admin sold the vehicle", 10000, 3);
- GetVehiclePos(vehid, x, y, z);
- GetVehicleZAngle(vehid, a);
- CarInfo[vehid][cLocationx] = x;
- CarInfo[vehid][cLocationy] = y;
- CarInfo[vehid][cLocationz] = z;
- CarInfo[vehid][cAngle] = a;
- RemovePlayerFromVehicle(playerid);
- TogglePlayerControllable(playerid, 1);
- OnPropUpdate();
- DestroyVehicle(vehid);
- CreateVehicle(CarInfo[vehid][cModel],CarInfo[vehid][cLocationx],CarInfo[vehid][cLocationy],CarInfo[vehid][cLocationz]+1.0,CarInfo[vehid][cAngle],CarInfo[vehid][cColorOne],CarInfo[vehid][cColorTwo],60000);
- return 1;
- }
- else
- {
- SendClientMessage(playerid, COLOR_GREY, " You're not authorized to use that command !");
- return 1;
- }
- }
- return 1;
- }
- if(strcmp(cmd, "/acarsell", true) == 0)
- {
- if(IsPlayerConnected(playerid))
- {
- GetPlayerName(playerid, playername, sizeof(playername));
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /acarsell [bizid]");
- return 1;
- }
- new car = strval(tmp);
- if(PlayerInfo[playerid][pAdmin] >= 4)
- {
- strmid(CarInfo[car][cOwner], "Dealership", 0, strlen("Dealership"), 999);
- PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
- CarInfo[car][cOwned] = 0;
- CarInfo[car][cLock] = 1;
- format(string, sizeof(string), "~w~You have sold the Car");
- GameTextForPlayer(playerid, string, 2500, 3);
- OnPropUpdate();
- }
- else
- {
- SendClientMessage(playerid, COLOR_WHITE, "You are not an admin.");
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement