rkv
Умник
Доброго времени суток форумчане
Вот вам мануал сис-темы азс с созданием из игры
Ко всем Define добавьте :
Ко всем new
Ко всем enum
В public OnPlayerCommandText(playerid, cmdtext[]) вставьте
Далее ищем public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) и вставляем
В конец мода
Далее в public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
Ищем public OnPlayerUpdate(playerid) и вставим туда
Чтобы создать азс команда /addazs
Купить азс /buyazs
Продать азс /sellazs
Открыть меню азс /azsmenu
И в папке scriptfiles создайте файл AZS.cfg
Вот вам мануал сис-темы азс с созданием из игры
Ко всем Define добавьте :
PHP:
#define Create_AZS (8441)
#define OPTIONS_AZS (8446)
PHP:
new countAZS;
new ClickID[MAX_PLAYERS],costazss,Distan[MAX_PLAYERS];
PHP:
enum OF
{
Float:IconX,
Float:IconY,
Float:IconZ,
Cost,
Owner[MAX_PLAYER_NAME],
CostBenzin,
bool:Status,
NameAZS[255],
BankAZS,
PriblAZS,
Text3D:InAZSText,
};
new AZSInfo[500][OF];
new CurrentHouse[MAX_PLAYERS];
PHP:
if(!strcmp(cmdtext, "/sellazs", true, 8))
{
new player1,cost;
if(sscanf(cmdtext[9],"ui",player1,cost)) return SendClientMessage(playerid, -1, "Команда для продажи: /sellazs [ID игрока] [Стоимость]");
if(!IsPlayerConnected(player1)) return SendClientMessage(playerid, -1, " Ошибка такого игрока нету");
if(IsPlayerInRangeOfPoint(playerid, 2.00, AZSInfo[CurrentHouse[playerid]][IconX],AZSInfo[CurrentHouse[playerid]][IconY],AZSInfo[CurrentHouse[playerid]][IconZ]))
{
for(new i; i<countAZS; i++)
{
if (!strcmp(AZSInfo[i][Owner], GetName(playerid)))
{
if (!strcmp(AZSInfo[i][Owner], GetName(player1))) return SendClientMessage(playerid,-1,"У данного игрока есть заправка");
ClickID[player1] = playerid;
costazss = cost;
Distan[player1] = CurrentHouse[playerid];
new string[256];
format(string,sizeof(string),"\t\t {E4D1B3}Предложения\n\n\
{FFFFFF}Игрок {2E8BEA}%s хочет предложить вам купить АЗС\n\
\t{FFFFFF}Названия АЗС: {E68C1A}%s\n\
{FFFFFF}Цена:\t{2E8BEA}%d$\t{FFFFFF}\n\
{E4D1B3}Желаете купить эту заправку?\n",GetName(playerid),AZSInfo[CurrentHouse[playerid]][NameAZS],cost);
ShowPlayerDialog(player1,OPTIONS_AZS+7,DIALOG_STYLE_MSGBOX,"{E68C1A}Предложения о покупке АЗС", string, "Согласен", "Отмена");
}
}
}
return 1;
}
if (strcmp("/azsmenu", cmdtext, true, 10) == 0)
{
new s[256];
if (!strcmp(AZSInfo[CurrentHouse[playerid]][Owner], GetName(playerid)))
{
if(AZSInfo[CurrentHouse[playerid]][Status] == false) format(s,256,"{FFFFFF}Cтатус:\t[ {FF0000}ЗАКРЫТЬ {FFFFFF}]");
else format(s,256,"{FFFFFF}Cтатус:\t[ {56AD00}ОТКРЫТЬ {FFFFFF}]");
if(AZSInfo[CurrentHouse[playerid]][NameAZS] != 0) format(s,128,"%s\n{FFFFFF}Названия Вашего АЗС: {FFFFFF}[ {FECC00}%s {FFFFFF}]",s,AZSInfo[CurrentHouse[playerid]][NameAZS]);
if(AZSInfo[CurrentHouse[playerid]][CostBenzin] != 0) format(s,256,"%s\nЦена за 10 литров: {2E8BEA}$%d",s,AZSInfo[CurrentHouse[playerid]][CostBenzin]);
if(AZSInfo[CurrentHouse[playerid]][CostBenzin] != 0) format(s,256,"%s\n{FECC00}Статистика АЗС",s);
return ShowPlayerDialog(playerid, OPTIONS_AZS, DIALOG_STYLE_LIST, "Меню заправки", s, "Ок", "Выход");
}
}
if (strcmp("/addazs", cmdtext, true, 10) == 0)
{
new s[256];
if(AZSInfo[countAZS][IconX] != 0) format(s,256,"Место нахождения АЗС: %f,%f,%f",AZSInfo[countAZS][IconX],AZSInfo[countAZS][IconY],AZSInfo[countAZS][IconZ]);
else format(s,256,"Место нахождения АЗС: [Встаньте на нужном месте]");
if(AZSInfo[countAZS][NameAZS] != 0) format(s,128,"%s\nНазвания: %s",s,AZSInfo[countAZS][NameAZS]);
else format(s,158,"%s\nНазвания не установлено: [нажмите для ввода]",s);
if(AZSInfo[countAZS][Cost] != 0) format(s,256,"%s\nЦена АЗС:%d",s,AZSInfo[countAZS][Cost]);
else format(s,256,"%s\nЦена: [нажмите для ввода]",s);
if(AZSInfo[countAZS][Cost] != 0 && AZSInfo[countAZS][NameAZS] != 0 && AZSInfo[countAZS][IconX] != 0) format(s,256,"%s\nСоздать АЗС",s);
return ShowPlayerDialog(playerid, Create_AZS, DIALOG_STYLE_LIST, "Создание АЗС", s, "Ок", "Выход");
}
if (strcmp("/buyazs", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 2.00, AZSInfo[CurrentHouse[playerid]][IconX],AZSInfo[CurrentHouse[playerid]][IconY],AZSInfo[CurrentHouse[playerid]][IconZ]))
{
for(new i; i<countAZS; i++)
{
if (!strcmp(AZSInfo[i][Owner], GetName(playerid))) return SendClientMessage(playerid,-1,"У вас уже есть заправочная станция");
}
if(GetPlayerMoney(playerid) < AZSInfo[CurrentHouse[playerid]][Cost]) return SendClientMessage(playerid,-1,"У вас нету столько данной суммы");
GivePlayerMoney(playerid,-AZSInfo[CurrentHouse[playerid]][Cost]);
strmid(AZSInfo[CurrentHouse[playerid]][Owner], GetName(playerid), 0, strlen(GetName(playerid)), 255);
new s[256];
format(s,256,"{2E8BEA}%s\n{FFFFFF}Владелец: {56AD00}%s\n{FFFFFF}Цена за 10 литров: {FECC00}%d$",AZSInfo[CurrentHouse[playerid]][NameAZS],AZSInfo[CurrentHouse[playerid]][Owner],AZSInfo[CurrentHouse[playerid]][CostBenzin]);
UpdateDynamic3DTextLabelText(AZSInfo[CurrentHouse[playerid]][InAZSText], 0xCCFFDDFF, s);
Update__AZS();
}
return 1;
}
PHP:
case OPTIONS_AZS+7:
{
if(!response) return SendClientMessage(ClickID[playerid],-1,"Данный игрок отказался покупать заправочную станцию");
if(GetPlayerMoney(playerid) < costazss) return SendClientMessage(playerid,-1,"У вас нет данной суммы");
if(!IsPlayerInRangeOfPoint(playerid, 2.00, AZSInfo[Distan[playerid]][IconX],AZSInfo[Distan[playerid]][IconY],AZSInfo[Distan[playerid]][IconZ])) return SendClientMessage(playerid,-1,"{00CCFF}[ Ошибка ] Вы не возле этой АЗС");
SendClientMessage(playerid,-1,"Поздравляем! Вы купили заправочную станцию");
GivePlayerMoney(ClickID[playerid],costazss); GivePlayerMoney(playerid,-costazss);
strmid(AZSInfo[Distan[playerid]][Owner], GetName(playerid), 0, strlen(GetName(playerid)), 255);
new s[256];
format(s,256,"{2E8BEA}%s\n{FFFFFF}Владелец: {56AD00}%s\n{FFFFFF}Цена за 10 литров: {FECC00}%d$",AZSInfo[Distan[playerid]][NameAZS],AZSInfo[Distan[playerid]][Owner],AZSInfo[Distan[playerid]][CostBenzin]);
UpdateDynamic3DTextLabelText(AZSInfo[Distan[playerid]][InAZSText], 0xCCFFDDFF, s);
Update__AZS();
}
case OPTIONS_AZS:
{
if(!response) return 1;
switch(listitem)
{
case 0:
{
if(AZSInfo[CurrentHouse[playerid]][Status] == false) AZSInfo[CurrentHouse[playerid]][Status] = true,GameTextForPlayer(playerid, "~n~~r~Closed",2000,3);
else AZSInfo[CurrentHouse[playerid]][Status] = false,GameTextForPlayer(playerid, "~n~~g~open",2000,3);
}
case 1: ShowPlayerDialog(playerid, OPTIONS_AZS+3, DIALOG_STYLE_INPUT, "Названия заправки", "Введите Новое названия заправки", "Ок", "Отмена");
case 2: ShowPlayerDialog(playerid, OPTIONS_AZS+2, DIALOG_STYLE_INPUT, "Цена за 10 литров", "Введите цену за 10 литров (АЗС)", "Ок", "Отмена");
case 3:
{
new string[256];
format(string,sizeof(string),"\t\t{FFFFFF}[ {56AD00}Информация о вашей АЗС {FFFFFF}]\n\n\
{FFFFFF}Названия: \t\t{2E8BEA}%s\n\
{FFFFFF}Цена за 10 литров:\t{2E8BEA}%d$\n\
{FFFFFF}На счету бизнеса:\t{2E8BEA}%d$\t{FFFFFF}(За электричество - 50$)\n\
{FFFFFF}Прибыль от АЗС:\t{2E8BEA}%d$\t{FFFFFF}\n",AZSInfo[CurrentHouse[playerid]][NameAZS],AZSInfo[CurrentHouse[playerid]][CostBenzin],AZSInfo[CurrentHouse[playerid]][BankAZS],AZSInfo[CurrentHouse[playerid]][PriblAZS]);
ShowPlayerDialog(playerid,OPTIONS_AZS+4,DIALOG_STYLE_MSGBOX,"{97FFFF}Статистика вашего АЗС", string, "Ок", "Выход");
}
}
}
case OPTIONS_AZS+2:
{
if(response == 1)
{
AZSInfo[CurrentHouse[playerid]][CostBenzin]=strval(inputtext);
SendClientMessage(playerid,-1,"Цена заправки установлена!");
new s[256];
format(s,256,"{2E8BEA}%s\n{FFFFFF}Владелец: {56AD00}%s\n{FFFFFF}Цена за 10 литров: {FECC00}%d$",AZSInfo[CurrentHouse[playerid]][NameAZS],AZSInfo[CurrentHouse[playerid]][Owner],AZSInfo[CurrentHouse[playerid]][CostBenzin]);
UpdateDynamic3DTextLabelText(AZSInfo[CurrentHouse[playerid]][InAZSText], 0xCCFFDDFF, s);
Update__AZS();
}
}
case OPTIONS_AZS+3:
{
if(response == 1)
{
strmid(AZSInfo[CurrentHouse[playerid]][NameAZS], inputtext[0], 0, strlen(inputtext[0]), 255);
SendClientMessage(playerid,-1,"Новое Названия АЗС установлено!");
new s[256];
format(s,256,"{2E8BEA}%s\n{FFFFFF}Владелец: {56AD00}%s\n{FFFFFF}Цена за 10 литров: {FECC00}%d$",AZSInfo[CurrentHouse[playerid]][NameAZS],AZSInfo[CurrentHouse[playerid]][Owner],AZSInfo[CurrentHouse[playerid]][CostBenzin]);
UpdateDynamic3DTextLabelText(AZSInfo[CurrentHouse[playerid]][InAZSText], 0xCCFFDDFF, s);
Update__AZS();
}
}
case Create_AZS+3:
{
if(response == 1)
{
strmid(AZSInfo[countAZS][NameAZS], inputtext[0], 0, strlen(inputtext[0]), 255);
SendClientMessage(playerid,-1,"Названия АЗС установлено!");
}
}
case Create_AZS+2:
{
if(response == 1)
{
AZSInfo[countAZS][Cost]=strval(inputtext);
SendClientMessage(playerid,-1,"Цена заправки установлена!");
}
}
case Create_AZS:
{
if(response)
{
switch(listitem)
{
case 0: GetPlayerPos(playerid,AZSInfo[countAZS][IconX],AZSInfo[countAZS][IconY],AZSInfo[countAZS][IconZ]);
case 1: ShowPlayerDialog(playerid, Create_AZS+3, DIALOG_STYLE_INPUT, "Названия заправки", "Введите названия заправки", "Ок", "Отмена");
case 2: ShowPlayerDialog(playerid, Create_AZS+2, DIALOG_STYLE_INPUT, "Цена АЗС", "Введите цену заправки (АЗС)", "Ок", "Отмена");
case 3:
{
new s[256];
format(s,256,"{2E8BEA}%s\n{56AD00}Cвободная АЗС\n{FFFFFF}Цена АЗС: {FECC00}%d$",AZSInfo[countAZS][NameAZS],AZSInfo[countAZS][Cost]);
AZSInfo[countAZS][InAZSText] = CreateDynamic3DTextLabel(s,0xF47A00FF,AZSInfo[countAZS][IconX],AZSInfo[countAZS][IconY],AZSInfo[countAZS][IconZ]-0.1,9.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0);
strmid(AZSInfo[countAZS][Owner], "The State", 0, strlen("The State"), 255);
AZSInfo[countAZS][CostBenzin] = 10;
countAZS++;
Update__AZS();
}
}
}
}
PHP:
LoadAZS()
{
new RandomePos[9][50];
new FileStr[256];
new File: file = fopen("AZS.cfg", io_read);
new s[256];
if (file)
{
fread(file, FileStr);
split(FileStr, RandomePos, ',');
countAZS = strval(RandomePos[0]);
for(new i; i<countAZS; i++)
{
fread(file, FileStr);
split(FileStr, RandomePos, ',');
AZSInfo[i][IconX] = floatstr(RandomePos[0]);
AZSInfo[i][IconY] = floatstr(RandomePos[1]);
AZSInfo[i][IconZ] = floatstr(RandomePos[2]);
AZSInfo[i][Cost] = strval(RandomePos[3]);
strmid(AZSInfo[i][Owner], RandomePos[4], 0, strlen(RandomePos[4]), 24);
strmid(AZSInfo[i][NameAZS], RandomePos[5], 0, strlen(RandomePos[5]), 24);
AZSInfo[i][BankAZS] = strval(RandomePos[6]);
AZSInfo[i][PriblAZS] = strval(RandomePos[7]);
AZSInfo[i][CostBenzin] = strval(RandomePos[8]);
if (!strcmp("The State", AZSInfo[i][Owner])) format(s,256,"{2E8BEA}%s\n{56AD00}Cвободная АЗС\n{FFFFFF}Цена АЗС: {FECC00}%d$",AZSInfo[i][NameAZS],AZSInfo[i][Cost]);
else format(s,256,"{2E8BEA}%s\n{FFFFFF}Владелец: {56AD00}%s\n{FFFFFF}Цена за 10 литров: {FECC00}%d$",AZSInfo[i][NameAZS],AZSInfo[i][Owner],AZSInfo[i][CostBenzin]);
AZSInfo[i][InAZSText] = CreateDynamic3DTextLabel(s,0xF47A00FF,AZSInfo[i][IconX],AZSInfo[i][IconY],AZSInfo[i][IconZ]-0.1,9.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0);
printf("AZS %d x-%0.0f,y-%0.0f,z-%0.0f,owner-%s",i,AZSInfo[i][IconX],AZSInfo[i][IconY],AZSInfo[i][IconZ],AZSInfo[i][Owner]);
}
}
print("Все АЗС были загружены");
fclose(file);
return true;
}
Update__AZS()
{
new File: file;
new RandomePos[1024];
for(new i; i<countAZS; i++)
{
format(RandomePos, sizeof(RandomePos), "%f,%f,%f,%d,%s,%s,%d,%d,%d\n",
AZSInfo[i][IconX],AZSInfo[i][IconY],AZSInfo[i][IconZ],AZSInfo[i][Cost],AZSInfo[i][Owner],AZSInfo[i][NameAZS],AZSInfo[i][BankAZS],AZSInfo[i][PriblAZS],AZSInfo[i][CostBenzin]);
if(i == 0)
{
file = fopen("AZS.cfg", io_write);
format(RandomePos,1024,"%d\n%s",countAZS,RandomePos);
fwrite(file, RandomePos);
fclose(file);
}
else
{
file = fopen("AZS.cfg", io_append);
fwrite(file, RandomePos);
fclose(file);
}
}
return 1;
}
stock GetName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
return name;
}
PHP:
if(newkeys == 4096)
{
if(IsPlayerInAnyVehicle(playerid))
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(IsPlayerInRangeOfPoint(playerid, 10.00, AZSInfo[CurrentHouse[playerid]][IconX],AZSInfo[CurrentHouse[playerid]][IconY],AZSInfo[CurrentHouse[playerid]][IconZ]))
{
if(AZSInfo[CurrentHouse[playerid]][Status] == true) return SendClientMessage(playerid,-1,"{00CCFF}[ Ошибка ] Эта заправка закрыта");
GivePlayerMoney(playerid, -AZSInfo[CurrentHouse[playerid]][CostBenzin]);
GameTextForPlayer(playerid, "~r~+10",2000,3);
}
else SendClientMessage(playerid,-1,"{00CCFF}[ Ошибка ] Вы далеко");
}
else SendClientMessage(playerid,-1,"{00CCFF}[ Ошибка ] Вы не за рулем");
}
else SendClientMessage(playerid,-1,"{00CCFF}[ Ошибка ] Вы не в машине");
}
PHP:
for(new i; i<countAZS; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 10.00, AZSInfo[i][IconX],AZSInfo[i][IconY],AZSInfo[i][IconZ]))
{
CurrentHouse[playerid] = i;
}
}
Купить азс /buyazs
Продать азс /sellazs
Открыть меню азс /azsmenu
И в папке scriptfiles создайте файл AZS.cfg
Последнее редактирование:
