PDA

Просмотр полной версии : [Вопрос] Система capture для банд



Artur_Savan
15.02.2017, 22:06
Добрый вечер, Ув.Люди, мне нужно поставить новую /capture систему..
У меня уже есть готовый код, но у меня не получается его вставить в мод..
Не могли бы мне помочь?, вот мой Skype: artur35994

Ко всем new:

new bool:StopWar = false;
new Command[2];
new CommandKill[2];
new WarZoneID;
new Text: onecommand;
new Text: twocommand;
new Text: kolone;
new Text: koltwo;
new Text: fon;
new Text: time;
new Text: vremya;
new WarTimeMin;
new WarTimeSec;
new WarStop;

Ко всем enum:

enum pZone
{
Float:px1,
Float:py1,
Float:px2,
Float:py2,
pfrak,
};

Добавим forward's (forward):

forward LoadGZ();
forward SaveGZ();
forward CheckArmour(); // такой форвад уже скорей всего есть, так что можно просто добавить содержимое моего кода в данный паблик

Создать паблики, лучше в самом конце мода:

public LoadGZ(){
new string[256];
new ololo[5][32];
new File: file = fopen("zone.ini", io_read);
if(file){
new idx;
while (idx < sizeof(GZInfo)){
fread(file, string);
split(string, ololo, '|');
GZInfo[idx][px1] = floatstr(ololo[0]);
GZInfo[idx][py1] = floatstr(ololo[1]);
GZInfo[idx][px2] = floatstr(ololo[2]);
GZInfo[idx][py2] = floatstr(ololo[3]);
GZInfo[idx][pfrak] = strval(ololo[4]);
idx++;}
fclose(file);}}

public SaveGZ(){
new string[128], idx;
new File: file2;
while (idx < sizeof(GZInfo)){
format(string, sizeof(string),"%f|%f|%f|%f|%d\n",GZInfo[idx][px1]
,GZInfo[idx][py1],GZInfo[idx][px2],
GZInfo[idx][py2],GZInfo[idx][pfrak]);
if(idx == 0){
file2 = fopen("zone.ini", io_write);}
else{
file2 = fopen("zone.ini", io_append);}
fwrite(file2,string);
idx++;
fclose(file2);}return 1;}

