Вот скрипт : Наверное каждый сталкивался с тем, что нужно сделать для банд кучу "gang" зон, за которые им прийдется воевать как в одиночной игре.
Эта проблема более-менее решается.
Порылся в нескольких модах\мануалах, склеил это дело, дописал и что-то получилось.
Работающую версию мода Вы можете посмотреть на сервере:83.222.116.31:7801
Зоны будем делать для трех банд. Если нужно - расширяйте.
Первое что Вам понадобится - создать сами зоны (координаты). В этом Вам поможет FS.
Вот готовые 5 координат:
Code
2361.524902,-2685.230468,2857.524902,-2317.230468
2409.545166,-1931.665161,2641.545166,-1619.665161
2400.000488,-2163.384277,2712.000488 ,-1931.384277
2637.094238,-1937.709960,2901.094238,-1665.709960
2713.993652,-2237.376220,2913.993652,-1933.376220
Вы должны занести их в массив и получится:
Code
new Float:Gangkoordinaten[5][4]={
{2361.524902,-2685.230468,2857.524902,-2317.230468},
{2409.545166,-1931.665161,2641.545166,-1619.665161},
{2400.000488,-2163.384277,27 12.000488,-1931.384277},
{2637.094238,-1937.709960,2901.094238,-1665.709960},
{2713.993652,-2237.376220,2913.993652,-1933.376220}
} ;
Понятно, что добавляя координаты зон, мы меняем значение 5 на большее.
Добавлено (29.11.2010, 00:31)
---------------------------------------------
Добавляем переменную с цветами.
new GangColor[3]={0x00FF00D0,0x8000FFC9,0xFF0000C7};
И остальное
Code
new gangzone[5][1]; // 5 тоже меняем, если кол-во зон растет.
new gzc[sizeof(Gangkoordinaten)];
new taketurfbackcount[MAX_PLAYERS];
new gangkillcount[MAX_PLAYERS];
new mainzones;
new mainzones2;
new otvetk;
new otvetp;
Идем в public OnPlayerDeath
И почти в самое начало
Code
if(PlayerInfo[killerid][pLeader] == 13 || PlayerInfo[killerid][pLeader] == 14 || PlayerInfo[killerid][pLeader] == 15 || PlayerInfo[killerid][pLeader] == 16 || PlayerInfo[killerid][pLeader] == 17 || PlayerInfo[killerid][pLeader] == 18 || PlayerInfo[killerid][pMember] == 13 || PlayerInfo[killerid][pMember] == 14 || PlayerInfo[killerid][pMember] == 15 || PlayerInfo[killerid][pMember] == 16 || PlayerInfo[killerid][pMember] == 17 || PlayerInfo[killerid][pMember] == 18)
{
if(PlayerInfo[playerid][pLeader] == 13 || PlayerInfo[playerid][pLeader] == 14 || PlayerInfo[playerid][pLeader] == 15 || PlayerInfo[playerid][pLeader] == 16 || PlayerInfo[playerid][pLeader] == 17 || PlayerInfo[playerid][pLeader] == 18 || PlayerInfo[playerid][pMember] == 13 || PlayerInfo[playerid][pMember] == 14 || PlayerInfo[playerid][pMember] == 15 || PlayerInfo[playerid][pMember] == 16 || PlayerInfo[playerid][pMember] == 17 || PlayerInfo[playerid][pMember] == 18)
{
for(new h = 0; h < sizeof(Gangkoordinaten); h++)
{
if(IsPlayerInArea(killerid, Gangkoordinaten[h][0], Gangkoordinaten[h][1], Gangkoordinaten[h][2], Gangkoordinaten[h][3]))
{
if(PlayerInfo[killerid][pMember] == 0)
{
otvetk = PlayerInfo[killerid][pLeader];
}
else if(PlayerInfo[killerid][pLeader] == 0)
{
otvetk = PlayerInfo[killerid][pMember];
}
new str[256];
if(PlayerInfo[playerid][pMember] == 0)
{
otvetp = PlayerInfo[playerid][pLeader];
}
else if(PlayerInfo[playerid][pLeader] == 0)
{
otvetp = PlayerInfo[playerid][pMember];
}
if(otvetk == 13)
{
taketurfbackcount[killerid]++;
if(taketurfbackcount[killerid] == REOWN_TURF)
{
GangZoneStopFlashForAll(gzc[h]);
GangZoneHideForAll(gzc[h]);
GangZoneShowForAll(gzc[h], GangColor[0]);
//gangzone[h][mainzones] = 1;
taketurfbackcount[killerid] = 0;
}
}
if((otvetp != 13) && (otvetk == 13) && (killerid != INVALID_PLAYER_ID))
{
gangkillcount[killerid]++;
if(gangkillcount[killerid] == GANGAREA_WARNINGS)
{
if(gangzone[h][mainzones] == 1)
{
return 1;
}
SendClientMessageToAll(COLOR_RED,"Смотрящий: Территория атакована!");
GangZoneFlashForAll(gzc[h],GangColor[0]);
}
if(gangkillcount[killerid] == GANGAREA_TAKE)
{
if(gangzone[h][mainzones] == 1)
{
return 1;
}
new KillerName[30];
GetPlayerName(killerid, KillerName, 30);
format(str, 256, "Смотрящий: %s Захватил территорию!", KillerName);
SendClientMessageToAll(GangColor[0], str);
GangZoneStopFlashForAll(gzc[h]);
GangZoneHideForAll(gzc[h]);
GangZoneShowForAll(gzc[h], GangColor[0]);
gangzone[h][mainzones] = 1;
gangzone[h][mainzones2] = 1;
gangkillcount[killerid]=0;
}
}
if(otvetk == 14)
{
taketurfbackcount[killerid]++;
if(taketurfbackcount[killerid] == REOWN_TURF)
{
GangZoneStopFlashForAll(gzc[h]);
GangZoneHideForAll(gzc[h]);
GangZoneShowForAll(gzc[h], GangColor[1]);
//gangzone[h][mainzones] = 1;
taketurfbackcount[killerid] = 0;
}
}
if((otvetp != 14) && (otvetk == 14) && (killerid != INVALID_PLAYER_ID))
{
gangkillcount[killerid]++;
if(gangkillcount[killerid] == GANGAREA_WARNINGS)
{
if(gangzone[h][mainzones] == 2)
{
return 1;
}
SendClientMessageToAll(COLOR_RED,"Смотрящий: Территория атакована!");
GangZoneFlashForAll(gzc[h],GangColor[1]);
}
if(gangkillcount[killerid] == GANGAREA_TAKE)
{
if(gangzone[h][mainzones] == 2)
{
return 1;
}
new KillerName[30];
GetPlayerName(killerid, KillerName, 30);
format(str, 256, "Смотрящий: %s Захватил территорию!", KillerName);
SendClientMessageToAll(GangColor[1], str);
GangZoneStopFlashForAll(gzc[h]);
GangZoneHideForAll(gzc[h]);
GangZoneShowForAll(gzc[h], GangColor[1]);
gangzone[h][mainzones] = 2;
gangzone[h][mainzones2] = 2;
gangkillcount[killerid]=0;
}
}
if(otvetk == 15)
{
taketurfbackcount[killerid]++;
if(taketurfbackcount[killerid] == REOWN_TURF)
{
GangZoneStopFlashForAll(gzc[h]);
GangZoneHideForAll(gzc[h]);
GangZoneShowForAll(gzc[h], GangColor[2]);
//gangzone[h][mainzones] = 1;
taketurfbackcount[killerid] = 0;
}
}
if((otvetp != 15) && (otvetk == 15) && (killerid != INVALID_PLAYER_ID))
{
gangkillcount[killerid]++;
if(gangkillcount[killerid] == GANGAREA_WARNINGS)
{
if(gangzone[h][mainzones] == 3)
{
return 1;
}
SendClientMessageToAll(COLOR_RED,"Смотрящий: Территория атакована!");
GangZoneFlashForAll(gzc[h],GangColor[2]);
}
if(gangkillcount[killerid] == GANGAREA_TAKE)
{
if(gangzone[h][mainzones] == 2)
{
return 1;
}
new KillerName[30];
GetPlayerName(killerid, KillerName, 30);
format(str, 256, "Смотрящий: %s Захватил территорию!", KillerName);
SendClientMessageToAll(GangColor[2], str);
GangZoneStopFlashForAll(gzc[h]);
GangZoneHideForAll(gzc[h]);
GangZoneShowForAll(gzc[h], GangColor[2]);
gangzone[h][mainzones] = 3;
gangzone[h][mainzones2] = 3;
gangkillcount[killerid]=0;
}
}
SaveZones();
}
}
}
}
Добавлено (29.11.2010, 00:32)
---------------------------------------------
В public OnGameModeInit()
Code
for(new h = 0; h < sizeof(Gangkoordinaten); h++)
{
gzc[h] = GangZoneCreate(Gangkoordinaten[h][0], Gangkoordinaten[h][1], Gangkoordinaten[h][2], Gangkoordinaten[h][3]);
}
В public OnPlayerSpawn
Code
new gzcolor;
for(new h = 0; h < sizeof(Gangkoordinaten); h++)
{
if (gangzone[h][mainzones] == 1)
{
gzcolor = GangColor[0];
}
else if(gangzone[h][mainzones] == 2)
{
gzcolor = GangColor[1];
}
else if(gangzone[h][mainzones] == 3)
{
gzcolor = GangColor[2];
}
GangZoneShowForPlayer(playerid, gzc[h], gzcolor);
}
Добавляем паблики:
Code
public LoadZones()
{
new arrCoords[2][512];
new strFromFile2[512];
new File: file = fopen("gangzones.cfg", io_read);
if (file)
{
new idx;
while (idx < 5)
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, '|');
gangzone[idx][mainzones] = strval(arrCoords[0]);
gangzone[idx][mainzones2] = strval(arrCoords[1]);
printf("GANGZONE %d ",gangzone[idx][mainzones]);
idx++;
}
fclose(file); //
}
return 1;
}
public SaveZones()
{
new idx;
new File: file2;
while (idx < 5)
{
new coordsstring[512];
format(coordsstring, sizeof(coordsstring), "%d|%d\n",
gangzone[idx][mainzones],
gangzone[idx][mainzones2]
);
if(idx == 0)
{
file2 = fopen("gangzones.cfg", io_write);
}
else
{
file2 = fopen("gangzones.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}
stock IsPlayerInArea(playerid, Float:min_x, Float:min_y ,Float:max_x, Float:max_y)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
if(X <= max_x && X >= min_x && Y <= max_y && Y >= min_y) return 1;
return 0;
}
Форварды к ним:
Code
forward LoadZones();
forward SaveZones();
Добавляем Дефайны в начало:
Code
#define REOWN_TURF 4
#define GANGAREA_WARNINGS 2
#define GANGAREA_TAKE 4
Лоадим (добавляем строчку) LoadZones(); в public OnGameModeInit()
Создаем файл gangzones.cfg в скриптфайлах и заполняем
Code
1|1
2|2
3|3
2|2
1|1
Это 5 наших зон, разных цветов. (почему 2 раза - код не оптимизирован)
Как заметили у нас 3 банды ID 13\14\15
На этом наверное все. Что забыл потом допишу.
зделайте чтобы ,можно было /capture писать и атаковать через каждые 2 часа плз!