Пивет всем, Вот решил выложить Новый Авторынок!
Возможности: -
Управление авто(в диалоге).
Комманда: /carmenu
Кстати, Авто можно добавлять прям из игры /addveh!
И, так начнём\ Если нету то добавьте >
Ко всем new
Теперь в > OnGameModeExit()
Теперь в > public OnPlayerConnect(playerid)
Теперь добавим паблики >
Теперь в > public OnPlayerCommandText(playerid, cmdtext[])
Теперь в public OnPlayerStateChange(playerid, newstate, oldstate)
Добавляем Паблики!
Теперь в >
Теперь добавим диалоги > public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
Теперь в конец мода >
Теперь добавим в папку scriptfiles http://rghost.ru/31461491
Ну вот и всё!
+ Я его еще чуть Доработал!
Нашли ощибки напищите
Возможности: -
Управление авто(в диалоге).
Комманда: /carmenu
- Код:
[Открыть/Закрыть] TC
Починить ($2000)
Покрасить ($2000)
Припарковать транспорт
Отбуксировать на парковку
Определить местоположение
Контроль (двигатель, фары, багажник)
Продать TC
- Код:
/carmenu sellto [id игрока] [цена]
Кстати, Авто можно добавлять прям из игры /addveh!
И, так начнём\ Если нету то добавьте >
- Код:
#include <utils>
- Код:
#define MAX_LEN_NAME 40
#define DIALOG_POKUPKA_AUTO 3754
#define DIALOG_VMENU 3755
#define DIALOG_VKMENU 3756
#define DIALOG_VNMENU 3757
#define DIALOG_AUTO_COLOR1 3758
#define DIALOG_AUTO_COLOR2 3759
#define Public:%0(%1) forward %0(%1); \
public %0(%1)// Оптимизация!
Ко всем new
- Код:
new VehiclesName[][] =
{
"Landstalker", "Bravura", "Buffalo", "Linerunner", "Pereniel", "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", "Previon", "Coach", "Cabbie", "Stallion", "Rumpo", "RC Bandit",
"Romero", "Packer", "Monster Truck", "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",
"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", "Hotring Racer", "Bloodring Banger", "Rancher", "Super GT", "Elegant", "Journey", "Bike", "Mountain Bike", "Beagle",
"Cropdust", "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",
"Yosemite", "Windsor", "Monster Truck", "Monster Truck", "Uranus", "Jester", "Sultan", "Stratum", "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma",
"Savanna", "Bandito", "Freight", "Trailer", "Kart", "Mower", "Duneride", "Sweeper", "Broadway", "Tornado", "AT-400", "DFT-30", "Huntley", "Stafford", "BF-400",
"Newsvan", "Tug", "Trailer", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club", "Trailer", "Trailer", "Andromada", "Dodo", "RC Cam", "Launch", "Police Car (LS)",
"Police Car (SF)", "Police Car (LV)", "Police Ranger", "Picador", "S.W.A.T. Van", "Alpha", "Phoenix", "Glendale", "Sadler", "Luggage Trailer", "Luggage Trailer",
"Stair Trailer", "Boxville", "Farm Plow", "Utility Trailer"
};
new FP_OwnableCar[500];
new Text3D:vehicle3Dtext[500];
new engine,lights,alarm,doors,bonnet,boot,objective;
new Engine[500];
new Light[500];
new Bonnet[500];
new Boot[500];
new neon[500];
new neon1[500];
new vehcolor1[MAX_PLAYERS];
new vehcolor2[MAX_PLAYERS];
new OWNABLECARS;
new FP_CarKey[MAX_PLAYERS];
new MyCarID[MAX_PLAYERS];
new MyCarOffer[MAX_PLAYERS];
new MyCarMoney[MAX_PLAYERS];
- Код:
enum ocInfo
{
ocId,
Float:ocCar_x,
Float:ocCar_y,
Float:ocCar_z,
Float:ocCar_a,
ocColor1,
ocColor2,
ocOwner[64],
ocLock,
ocCost,
ocSpoiler,
ocHood,
ocSideskirt,
ocNitro,
ocLamps,
ocExhaust,
ocWheels,
ocRoof,
ocStereo,
ocHydraulics,
ocBullbar,
ocRearBullbars,
ocFrontSign,
ocFrontBullbars,
ocFrontBumper,
ocRearBumper,
ocVents,
ocPaintJob,
ocKey
};
new FP_CarInfo[500][ocInfo];
- Код:
LoadOwnableCars();
SetTimer("SpawnVeh",1000,0);
for(new i=0;i<MAX_PLAYERS;i++){if(IsPlayerConnected(i)) PlayerCars(i); }
Теперь в > OnGameModeExit()
- Код:
for(new idx = 1 ; idx <= OWNABLECARS; idx++)
{
DestroyVehicle(FP_OwnableCar[idx]);
Delete3DTextLabel(vehicle3Dtext[idx]);
}
Теперь в > public OnPlayerConnect(playerid)
- Код:
PlayerCars(playerid);
MyCarID[playerid] = 0;
MyCarOffer[playerid] = 999;
MyCarMoney[playerid] = 0;
Теперь добавим паблики >
- Код:
public OnVehicleSpawn(vehicleid)
{
if(IsAOwnableVehicle(vehicleid))
{
new number = GetVehicleID(vehicleid);
SetVehicleZAngle(vehicleid, FP_CarInfo[number][ocCar_a]);
SetVehiclePos(vehicleid, FP_CarInfo[number][ocCar_x], FP_CarInfo[number][ocCar_y], FP_CarInfo[number][ocCar_z]+1);
ChangeVehicleColor(vehicleid,FP_CarInfo[number][ocColor1],FP_CarInfo[number][ocColor2]);
SetVehicleNumberPlate(vehicleid, " ");
SetTimerEx("OnVehicleSpawnAngle",500,false,"i",number);
ModCar(number);
}
return 1;
}
Public:OnVehicleSpawnAngle(vehicleid)
{
if(IsAOwnableVehicle(FP_OwnableCar[vehicleid])) SetVehicleZAngle(FP_OwnableCar[vehicleid], FP_CarInfo[vehicleid][ocCar_a]);
return 1;
}
Теперь в > public OnPlayerCommandText(playerid, cmdtext[])
- Код:
new name[MAX_LEN_NAME];
GetPlayerName(playerid, name, sizeof(name));
if(strcmp(cmd, "/mycar", true) == 0)
{
if(FP_CarKey[playerid] == 0)return SendClientMessage(playerid,COLOR_GREY,"У тебя нет личного транспорта.");
format(string, sizeof(string), "Модель: %s",VehiclesName[GetVehicleModel(FP_OwnableCar[FP_CarKey[playerid]])-400]);
SendClientMessage(playerid,COLOR_WHITE,string);
return 1;
}
if(strcmp(cmd,"/carmenu",true)==0 || strcmp(cmdtext, "/сфкьутг", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new x_job[256];
x_job = strtok(cmdtext, idx);
if(!strlen(x_job)) {
if(FP_CarKey[playerid] == 0)return SendClientMessage(playerid,COLOR_GREY,"У тебя нет личного транспорта.");
ShowPlayerDialog(playerid,DIALOG_VMENU,DIALOG_STYLE_LIST,"Авторынок","{FFFFFF}[Открыть|Закрыть] Транспорт\n\
Починить ($2000)\n\
Покрасить ($2000)\n\
Припарковать транспорт\n\
Отбуксировать на парковку\n\
Определить местоположение\n\
Контроль (двигатель, фары, багажник)\n\
Продать транспорт","Выбрать","Отмена");
return 1;
}
//------------------------------------------------------------------------------
if(strcmp(x_job,"buy",true) == 0)
{
if(FP_CarKey[playerid] != 0)return SendClientMessage(playerid,COLOR_GREY,"У вас уже есть личный транспорт.");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GREY, "Ты должен находиться в транспорте!");
new buycar = GetPlayerVehicleID(playerid),number = GetVehicleID(buycar);
if(!IsAOwnableVehicle(buycar))return SendClientMessage(playerid,COLOR_GREY,"Этот транспорт не для продажи.");
if(!strcmp(FP_CarInfo[number][ocOwner],"The State",true))
{
if(GetPlayerMoney(playerid) < FP_CarInfo[number][ocCost])
{
SendClientMessage(playerid, COLOR_GREY, "У вас недостаточно денег для покупки.");
RemoveFromVehicle(playerid);
return 1;
}
SendClientMessage(playerid, COLOR_WHITE, "Поздравляю! Теперь этот транспорт принадлежит тебе!");
GivePlayerMoney(playerid,-FP_CarInfo[number][ocCost]);
strmid(FP_CarInfo[number][ocOwner], name, 0, strlen(name), 999);
FP_CarInfo[number][ocLock] = 1;
GetVehicleParamsEx(buycar,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(buycar,engine,lights,alarm,1,bonnet,boot,objective);
FP_CarKey[playerid] = number;
SaveOwnableCars();
TogglePlayerControllable(playerid,1);
format(string, sizeof(string), "[Владелец: %s]",FP_CarInfo[number][ocOwner]);
Update3DTextLabelText(vehicle3Dtext[number], 0xFFA500AA,string);
return 1;
}
return 1;
}
//------------------------------------------------------------------------------
if(strcmp(x_job,"sell", true) == 0)
{
if(FP_CarKey[playerid] == 0)return SendClientMessage(playerid,COLOR_GREY,"У тебя нет личного транспорта.");
new carid = FP_CarKey[playerid];
strmid(FP_CarInfo[carid][ocOwner], "The State", 0, strlen("The State"), 999);
FP_CarInfo[carid][ocColor1] = -1;
FP_CarInfo[carid][ocColor2] = -1;
FP_CarInfo[carid][ocLock] = 0;
GetVehicleParamsEx(FP_OwnableCar[carid],engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(FP_OwnableCar[carid],engine,lights,alarm,0,bonnet,boot,objective);
FP_CarInfo[carid][ocSpoiler] = 0;
FP_CarInfo[carid][ocHood] = 0;
FP_CarInfo[carid][ocSideskirt] = 0;
FP_CarInfo[carid][ocNitro] = 0;
FP_CarInfo[carid][ocLamps] = 0;
FP_CarInfo[carid][ocExhaust] = 0;
FP_CarInfo[carid][ocWheels] = 0;
FP_CarInfo[carid][ocRoof] = 0;
FP_CarInfo[carid][ocStereo] = 0;
FP_CarInfo[carid][ocHydraulics] = 0;
FP_CarInfo[carid][ocBullbar] = 0;
FP_CarInfo[carid][ocRearBullbars] = 0;
FP_CarInfo[carid][ocFrontSign] = 0;
FP_CarInfo[carid][ocFrontBullbars] = 0;
FP_CarInfo[carid][ocFrontBumper] = 0;
FP_CarInfo[carid][ocRearBumper] = 0;
FP_CarInfo[carid][ocVents] = 0;
FP_CarInfo[carid][ocPaintJob] = -1;
GivePlayerMoney(playerid,FP_CarInfo[carid][ocCost]);
format(string, sizeof(string), "~w~B‘ ЊPOѓA‡… CBOE ЏC €A ~n~~g~$%d", FP_CarInfo[carid][ocCost]);
GameTextForPlayer(playerid, string, 10000, 3);
SaveOwnableCars();
FP_CarKey[playerid] = 0;
RemoveFromVehicle(playerid);
format(string, sizeof(string), "Этот транспорт продаётся\n[Модель: %s]\n[Цена: %d$]",VehiclesName[GetVehicleModel(FP_OwnableCar[carid])-400], FP_CarInfo[carid][ocCost]);
Update3DTextLabelText(vehicle3Dtext[carid], COLOR_WHITE,string);
return 1;
}
//------------------------------------------------------------------------------
if(strcmp(x_job,"sellto", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))return SendClientMessage(playerid, COLOR_GREY, "ИНФО: /carmenu sellto [id игрока] [цена] ");
new playa = ReturnUser(tmp);
if(playa == playerid)return SendClientMessage(playerid,COLOR_GREY,"Ты не можешь продать транспорт себе.");
if(!IsPlayerConnected(playa))return SendClientMessage(playerid,COLOR_GREY,"Этот игрок не в сети.");
if(!ProxDetectorS(5.0, playerid, playa))return SendClientMessage(playerid,COLOR_GREY,"Вы слишком далеко друг от друга.");
tmp = strtok(cmdtext, idx);
new price = strval(tmp);
if(!strlen(tmp))return SendClientMessage(playerid, COLOR_GREY, "ИНФО: /carmenu sellto [id игрока] [цена] ");
if(price < 0)return SendClientMessage(playerid,COLOR_GREY,"Цена не может быть отрицательной.");
new Float:x,Float:y,Float:z;
GetVehiclePos(FP_OwnableCar[FP_CarKey[playerid]],x,y,z);
if(!IsPlayerInRangeOfPoint(playerid,10,x,y,z) || !IsPlayerInRangeOfPoint(playa,10,x,y,z))
return SendClientMessage(playerid,COLOR_GREY,"Вы должны находиться около автомобиля.");
MyCarID[playa] = FP_OwnableCar[FP_CarKey[playerid]];
MyCarOffer[playa] = playerid;
MyCarMoney[playa] = price;
new sendername[MAX_PLAYER_NAME],giveplayer[MAX_PLAYER_NAME];
GetPlayerName(playerid,sendername,sizeof(sendername));
GetPlayerName(playa,giveplayer,sizeof(giveplayer));
format(string,sizeof(string),"* Ты предлагаешь %s купить у тебя машину за $%d.",giveplayer,price);
SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
format(string,sizeof(string),"* %s предлагает тебе купить у него машину за $%d.",sendername,price);
SendClientMessage(playa,COLOR_LIGHTBLUE,string);
SendClientMessage(playa,COLOR_LIGHTBLUE," Используй /carmenu buyto , чтобы согласиться.");
return 1;
}
//------------------------------------------------------------------------------
if(strcmp(x_job,"buyto", true) == 0)
{
if(MyCarOffer[playerid] == 999) return SendClientMessage(playerid,COLOR_GREY,"Никто не предлагал тебе купить транспорт.");
if(!ProxDetectorS(5.0, playerid, MyCarOffer[playerid]))return SendClientMessage(playerid,COLOR_GREY,"Вы слишком далеко друг от друга.");
new Float:x,Float:y,Float:z;
GetVehiclePos(FP_OwnableCar[FP_CarKey[playerid]],x,y,z);
if(!IsPlayerInRangeOfPoint(playerid,10,x,y,z) || !IsPlayerInRangeOfPoint(MyCarOffer[playerid],10,x,y,z))
return SendClientMessage(playerid,COLOR_GREY,"Вы должны находиться около автомобиля.");
FP_CarKey[playerid] = FP_CarKey[MyCarOffer[playerid]];
FP_CarKey[MyCarOffer[playerid]] = 0;
GivePlayerMoney(playerid,MyCarMoney[playerid]);
GivePlayerMoney(MyCarOffer[playerid],-MyCarMoney[playerid]);
new sendername[MAX_PLAYER_NAME],giveplayer[MAX_PLAYER_NAME];
GetPlayerName(playerid,sendername,sizeof(sendername));
GetPlayerName(MyCarOffer[playerid],giveplayer,sizeof(giveplayer));
format(string,sizeof(string),"* Ты купил транспорт у %s за $%d.",giveplayer,MyCarMoney);
SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
format(string,sizeof(string),"* %s купил у тебя транспорт за $%d.",sendername,MyCarMoney);
SendClientMessage(MyCarOffer[playerid],COLOR_LIGHTBLUE,string);
strmid(FP_CarInfo[FP_CarKey[playerid]][ocOwner], sendername, 0, strlen(sendername), 999);
SaveOwnableCars();
RemoveFromVehicle(playerid);
format(string, sizeof(string), "Этот транспорт продаётся\n[Модель: %s]\n[Цена: %d$]",VehiclesName[GetVehicleModel(FP_CarKey[playerid])-400], FP_CarInfo[FP_CarKey[playerid]][ocCost]);
Update3DTextLabelText(vehicle3Dtext[FP_CarKey[playerid]], COLOR_WHITE,string);
MyCarID[playerid] = 0;
MyCarOffer[playerid] = 999;
MyCarMoney[playerid] = 0;
return 1;
}
//------------------------------------------------------------------------------
if(strcmp(x_job,"lock", true) == 0)
{
if(FP_CarKey[playerid] == 0)return SendClientMessage(playerid,COLOR_GREY,"У тебя нет личного транспорта.");
GetVehicleParamsEx(FP_OwnableCar[FP_CarKey[playerid]],engine,lights,alarm,doors,bonnet,boot,objective);
if(FP_CarInfo[FP_CarKey[playerid]][ocLock] == 0)
{
SetVehicleParamsEx(FP_OwnableCar[FP_CarKey[playerid]],engine,lights,alarm,1,bonnet,boot,objective);
FP_CarInfo[FP_CarKey[playerid]][ocLock] = 1;
GameTextForPlayer(playerid,"~w~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~ЏPAмCЊOPЏ~r~ €AKP‘Џ",3000,3);
}
else
{
SetVehicleParamsEx(FP_OwnableCar[FP_CarKey[playerid]],engine,lights,alarm,0,bonnet,boot,objective);
FP_CarInfo[FP_CarKey[playerid]][ocLock] = 0;
GameTextForPlayer(playerid,"~w~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~ЏPAмCЊOPЏ~g~ OЏKP‘Џ",3000,3);
}
return 1;
}
//-----------------------------------------------------------------------------
if(strcmp(x_job,"park", true) == 0)
{
if(FP_CarKey[playerid] == 0)return SendClientMessage(playerid,COLOR_GREY,"У тебя нет личного транспорта.");
if(!IsPlayerInVehicle(playerid,FP_OwnableCar[FP_CarKey[playerid]])) return SendClientMessage(playerid, COLOR_GREY, "Ты должен находиться в личном транспорте.");
new Float:Pos[4];
GetVehiclePos(FP_OwnableCar[FP_CarKey[playerid]],Pos[0], Pos[1], Pos[2]);
GetVehicleZAngle(FP_OwnableCar[FP_CarKey[playerid]], Pos[3]);
FP_CarInfo[FP_CarKey[playerid]][ocCar_x] = Pos[0];
FP_CarInfo[FP_CarKey[playerid]][ocCar_y] = Pos[1];
FP_CarInfo[FP_CarKey[playerid]][ocCar_z] = Pos[2];
FP_CarInfo[FP_CarKey[playerid]][ocCar_a] = Pos[3];
GameTextForPlayer(playerid, "~g~~/n~ ~/n~ ~/n~ ~/n~ ~/n~ ~/n~ЏEЊEP’ ЏBO† ЏPAмCЊOPЏ ЂYѓEЏ CЏO•Џ’ €ѓEC’", 5000, 3);
SaveOwnableCars();
return 1;
}
//------------------------------------------------------------------------------
if(strcmp(x_job,"color", true) == 0)
{
if(FP_CarKey[playerid] == 0)return SendClientMessage(playerid,COLOR_GREY,"У тебя нет личного транспорта.");
if(GetPlayerMoney(playerid) < 2000) return SendClientMessage(playerid,COLOR_GREY," Тебе нужно $2000 для этого!");
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_WHITE," ИНФО: /carmenu color [1-300] [1-300] ");
new para1, para2, carid = FP_CarKey[playerid];
para1 = strval(tmp);
tmp = strtok(cmdtext, idx);
para2 = strval(tmp);
ChangeVehicleColor(FP_OwnableCar[carid],para1,para2);
FP_CarInfo[carid][ocColor1] = para1;
FP_CarInfo[carid][ocColor2] = para2;
SaveOwnableCars();
GivePlayerMoney(playerid,-2000);
SendClientMessage(playerid,COLOR_WHITE," Ты заплатил за перекраску автомобиля 2000$!");
return 1;
}
//------------------------------------------------------------------------------
if(strcmp(x_job,"car", true) == 0)
{
if(FP_CarKey[playerid] == 0)return SendClientMessage(playerid,COLOR_GREY,"У тебя нет личного транспорта.");
new Float:X,Float:Y,Float:Z;
GetVehiclePos(FP_OwnableCar[FP_CarKey[playerid]], X,Y,Z);
SetPlayerCheckpoint(playerid,X,Y,Z,2.5);
SendClientMessage(playerid,COLOR_WHITE,"Местоположение транспорта указано на карте!");
return 1;
}
//------------------------------------------------------------------------------
if(strcmp(x_job,"topark", true) == 0)
{
if(FP_CarKey[playerid] == 0)return SendClientMessage(playerid,COLOR_GREY,"У тебя нет личного транспорта.");
if(GetPlayerMoney(playerid) < 1500)return SendClientMessage(playerid,COLOR_GREY,"Тебе нужно $1500 для этого!");
SetVehicleToRespawn(FP_OwnableCar[FP_CarKey[playerid]]);
GivePlayerMoney(playerid,-1500);
SendClientMessage(playerid,COLOR_GREY," Личный транспорт доставлен на место парковки!");
return 1;
}
//------------------------------------------------------------------------------
if(strcmp(x_job,"fix", true) == 0)
{
if(FP_CarKey[playerid] == 0)return SendClientMessage(playerid,COLOR_GREY,"У тебя нет личного транспорта.");
if(GetPlayerMoney(playerid) < 2000) return SendClientMessage(playerid,COLOR_GREY,"Тебе нужно $2000 для этого!");
SetVehicleHealth(FP_OwnableCar[FP_CarKey[playerid]], 1000.0);
RepairVehicle(FP_OwnableCar[FP_CarKey[playerid]]);
SendClientMessage(playerid, COLOR_WHITE, "Ты заплатил за починку автомобиля 2000$!");
GivePlayerMoney(playerid,-2000);
return 1;
}
if(strcmp(x_job,"control", true) == 0)
{
ShowPlayerDialog(playerid,DIALOG_VKMENU,DIALOG_STYLE_LIST,"Авторынок","Двигатель\n\
Фары\n\
Капот\n\
Багажник\n\
Неон","Выбрать","Отмена");
return 1;
}
}
return 1;
}
if(strcmp(cmd, "/addveh", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if (PlayerInfo[playerid][pAdmin] >= 6)// Меняем на своё!
{
if(!IsPlayerInAnyVehicle(playerid))return SendClientMessage(playerid,COLOR_GREY,"Тебе нужно быть в транспорте");
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))return SendClientMessage(playerid, COLOR_WHITE, "ИНФО: /addveh [carid] [цена]");
new car;
car = strval(tmp);
if(car < 400 || car > 611) { SendClientMessage(playerid, COLOR_GREY, "От 400 до 611!"); return 1; }
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))return SendClientMessage(playerid, COLOR_WHITE, "ИНФО: /addveh [carid] [цена]");
new price;
price = strval(tmp);
if(price < 0 ) { SendClientMessage(playerid, COLOR_GREY, "Цена не может быть отрицательной!"); return 1; }
new Float:X,Float:Y,Float:Z,Float:A;
GetVehiclePos(GetPlayerVehicleID(playerid), X,Y,Z);
GetVehicleZAngle(GetPlayerVehicleID(playerid),A);
OWNABLECARS ++;
FP_CarInfo[OWNABLECARS][ocId] = car;
FP_CarInfo[OWNABLECARS][ocColor1] = -1;
FP_CarInfo[OWNABLECARS][ocColor2] = -1;
FP_CarInfo[OWNABLECARS][ocPaintJob] = -1;
FP_CarInfo[OWNABLECARS][ocCost] = price;
FP_CarInfo[OWNABLECARS][ocCar_x] = X;
FP_CarInfo[OWNABLECARS][ocCar_y] = Y;
FP_CarInfo[OWNABLECARS][ocCar_z] = Z;
FP_CarInfo[OWNABLECARS][ocCar_a] = A;
strmid(FP_CarInfo[OWNABLECARS][ocOwner], "The State", 0, 9, 999);
SaveOwnableCars();
format(string, sizeof(string), "* Машина на продажу номер %d создана.", OWNABLECARS);
SendClientMessage(playerid, COLOR_GREY, string);
FP_OwnableCar[OWNABLECARS] = AddStaticVehicleEx(FP_CarInfo[OWNABLECARS][ocId], FP_CarInfo[OWNABLECARS][ocCar_x], FP_CarInfo[OWNABLECARS][ocCar_y], FP_CarInfo[OWNABLECARS][ocCar_z]+1, FP_CarInfo[OWNABLECARS][ocCar_a], -1, -1,30000);
format(string, sizeof(string), "Транспорт продаётся\n[Модель: %s]\n[Цена: %d$]",VehiclesName[GetVehicleModel(FP_OwnableCar[OWNABLECARS])-400], FP_CarInfo[OWNABLECARS][ocCost]);
vehicle3Dtext[OWNABLECARS] = Create3DTextLabel(string, 0xFFA500AA,FP_CarInfo[OWNABLECARS][ocCar_x], FP_CarInfo[OWNABLECARS][ocCar_y], FP_CarInfo[OWNABLECARS][ocCar_z]+2.5,15.0, 0, 1 );
Attach3DTextLabelToVehicle(vehicle3Dtext[OWNABLECARS], FP_OwnableCar[OWNABLECARS], 0.0, 0.0, 1.6 );
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "У вас нет доступа к этой комманде!");
return 1;
}
}
return 1;
}
Теперь в public OnPlayerStateChange(playerid, newstate, oldstate)
- Код:
new string[128];
if(newstate == PLAYER_STATE_DRIVER)
{
if(IsAOwnableVehicle(GetPlayerVehicleID(playerid)))
{
new number = GetVehicleID(GetPlayerVehicleID(playerid));
if(!strcmp(FP_CarInfo[number][ocOwner],"The State",true))
{
format(string, sizeof(string), "Транспорт на продажу\nМодель: %s\nЦена: %d$",VehiclesName[GetVehicleModel(FP_OwnableCar[number])-400], FP_CarInfo[number][ocCost]);
ShowPlayerDialog(playerid,DIALOG_POKUPKA_AUTO,DIALOG_STYLE_MSGBOX,"Авторынок",string,"Купить","Выйти");
TogglePlayerControllable(playerid,0);
}
}
}
в =\ public OnPlayerEnterCheckpoint(playerid)
DisablePlayerCheckpoint(playerid);
Добавляем Паблики!
- Код:
Public:OnVehicleMod(playerid, vehicleid, componentid)
{
if(IsAOwnableVehicle(vehicleid))
{
new c = componentid,number = GetVehicleID(vehicleid);
if( (c >= 1000 && c <= 1003) || (c >= 1014 && c <= 1016) || c == 1023 || c == 1049 || c == 1050 || c ==1058 ||
c == 1060 || c == 1138 || c == 1139 || c == 1146 || c == 1147 || c == 1158 || (c >= 1162 && c <= 1164))
{
FP_CarInfo[number][ocSpoiler] = c;
}
else if (c== 1004 || c == 1005 || c == 1011 || c == 1012)
{
FP_CarInfo[number][ocHood] = c;
}
else if (c== 1007 || c == 1017 || c == 1026 || c == 1027 || c == 1030 || c == 1031 || c == 1036 ||
(c >= 1039 && c <= 1042) || c == 1047 || c == 1048 || c == 1051 || c == 1052 || c == 1056 ||
c == 1057 || c == 1062 || c == 1063 || ( c >= 1069 && c <= 1072) || c == 1090 || ( c >= 1093 && c <= 1095) ||
c == 1099 || c == 1101 || c == 1102 || ( c >= 1106 && c <= 1108) || ( c >= 1119 && c <= 1122) || c == 1124 || c == 1133 || c == 1134 || c == 1137)
{
FP_CarInfo[number][ocSideskirt] = c;
}
else if (c >= 1008 && c <= 1010)
{
FP_CarInfo[number][ocNitro] = c;
}
else if (c == 1013 || c == 1024)
{
FP_CarInfo[number][ocLamps] = c;
}
else if (( c >= 1018 && c <= 1022) || c == 1028 || c == 1029 || c == 1034 || c == 1037 ||
( c >= 1043 && c <= 1046) || c == 1059 || ( c >= 1064 && c <= 1066) ||
c == 1089 || c == 1092 || c == 1004 || c == 1105 || c == 1113 || c == 1114 ||
c == 1126 || c == 1127 || c == 1129 || c == 1132 || c == 1135 || c == 1136)
{
FP_CarInfo[number][ocExhaust] = c;
}
else if (c == 1025 || ( c >= 1073 && c <= 1085) || ( c >= 1096 && c <= 1098))
{
FP_CarInfo[number][ocWheels] = c;
}
else if (c == 1006 || c == 1032 || c == 1033 || c == 1035 || c == 1038 || (c >= 1053 && c <= 1055) ||
c == 1061 || c == 1067 || c == 1068 || c == 1088 || c == 1091 || c == 1103 || c == 1128 || c == 1130 || c == 1131 )
{
FP_CarInfo[number][ocRoof] = c;
}
else if (c == 1086)
{
FP_CarInfo[number][ocStereo] = c;
}
else if (c == 1087)
{
FP_CarInfo[number][ocHydraulics] = c;
}
else if (c == 1100 || c == 1123 || c == 1125)
{
FP_CarInfo[number][ocBullbar] = c;
}
else if (c == 1109 || c == 1110)
{
FP_CarInfo[number][ocRearBullbars] = c;
}
else if (c == 1111 || c == 1112)
{
FP_CarInfo[number][ocFrontSign] = c;
}
else if (c == 1115 || c == 1116)
{
FP_CarInfo[number][ocFrontBullbars] = c;
}
else if (c == 1117 || c == 1152 || c == 1153 || c == 1155 || c == 1157 || c == 1160 || c == 1165 || c == 1166 ||
(c >= 1169 && c <= 1174) || c == 1176 || c == 1179 || c == 1181 || c == 1182 || c == 1185 || (c >= 1188 && c <= 1191))
{
FP_CarInfo[number][ocFrontBumper] = c;
}
else if (c == 1140 || c == 1141 || (c >= 1148 && c <= 1151) || c == 1154 || c == 1156 || c == 1159 || c == 1161 || c == 1167 ||
c == 1168 || c == 1175 || c == 1177 || c == 1178 || c == 1180 || c == 1183 || c == 1184 || c == 1186 || c == 1187 || c == 1192 || c == 1193)
{
FP_CarInfo[number][ocRearBumper] = c;
}
else if (c >= 1142 && c <= 1145)
{
FP_CarInfo[number][ocVents] = c;
}
SaveOwnableCars();
}
return 1;
}
Public:ModCar(carid)
{
if(IsAOwnableVehicle(FP_OwnableCar[carid]))
{
if(FP_CarInfo[carid][ocSpoiler] != 0) AddVehicleComponent(FP_OwnableCar[carid],FP_CarInfo[carid][ocSpoiler]);
if(FP_CarInfo[carid][ocHood] != 0) AddVehicleComponent(FP_OwnableCar[carid],FP_CarInfo[carid][ocHood]);
if(FP_CarInfo[carid][ocSideskirt] != 0) AddVehicleComponent(FP_OwnableCar[carid],FP_CarInfo[carid][ocSideskirt]);
if(FP_CarInfo[carid][ocNitro] != 0) AddVehicleComponent(FP_OwnableCar[carid],FP_CarInfo[carid][ocNitro]);
if(FP_CarInfo[carid][ocLamps] != 0) AddVehicleComponent(FP_OwnableCar[carid],FP_CarInfo[carid][ocLamps]);
if(FP_CarInfo[carid][ocExhaust] != 0) AddVehicleComponent(FP_OwnableCar[carid],FP_CarInfo[carid][ocExhaust]);
if(FP_CarInfo[carid][ocWheels] != 0) AddVehicleComponent(FP_OwnableCar[carid],FP_CarInfo[carid][ocWheels]);
if(FP_CarInfo[carid][ocRoof] != 0) AddVehicleComponent(FP_OwnableCar[carid],FP_CarInfo[carid][ocRoof]);
if(FP_CarInfo[carid][ocStereo] != 0) AddVehicleComponent(FP_OwnableCar[carid],FP_CarInfo[carid][ocStereo]);
if(FP_CarInfo[carid][ocHydraulics] != 0) AddVehicleComponent(FP_OwnableCar[carid],FP_CarInfo[carid][ocHydraulics]);
if(FP_CarInfo[carid][ocBullbar] != 0) AddVehicleComponent(FP_OwnableCar[carid],FP_CarInfo[carid][ocBullbar]);
if(FP_CarInfo[carid][ocRearBullbars] != 0) AddVehicleComponent(FP_OwnableCar[carid],FP_CarInfo[carid][ocRearBullbars]);
if(FP_CarInfo[carid][ocFrontSign] != 0) AddVehicleComponent(FP_OwnableCar[carid],FP_CarInfo[carid][ocFrontSign]);
if(FP_CarInfo[carid][ocFrontBullbars] != 0) AddVehicleComponent(FP_OwnableCar[carid],FP_CarInfo[carid][ocFrontBullbars]);
if(FP_CarInfo[carid][ocFrontBumper] != 0) AddVehicleComponent(FP_OwnableCar[carid],FP_CarInfo[carid][ocFrontBumper]);
if(FP_CarInfo[carid][ocRearBumper] != 0) AddVehicleComponent(FP_OwnableCar[carid],FP_CarInfo[carid][ocRearBumper]);
if(FP_CarInfo[carid][ocVents] != 0) AddVehicleComponent(FP_OwnableCar[carid],FP_CarInfo[carid][ocVents]);
if(FP_CarInfo[carid][ocPaintJob] != -1)ChangeVehiclePaintjob(FP_OwnableCar[carid],FP_CarInfo[carid][ocPaintJob]);
}
return 1;
}
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
if(IsAOwnableVehicle(vehicleid))
{
new number = GetVehicleID(vehicleid);
ChangeVehiclePaintjob(vehicleid,FP_CarInfo[number][ocPaintJob]);
}
return 1;
}
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
if(IsAOwnableVehicle(vehicleid))
{
new number = GetVehicleID(vehicleid);
ChangeVehicleColor(vehicleid,FP_CarInfo[number][ocColor1],FP_CarInfo[number][ocColor2]);
}
return 1;
}
public OnVehicleStreamIn(vehicleid, forplayerid)
{
if(IsAOwnableVehicle(vehicleid))
{
new number = GetVehicleID(vehicleid);
if(FP_CarInfo[number][ocLock] == 1)
SetVehicleParamsForPlayer(vehicleid, forplayerid, 0 , 1);
}
return 1;
}
Теперь в >
- Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
if(GetPlayerState(playerid) == 2 && IsAOwnableVehicle(GetPlayerVehicleID(playerid)) && newkeys & 16 && GetPlayerInterior(playerid) == 0) RemoveFromVehicle(playerid);
if(GetPlayerState(playerid) == 2 && IsAOwnableVehicle(GetPlayerVehicleID(playerid)) && newkeys & 512)
ShowPlayerDialog(playerid,DIALOG_VMENU,DIALOG_STYLE_LIST,"Авторынок","{FFFFFF}[Открыть|Закрыть] Транспорт\n\
Починить ($2000)\n\
Покрасить ($2000)\n\
Припарковать транспорт\n\
Отбуксировать на парковку\n\
Определить местоположение\n\
Контроль (двигатель, фары, багажник)\n\
Продать транспорт","Выбрать","Отмена");
Теперь добавим диалоги > public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- Код:
if(dialogid == DIALOG_POKUPKA_AUTO)
{
if(response) OnPlayerCommandText(playerid,"/carmenu buy");
else RemoveFromVehicle(playerid);
}
//------------------------------------------------------------------------------
if(dialogid == DIALOG_VMENU)
{
if(response)
{
if(listitem == 0)OnPlayerCommandText(playerid,"/carmenu lock");
if(listitem == 1)OnPlayerCommandText(playerid,"/carmenu fix");
if(listitem == 2)ShowPlayerDialog(playerid, DIALOG_AUTO_COLOR1 , DIALOG_STYLE_INPUT, "Перекраска", "Введите id основного цвета", "Выбрать", "Отмена");
if(listitem == 3)OnPlayerCommandText(playerid,"/carmenu park");
if(listitem == 4)OnPlayerCommandText(playerid,"/carmenu topark");
if(listitem == 5)OnPlayerCommandText(playerid,"/carmenu car");
if(listitem == 6)OnPlayerCommandText(playerid,"/carmenu control");
if(listitem == 7)OnPlayerCommandText(playerid,"/carmenu sell");
}
return 1;
}
//------------------------------------------------------------------------------
if(dialogid == DIALOG_VKMENU)
{
if(response)
{
switch(listitem)
{
case 0:
{
new vid = GetPlayerVehicleID(playerid);
if(vid != INVALID_VEHICLE_ID)
{
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
//Engine[vid] = engine;
if(Engine[vid] == 0)
{
Engine[vid] = 1;
SetVehicleParamsEx(vid,1,lights,alarm,doors,bonnet,boot,objective);
GameTextForPlayer(playerid,"~w~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~ѓB…‚AЏE‡’~g~ €AЊYЉEм",3000,3);
return 1;
}
if(Engine[vid] == 1)
{
Engine[vid] = 0;
SetVehicleParamsEx(vid,0,lights,alarm,doors,bonnet,boot,objective);
GameTextForPlayer(playerid,"~w~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~ѓB…‚AЏE‡’~r~ B‘K‡”ЌEм",3000,3);
return 1;
}
}
return 1;
}
case 1:
{
new vid = GetPlayerVehicleID(playerid);
if(vid != INVALID_VEHICLE_ID)
{
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
if(Light[vid] == 0)
{
Light[vid] = 1;
SetVehicleParamsEx(vid,engine,1,alarm,doors,bonnet,boot,objective);
return 1;
}
if(Light[vid] == 1)
{
Light[vid] = 0;
SetVehicleParamsEx(vid,engine,0,alarm,doors,bonnet,boot,objective);
return 1;
}
}
return 1;
}
case 2:
{
new vid = GetPlayerVehicleID(playerid);
if(vid != INVALID_VEHICLE_ID)
{
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
if(Bonnet[vid] == 0)
{
Bonnet[vid] = 1;
SetVehicleParamsEx(vid,engine,lights,alarm,doors,1,boot,objective);
return 1;
}
if(Bonnet[vid] == 1)
{
Bonnet[vid] = 0;
SetVehicleParamsEx(vid,engine,lights,alarm,doors,0,boot,objective);
return 1;
}
}
return 1;
}
case 3:
{
new vid = GetPlayerVehicleID(playerid);
if(vid != INVALID_VEHICLE_ID)
{
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
if(Boot[vid] == 0)
{
Boot[vid] = 1;
SetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,1,objective);
return 1;
}
if(Boot[vid] == 1)
{
Boot[vid] = 0;
SetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,0,objective);
return 1;
}
}
return 1;
}
case 4:
{
return ShowPlayerDialog(playerid,DIALOG_VNMENU,DIALOG_STYLE_LIST,"Авторынок","Красный\nСиний\nЗеленый\nЖелтый\nРозовый\nБелый\nУдалить","Выбрать","Отмена");
}
}
}
}
//------------------------------------------------------------------------------
if(dialogid == DIALOG_VNMENU)
{
if(response)
{
switch(listitem)
{
case 0:
{
DestroyObject(neon[GetPlayerVehicleID(playerid)]);
DestroyObject(neon1[GetPlayerVehicleID(playerid)]);
neon[GetPlayerVehicleID(playerid)] = CreateObject(18647,0,0,0,180,0,0,100.0);
neon1[GetPlayerVehicleID(playerid)] = CreateObject(18647,0,0,0,0,0,0,100.0);
AttachObjectToVehicle(neon[GetPlayerVehicleID(playerid)], GetPlayerVehicleID(playerid), -0.8, 0.0, -0.7, 0.0, 0.0, 0.0);
AttachObjectToVehicle(neon1[GetPlayerVehicleID(playerid)], GetPlayerVehicleID(playerid), 0.8, 0.0, -0.7, 0.0, 0.0, 0.0);
GivePlayerMoney(playerid,-2500);
return 1;
}
case 1:
{
DestroyObject(neon[GetPlayerVehicleID(playerid)]);
DestroyObject(neon1[GetPlayerVehicleID(playerid)]);
neon[GetPlayerVehicleID(playerid)] = CreateObject(18648,0,0,0,0,0,0,100.0);
neon1[GetPlayerVehicleID(playerid)] = CreateObject(18648,0,0,0,0,0,0,100.0);
AttachObjectToVehicle(neon[GetPlayerVehicleID(playerid)], GetPlayerVehicleID(playerid), -0.8, 0.0, -0.7, 0.0, 0.0, 0.0);
AttachObjectToVehicle(neon1[GetPlayerVehicleID(playerid)], GetPlayerVehicleID(playerid), 0.8, 0.0, -0.7, 0.0, 0.0, 0.0);
GivePlayerMoney(playerid,-2500);
return 1;
}
case 2:
{
DestroyObject(neon[GetPlayerVehicleID(playerid)]);
DestroyObject(neon1[GetPlayerVehicleID(playerid)]);
neon[GetPlayerVehicleID(playerid)] = CreateObject(18649,0,0,0,0,0,0,100.0);
neon1[GetPlayerVehicleID(playerid)] = CreateObject(18649,0,0,0,0,0,0,100.0);
AttachObjectToVehicle(neon[GetPlayerVehicleID(playerid)], GetPlayerVehicleID(playerid), -0.8, 0.0, -0.7, 0.0, 0.0, 0.0);
AttachObjectToVehicle(neon1[GetPlayerVehicleID(playerid)], GetPlayerVehicleID(playerid), 0.8, 0.0, -0.7, 0.0, 0.0, 0.0);
GivePlayerMoney(playerid,-2500);
return 1;
}
case 3:
{
DestroyObject(neon[GetPlayerVehicleID(playerid)]);
DestroyObject(neon1[GetPlayerVehicleID(playerid)]);
neon[GetPlayerVehicleID(playerid)] = CreateObject(18650,0,0,0,0,0,0,100.0);
neon1[GetPlayerVehicleID(playerid)] = CreateObject(18650,0,0,0,0,0,0,100.0);
AttachObjectToVehicle(neon[GetPlayerVehicleID(playerid)], GetPlayerVehicleID(playerid), -0.8, 0.0, -0.7, 0.0, 0.0, 0.0);
AttachObjectToVehicle(neon1[GetPlayerVehicleID(playerid)], GetPlayerVehicleID(playerid), 0.8, 0.0, -0.7, 0.0, 0.0, 0.0);
GivePlayerMoney(playerid,-2500);
return 1;
}
case 4:
{
DestroyObject(neon[GetPlayerVehicleID(playerid)]);
DestroyObject(neon1[GetPlayerVehicleID(playerid)]);
neon[GetPlayerVehicleID(playerid)] = CreateObject(18651,0,0,0,0,0,0,100.0);
neon1[GetPlayerVehicleID(playerid)] = CreateObject(18651,0,0,0,0,0,0,100.0);
AttachObjectToVehicle(neon[GetPlayerVehicleID(playerid)], GetPlayerVehicleID(playerid), -0.8, 0.0, -0.7, 0.0, 0.0, 0.0);
AttachObjectToVehicle(neon1[GetPlayerVehicleID(playerid)], GetPlayerVehicleID(playerid), 0.8, 0.0, -0.7, 0.0, 0.0, 0.0);
GivePlayerMoney(playerid,-2500);
return 1;
}
case 5:
{
DestroyObject(neon[GetPlayerVehicleID(playerid)]);
DestroyObject(neon1[GetPlayerVehicleID(playerid)]);
neon[GetPlayerVehicleID(playerid)] = CreateObject(18652,0,0,0,0,0,0,100.0);
neon1[GetPlayerVehicleID(playerid)] = CreateObject(18652,0,0,0,0,0,0,100.0);
AttachObjectToVehicle(neon[GetPlayerVehicleID(playerid)], GetPlayerVehicleID(playerid), -0.8, 0.0, -0.7, 0.0, 0.0, 0.0);
AttachObjectToVehicle(neon1[GetPlayerVehicleID(playerid)], GetPlayerVehicleID(playerid), 0.8, 0.0, -0.7, 0.0, 0.0, 0.0);
GivePlayerMoney(playerid,-2500);
return 1;
}
case 6:
{
DestroyObject(neon[GetPlayerVehicleID(playerid)]);
DestroyObject(neon1[GetPlayerVehicleID(playerid)]);
return 1;
}
}
}
}
if(dialogid == DIALOG_AUTO_COLOR1)
{
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_AUTO_COLOR1 , DIALOG_STYLE_INPUT, "Перекраска", "Введите id основного цвета", "Выбрать", "Отмена");
ShowPlayerDialog(playerid, DIALOG_AUTO_COLOR2 , DIALOG_STYLE_INPUT, "Перекраска", "Введите id дополнительного цвета", "Выбрать", "Отмена");
vehcolor1[playerid] = strval(inputtext);
return 1;
}
}
//------------------------------------------------------------------------------
if(dialogid == DIALOG_AUTO_COLOR2)
{
if(response)
{
new string[64];
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_AUTO_COLOR2 , DIALOG_STYLE_INPUT, "Перекраска", "Введите id дополнительного цвета", "Выбрать", "Отмена");
vehcolor2[playerid] = strval(inputtext);
format(string,sizeof(string),"/carmenu color %d %d",vehcolor1[playerid],vehcolor2[playerid]);
OnPlayerCommandText(playerid,string);
return 1;
}
}
Теперь в конец мода >
- Код:
Public:LoadOwnableCars()
{
new arrCoords[28][64];
new strFromFile2[256];
new File: file = fopen("Ownable.cfg", io_read);
if (file)
{
new idx = 1;
while (idx < sizeof(FP_CarInfo))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, '|');
FP_CarInfo[idx][ocId] = strval(arrCoords[0]);
FP_CarInfo[idx][ocCar_x] = strval(arrCoords[1]);
FP_CarInfo[idx][ocCar_y] = strval(arrCoords[2]);
FP_CarInfo[idx][ocCar_z] = strval(arrCoords[3]);
FP_CarInfo[idx][ocCar_a] = strval(arrCoords[4]);
FP_CarInfo[idx][ocColor1] = strval(arrCoords[5]);
FP_CarInfo[idx][ocColor2] = strval(arrCoords[6]);
strmid(FP_CarInfo[idx][ocOwner], arrCoords[7], 0, strlen(arrCoords[7]), 255);
FP_CarInfo[idx][ocLock] = strval(arrCoords[8]);
FP_CarInfo[idx][ocCost] = strval(arrCoords[9]);
FP_CarInfo[idx][ocSpoiler] = strval(arrCoords[10]);
FP_CarInfo[idx][ocHood] = strval(arrCoords[11]);
FP_CarInfo[idx][ocSideskirt] = strval(arrCoords[12]);
FP_CarInfo[idx][ocNitro] = strval(arrCoords[13]);
FP_CarInfo[idx][ocLamps] = strval(arrCoords[14]);
FP_CarInfo[idx][ocExhaust] = strval(arrCoords[15]);
FP_CarInfo[idx][ocWheels] = strval(arrCoords[16]);
FP_CarInfo[idx][ocRoof] = strval(arrCoords[17]);
FP_CarInfo[idx][ocStereo] = strval(arrCoords[18]);
FP_CarInfo[idx][ocHydraulics] = strval(arrCoords[19]);
FP_CarInfo[idx][ocBullbar] = strval(arrCoords[20]);
FP_CarInfo[idx][ocRearBullbars] = strval(arrCoords[21]);
FP_CarInfo[idx][ocFrontSign] = strval(arrCoords[22]);
FP_CarInfo[idx][ocFrontBullbars] = strval(arrCoords[23]);
FP_CarInfo[idx][ocFrontBumper] = strval(arrCoords[24]);
FP_CarInfo[idx][ocRearBumper] = strval(arrCoords[25]);
FP_CarInfo[idx][ocVents] = strval(arrCoords[26]);
FP_CarInfo[idx][ocPaintJob] = strval(arrCoords[27]);
if(FP_CarInfo[idx][ocId] != 0){ OWNABLECARS ++; }
idx++;
}
fclose(file);
printf("Авто на продажу: %d",OWNABLECARS);
}
return 1;
}
Public:SaveOwnableCars()
{
new idx = 1;
new File: file2;
while (idx < sizeof(FP_CarInfo))
{
new coordsstring[256];
format(coordsstring, sizeof(coordsstring), "%d|%f|%f|%f|%f|%d|%d|%s|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d\r\n",
FP_CarInfo[idx][ocId],
FP_CarInfo[idx][ocCar_x],
FP_CarInfo[idx][ocCar_y],
FP_CarInfo[idx][ocCar_z],
FP_CarInfo[idx][ocCar_a],
FP_CarInfo[idx][ocColor1],
FP_CarInfo[idx][ocColor2],
FP_CarInfo[idx][ocOwner],
FP_CarInfo[idx][ocLock],
FP_CarInfo[idx][ocCost],
FP_CarInfo[idx][ocSpoiler],
FP_CarInfo[idx][ocHood],
FP_CarInfo[idx][ocSideskirt],
FP_CarInfo[idx][ocNitro],
FP_CarInfo[idx][ocLamps],
FP_CarInfo[idx][ocExhaust],
FP_CarInfo[idx][ocWheels],
FP_CarInfo[idx][ocRoof],
FP_CarInfo[idx][ocStereo],
FP_CarInfo[idx][ocHydraulics],
FP_CarInfo[idx][ocBullbar],
FP_CarInfo[idx][ocRearBullbars],
FP_CarInfo[idx][ocFrontSign],
FP_CarInfo[idx][ocFrontBullbars],
FP_CarInfo[idx][ocFrontBumper],
FP_CarInfo[idx][ocRearBumper],
FP_CarInfo[idx][ocVents],
FP_CarInfo[idx][ocPaintJob]);
if(idx == 1)
{
file2 = fopen("Ownable.cfg", io_write);
}
else
{
file2 = fopen("Ownable.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}
Public:PlayerCars(playerid)
{
new name[MAX_LEN_NAME];
GetPlayerName(playerid,name,sizeof(name));
for(new i=1;i<= OWNABLECARS;i++)
{
if(!strcmp(FP_CarInfo[i][ocOwner],name,true))
FP_CarKey[playerid] = i;
}
return 1;
}
Public:RemoveFromVehicle(playerid)
{
TogglePlayerControllable(playerid,1);
RemovePlayerFromVehicle(playerid);
return 1;
}
Public:SpawnVeh()
{
new string[128];
for(new idx = 1 ; idx <= OWNABLECARS; idx++)
{
FP_OwnableCar[idx] = AddStaticVehicleEx(FP_CarInfo[idx][ocId], FP_CarInfo[idx][ocCar_x], FP_CarInfo[idx][ocCar_y], FP_CarInfo[idx][ocCar_z]+1, FP_CarInfo[idx][ocCar_a], -1, -1,30000);
if(!strcmp(FP_CarInfo[idx][ocOwner],"The State",true))
{
format(string, sizeof(string), "Этот транспорт продаётся\n[Модель: %s]\n[Цена: %d$]",VehiclesName[GetVehicleModel(FP_OwnableCar[idx])-400], FP_CarInfo[idx][ocCost]);
}
else
{
format(string, sizeof(string), "[Владелец: %s]",FP_CarInfo[idx][ocOwner]);
}
vehicle3Dtext[idx] = Create3DTextLabel(string, COLOR_WHITE,0, 0, 2.5,15.0, 0, 1 );
Attach3DTextLabelToVehicle(vehicle3Dtext[idx], FP_OwnableCar[idx], 0.0, 0.0, 1.6 );
SetVehicleToRespawn(FP_OwnableCar[idx]);
}
return 1;
}
stock GetVehicleID(vehicleid)
{
if(IsAOwnableVehicle(vehicleid))
{
new number;
for(new i=1;i<=OWNABLECARS;i++)
{
if(vehicleid == FP_OwnableCar[i]) number = i;
}
return number;
}
return 0;
}
stock IsAOwnableVehicle(carid)
{
if((carid >= FP_OwnableCar[0]) && (carid <= FP_OwnableCar[OWNABLECARS]))
{
return 1;
}
return 0;
}
Теперь добавим в папку scriptfiles http://rghost.ru/31461491
Ну вот и всё!
+ Я его еще чуть Доработал!
Нашли ощибки напищите