public CheckArmour()
{
WarTimeSec--;
if(WarStop > 0) WarStop--;
if(WarStop == 0) StopWar = false;
if(WarTimeSec == 0 && WarTimeMin == 0)
{
TextDrawDestroy(fon);
TextDrawDestroy(onecommand);
TextDrawDestroy(twocommand);
TextDrawDestroy(kolone);
TextDrawDestroy(koltwo);
TextDrawDestroy(time);
TextDrawDestroy(vremya);
GangZoneStopFlashForAll(WarZoneID);
SaveGZ();
if(CommandKill[0] > CommandKill[1])
{
for(new i = 0; i < GetMaxPlayers(); i++)
{
if(IsPlayerConnected(i))
{
if(GZInfo[WarZoneID][pfrak] == 19) GangZoneShowForPlayer(i, WarZoneID, 0x00BC1E96);
else if(GZInfo[WarZoneID][pfrak] == 20) GangZoneShowForPlayer(i, WarZoneID, 0xD800C796);
else if(GZInfo[WarZoneID][pfrak] == 21) GangZoneShowForPlayer(i, WarZoneID, 0x5418D696);
else if(GZInfo[WarZoneID][pfrak] == 22) GangZoneShowForPlayer(i, WarZoneID, 0x0098FF96);
else if(GZInfo[WarZoneID][pfrak] == 23) GangZoneShowForPlayer(i, WarZoneID, 0xFFCF0096);
}
if(PlayerInfo[i][pMember] == Command[0] || PlayerInfo[i][pLeader] == Command[0])
{
SendClientMessage(i, COLOR_GREEN, "Вы выиграли эту битву.");
}
}
GZInfo[WarZoneID][pfrak] = Command[0];
}
else if(CommandKill[0] < CommandKill[1])
{
for(new i = 0; i < GetMaxPlayers(); i++)
{
if(IsPlayerConnected(i))
{
if(GZInfo[WarZoneID][pfrak] == 19) GangZoneShowForPlayer(i, WarZoneID, 0x00BC1E96);
else if(GZInfo[WarZoneID][pfrak] == 20) GangZoneShowForPlayer(i, WarZoneID, 0xD800C796);
else if(GZInfo[WarZoneID][pfrak] == 21) GangZoneShowForPlayer(i, WarZoneID, 0x5418D696);
else if(GZInfo[WarZoneID][pfrak] == 22) GangZoneShowForPlayer(i, WarZoneID, 0x0098FF96);
else if(GZInfo[WarZoneID][pfrak] == 23) GangZoneShowForPlayer(i, WarZoneID, 0xFFCF0096);
}
if(PlayerInfo[i][pMember] == Command[1] || PlayerInfo[i][pLeader] == Command[1])
{
SendClientMessage(i, COLOR_GRAD1, "Вы выиграли эту битву.");
}
else if(PlayerInfo[i][pMember] == Command[0] || PlayerInfo[i][pLeader] == Command[0])
{
new string[64],ftext[16];
if(GZInfo[WarZoneID][pfrak] == 19) ftext = "The Grove";
else if(GZInfo[WarZoneID][pfrak] == 20) ftext = "Ballas";
else if(GZInfo[WarZoneID][pfrak] == 21) ftext = "Rifa";
else if(GZInfo[WarZoneID][pfrak] == 22) ftext = "Aztecas";
else if(GZInfo[WarZoneID][pfrak] == 23) ftext = "Vagos";
format(string, sizeof(string),"Вам не удалось захватить территорию банды %s",ftext);
SendClientMessage(i, COLOR_GREEN, string);
}
}
}
else
{
for(new i = 0; i < GetMaxPlayers(); i++)
{
if(PlayerInfo[i][pMember] == Command[1] || PlayerInfo[i][pLeader] == Command[1])
{
SendClientMessage(i, COLOR_GREEN, "Ничья, зона остаётся у вас.");
if(GZInfo[WarZoneID][pfrak] == 19) GangZoneShowForPlayer(i, WarZoneID, 0x00BC1E96);
else if(GZInfo[WarZoneID][pfrak] == 20) GangZoneShowForPlayer(i, WarZoneID, 0xD800C796);
else if(GZInfo[WarZoneID][pfrak] == 21) GangZoneShowForPlayer(i, WarZoneID, 0x5418D696);
else if(GZInfo[WarZoneID][pfrak] == 22) GangZoneShowForPlayer(i, WarZoneID, 0x0098FF96);
else if(GZInfo[WarZoneID][pfrak] == 23) GangZoneShowForPlayer(i, WarZoneID, 0xFFCF0096);
}
}
}
Command[0] = 0;
Command[1] = 0;
}
else if(WarTimeSec == 0) { WarTimeSec = 60; WarTimeMin--; }
new string[32];
if(WarTimeSec > 9) format(string, sizeof(string),"%d:%d",WarTimeMin,WarTimeSec);
else format(string, sizeof(string),"%d:0%d",WarTimeMin,WarTimeSec);
TextDrawSetString(vremya, string);
}

В public OnGameModeInit() добавим:

SetTimer("CheckArmour",1000,1); // если такого нет
LoadGZ();
for(new i = 0; i < sizeof(GZInfo); i++)
{
GangZoneCreate(GZInfo[i][px1],GZInfo[i][py1],GZInfo[
i][px2],GZInfo[i][py2]);
}

В public OnPlayerConnect() добавим:

for(new i = 0; i < sizeof(GZInfo); i++)
{
if(GZInfo[i][pfrak] == 0) GangZoneShowForPlayer(playerid, i, 0xB4B4B496);
else if(GZInfo[i][pfrak] == 19) GangZoneShowForPlayer(playerid, i, 0x00BC1E96);
else if(GZInfo[i][pfrak] == 20) GangZoneShowForPlayer(playerid, i, 0xD800C796);
else if(GZInfo[i][pfrak] == 21) GangZoneShowForPlayer(playerid, i, 0x5418D696);
else if(GZInfo[i][pfrak] == 22) GangZoneShowForPlayer(playerid, i, 0x0098FF96);
else if(GZInfo[i][pfrak] == 23) GangZoneShowForPlayer(playerid, i, 0xFFCF0096);

В public OnPlayerDisconnect() добавим:

if(PlayerInfo[playerid][pMember] == Command[0] || PlayerInfo[playerid][pLeader] == Command[0] ||
PlayerInfo[playerid][pMember] == Command[1] || PlayerInfo[playerid][pLeader] == Command[1])
{
TextDrawHideForPlayer(playerid, fon);
TextDrawHideForPlayer(playerid, onecommand);
TextDrawHideForPlayer(playerid, twocommand);
TextDrawHideForPlayer(playerid, kolone);
TextDrawHideForPlayer(playerid, koltwo);
TextDrawHideForPlayer(playerid, time);
TextDrawHideForPlayer(playerid, vremya);
}

В public OnPlayerDeath() добавим:

if(WarTimeSec > 0)
{
if(PlayerInfo[playerid][pMember] == Command[0] || PlayerInfo[playerid][pLeader] == Command[0])
{
if(PlayerInfo[killerid][pMember] == Command[1] || PlayerInfo[killerid][pLeader] == Command[1])
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x,y,z);
if((x >= GZInfo[WarZoneID][px1] && x <= GZInfo[WarZoneID][px2]) &&
(y >= GZInfo[WarZoneID][py1] && y <= GZInfo[WarZoneID][py2]))
{
CommandKill[1]++;
new string[12];
format(string, sizeof(string),"%d",CommandKill[1]);
TextDrawSetString(kolone, string);
}
}
}
if(PlayerInfo[playerid][pMember] == Command[1] || PlayerInfo[playerid][pLeader] == Command[1])
{
if(PlayerInfo[killerid][pMember] == Command[0] || PlayerInfo[killerid][pLeader] == Command[0])
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x,y,z);
if((x >= GZInfo[WarZoneID][px1] && x <= GZInfo[WarZoneID][px2]) &&
(y >= GZInfo[WarZoneID][py1] && y <= GZInfo[WarZoneID][py2]))
{
CommandKill[0]++;
new string[12];
format(string, sizeof(string),"%d",CommandKill[0]);
TextDrawSetString(koltwo, string);
}
}
}
}

В public OnPlayerCommandText(playerid, cmdtext[]) добавим:

else if(strcmp(cmd, "/gzone", true) == 0)
{
if(PlayerInfo[playerid][pAdmin] >= 1)
{
tmp=strtok(cmdtext, idx);
if(!strlen(tmp) || (!IsNumeric(tmp)))
{
SendClientMessage(playerid, COLOR_GRAD1, "Используйте: /gzone [ 19 - 23 ]");
return 1;
}
new banda = strval(tmp);
if(banda > 18 && banda < 24)
{
new zid;
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x,y,z);
for(new i = 0; i < sizeof(GZInfo); i++)
{
if((x >= GZInfo[i][px1] && x <= GZInfo[i][px2]) &&
(y >= GZInfo[i][py1] && y <= GZInfo[i][py2]))
{
zid = i;
i = 5555;
}
}
GZInfo[zid][pfrak] = banda;
SaveGZ();
if(GZInfo[zid][pfrak] == 19) GangZoneShowForAll(zid, 0x00BC1E96);
else if(GZInfo[zid][pfrak] == 20) GangZoneShowForAll(zid, 0xD800C796);
else if(GZInfo[zid][pfrak] == 21) GangZoneShowForAll(zid, 0x5418D696);
else if(GZInfo[zid][pfrak] == 22) GangZoneShowForAll(zid, 0x0098FF96);
else if(GZInfo[zid][pfrak] == 23) GangZoneShowForAll(zid, 0xFFCF0096);
SendClientMessage(playerid,COLOR_GRAD1, "Сделано.");
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "Недопустимое значение.");
return 1;
}
}
}

else if(strcmp(cmd, "/capture", true) == 0)
{
new fntext[60];
new string[128];
new fztext[60];
if(PlayerInfo[playerid][pMember] >= 19 && PlayerInfo[playerid][pMember] <= 23)
{
if(PlayerInfo[playerid][pRang] >= 7)
{
if(StopWar == false)
{
if(Command[0] != 0) { SendClientMessage(playerid, COLOR_GRAD1, "На данный момент уже захватывается территория"); return 1; }
new zid,mid;
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x,y,z);
for(new i = 0; i < sizeof(GZInfo); i++)
{
if((x >= GZInfo[i][px1] && x <= GZInfo[i][px2]) &&
(y >= GZInfo[i][py1] && y <= GZInfo[i][py2]))
{
zid = i;
i = 5555;
}
}
if(PlayerInfo[playerid][pMember] != 0) mid = PlayerInfo[playerid][pMember];
else if(PlayerInfo[playerid][pLeader] != 0) mid = PlayerInfo[playerid][pLeader];
if(mid == GZInfo[zid][pfrak]) { SendClientMessage(playerid, COLOR_GRAD1, "Данная территория принадлежит вам"); return 1; }
if(GZInfo[zid][pfrak] == 0)
{
GZInfo[zid][pfrak] = mid;
SaveGZ();
if(GZInfo[zid][pfrak] == 19) GangZoneShowForPlayer(playerid, zid, 0x03c03cAA);
else if(GZInfo[zid][pfrak] == 20) GangZoneShowForPlayer(playerid, zid, 0xcd00cdAA);
else if(GZInfo[zid][pfrak] == 21) GangZoneShowForPlayer(playerid, zid, 0x3D62F296);
else if(GZInfo[zid][pfrak] == 22) GangZoneShowForPlayer(playerid, zid, 0x1ee7ffAA);
else if(GZInfo[zid][pfrak] == 23) GangZoneShowForPlayer(playerid, zid, 0xffd700AA);
return 1;
}
new kol;
for(new i = 0; i < GetMaxPlayers(); i++)
{
if(PlayerInfo[i][pMember] == GZInfo[zid][pfrak] ||
PlayerInfo[i][pLeader] == GZInfo[zid][pfrak])
{
kol++;
}
}
if(kol < 1) { SendClientMessage(playerid, COLOR_GRAD1, "У данной банды нету онлайна"); return 1; }
if(mid == 19) fntext = "Grove Street";
else if(mid == 20) fntext = "The Ballas";
else if(mid == 21) fntext = "The Rifa";
else if(mid == 22) fntext = "Varios Los Aztecas";
else if(mid == 23) fntext = "Los Santos Vagos";
if(GZInfo[zid][pfrak] == 19) fztext = "Grove Street";
else if(GZInfo[zid][pfrak] == 20) fztext = "The Ballas";
else if(GZInfo[zid][pfrak] == 21) fztext = "The Rifa";
else if(GZInfo[zid][pfrak] == 22) fztext = "Varios Los Aztecas";
else if(GZInfo[zid][pfrak] == 23) fztext = "Los Santos Vagos";
format(string, sizeof(string), "Банда '%s' начала захват территории у '%s' в районе '%s'",fntext, fztext, GetPlayerZone(playerid));
SendFamilyMessage(19, 0xdd4400AA, string),SendFamilyMessage(20, 0xdd4400AA, string),SendFamilyMessage(21, 0xdd4400AA, string),SendFamilyMessage(22, 0xdd4400AA, string),SendFamilyMessage(23, 0xdd4400AA, string);
GangZoneFlashForAll(zid, COLOR_RED);
Command[0] = mid;
Command[1] = GZInfo[zid][pfrak];
WarZoneID = zid;
new ftext[16];
fon = TextDrawCreate(1, 285, "_");
TextDrawUseBox(fon, 1);
TextDrawBoxColor(fon, 0x00000075);
TextDrawTextSize(fon, 150.0, 400.0);
TextDrawLetterSize(fon, 0.0, 5.3);
time = TextDrawCreate(10.0, 285.0, "Time:");
TextDrawLetterSize(time, 0.4, 1.2);
TextDrawColor(time, 0x37FA00FF);
TextDrawFont(time, 2);
TextDrawSetProportional(time, 1);
TextDrawSetOutline(time, 2);
vremya = TextDrawCreate(50.0, 285.0, "5:00");
TextDrawLetterSize(vremya, 0.4, 1.2);
TextDrawColor(vremya, 0x37FA00FF);
TextDrawFont(vremya, 2);
TextDrawSetOutline(vremya, 2);
if(mid == 19) ftext = "Grove";
else if(mid == 20) ftext = "Ballas";
else if(mid == 21) ftext = "Rifa";
else if(mid == 22) ftext = "Aztecas";
else if(mid == 23) ftext = "Vagos";
onecommand = TextDrawCreate(10.0, 300.0, ftext);
TextDrawLetterSize(onecommand, 0.4, 1.2);
TextDrawFont(onecommand, 2);
TextDrawSetOutline(onecommand, 2);
if(GZInfo[zid][pfrak] == 19) ftext = "Grove";
else if(GZInfo[zid][pfrak] == 20) ftext = "Ballas";
else if(GZInfo[zid][pfrak] == 21) ftext = "Rifa";
else if(GZInfo[zid][pfrak] == 22) ftext = "Aztecas";
else if(GZInfo[zid][pfrak] == 23) ftext = "Vagos";
twocommand = TextDrawCreate(10.0, 315.0, ftext);
TextDrawUseBox(twocommand, 0);
TextDrawLetterSize(twocommand, 0.4, 1.2);
TextDrawFont(twocommand, 2);
TextDrawSetOutline(twocommand, 2);
kolone = TextDrawCreate(133.0, 315.0, "0");
TextDrawLetterSize(kolone, 0.4, 1.2);
TextDrawFont(kolone, 2);
TextDrawSetOutline(kolone, 2);
koltwo = TextDrawCreate(133.0, 300.0, "0");
TextDrawLetterSize(koltwo, 0.4, 1.2);
TextDrawFont(koltwo, 2);
TextDrawSetOutline(koltwo, 2);
for(new i = 0; i < GetMaxPlayers();i++)
{
if((PlayerInfo[i][pMember] >= 19 && PlayerInfo[i][pMember] <= 23) ||
(PlayerInfo[i][pLeader] >= 19 && PlayerInfo[i][pLeader] <= 23))
{
TextDrawShowForPlayer(i,fon);
TextDrawShowForPlayer(i,time);
TextDrawShowForPlayer(i,vremya);
TextDrawShowForPlayer(i,onecommand);
TextDrawShowForPlayer(i,twocommand);
TextDrawShowForPlayer(i,kolone);
TextDrawShowForPlayer(i,koltwo);
}
}
WarTimeMin = 2;
WarTimeSec = 60;
WarStop = 7200000;
CommandKill[0] = 0;
CommandKill[1] = 0;
StopWar = true;
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "Захват территории возможен 1 раз в час");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "Данная функция доступна с 7 ранга");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "Данная функция Вам не доступна");
return 1;
}
}

Очень буду вам благодарен, с ув.Артур Саван ...:sorry:

Osetin
15.02.2017, 22:52
Выкладывай сюда, что не получается, а не готовый код, который взял откуда-то.

Artur_Savan
15.02.2017, 23:06
Osetin, я могу дать тебе мод что бы ты вставил туда это всё, у меня просто миллион ошибок!
Вот сылка: https://yadi.sk/d/jbQMltxh3E8WyN
Мне очень нужна твоя помощь!