Boufen | Дата: Суббота, 06.04.2013, 10:16 | Сообщение # 1 |
Проверенный временем
Группа: Проверенный
Сообщений: 204
Статус: Offline
| Код new AttackPlayer[MAX_PLAYERS]; new GroveGangZ = 0; new AztecGangZ = 0; new RifaGangZ = 0; new VagosGangZ = 0; new BallasGangZ = 0; new BaikerGangZ = 0; new gangColors[MAX_PLAYERS]; #define ZonesCount 100 //ето скоко зон будет читаться с ганг зон enum GangZonesEnum { Float:zX1, Float:zY1, Float:zX2, Float:zY2, gangID }; new zoneInfo[ZonesCount][GangZonesEnum]; new zonesID[ZonesCount]; new LastTimer[ZonesCount]; forward IsAGangZ(playerid); forward InitGangZones(); new Text:TextdrawDrugT[MAX_PLAYERS]; new AttackTimer[MAX_PLAYERS]; forward SaveGangZones(); forward IsInsideGangZone(playerid, zoneID); forward CheckConnectedPlayer(playerid); forward CaptureCheckTimer(num, zoneID, attackGang, defeatGang); forward StartCaptureGangZone(playerid, killerid); forward CommandCaptureGangZone(playerid); в pInfo
pGangMoney,
Добавляем команду: Код if(strcmp(cmd, "/attack", true) == 0) //команду пишим свою. { if(!IsAGangZ(playerid)) return SendClientMessage(playerid,COLOR_GRAD1,"Вы не в банде"); CommandCaptureGangZone(playerid); //SendClientMessage(playerid,COLOR_GRAD1,"Команда отключена. Убивайте игроков на их зоне, чтобы захватить."); return 1; } Добовляем паблик верх! Код public IsAGangZ(playerid) { if(IsPlayerConnected(playerid)) { new leader = PlayerInfo[playerid][pLeader]; new member = PlayerInfo[playerid][pMember]; if(member==12 || member==13 || member==14 || member==15 || member==17)//смените фраки на свои { return 1; } if(leader==12 || leader==13 || leader==14 || leader==15 || leader==17) { return 1; } } return 0; } Добавляем в паблик public SyncUp() Код for(new i = 0; i < MAX_PLAYERS; i++) { if(IsAGangZ(i) && gPlayerLogged [i]== 1) { if(PlayerInfo[i][pLeader]==12||PlayerInfo[i][pMember]==12) { PlayerInfo[i] [pGangMoney]+= GroveGangZ; } else if(PlayerInfo[i][pLeader]==13||PlayerInfo[i][pMember]==13) { PlayerInfo[i] [pGangMoney]+= BallasGangZ; } else if(PlayerInfo[i][pLeader]==14||PlayerInfo[i][pMember]==14) { PlayerInfo[i] [pGangMoney]+= VagosGangZ; } else if(PlayerInfo[i][pLeader]==15||PlayerInfo[i][pMember]==15) { PlayerInfo[i] [pGangMoney]+= AztecGangZ; } else if(PlayerInfo[i][pLeader]==17||PlayerInfo[i][pMember]==17) { PlayerInfo[i] [pGangMoney]+= RifaGangZ; } } } создаем паблики в конец мода! Код public InitGangZones() { //заполняем только нужные ИД gangColors[255] = 0xC0C0C0AA; gangColors[12] = 0x1DDE12AA; gangColors[13] = 0xA2359EAA; gangColors[14] = 0xFFFF09AA; gangColors[15] = 0x2CDCD3AA; gangColors[17] = 0x472DDBAA;
new splittedInfo[5][256];//5 - количество параметров, 256 - длина строки new strFromFile[256]; new strToPrint[256]; new File:zonesFile = fopen("gangzones.cfg", io_read); if (zonesFile) { for(new idx=0;idx<ZonesCount;idx++) { fread(zonesFile, strFromFile); split(strFromFile, splittedInfo, ','); //заполняем массив zoneInfo[idx][zX1] = floatstr(splittedInfo[0]); zoneInfo[idx][zY1] = floatstr(splittedInfo[1]); zoneInfo[idx][zX2] = floatstr(splittedInfo[2]); zoneInfo[idx][zY2] = floatstr(splittedInfo[3]); zoneInfo[idx] [gangID]= strval(splittedInfo[4]); if(zoneInfo[idx] [gangID]== 12) { GroveGangZ+=1; } else if(zoneInfo[idx] [gangID]== 13) { BallasGangZ+=1; } else if(zoneInfo[idx] [gangID]== 14) { VagosGangZ+=1; } else if(zoneInfo[idx] [gangID]== 15) { AztecGangZ+=1; } else if(zoneInfo[idx] [gangID]== 17) { RifaGangZ+=1; } //создаём зону new tmpZone = GangZoneCreate(zoneInfo[idx][zX1], zoneInfo[idx][zY1], zoneInfo[idx][zX2], zoneInfo[idx][zY2]); GangZoneHideForAll(tmpZone); zonesID [tmpZone]= idx; format(strToPrint, 256, "%f,%f,%f,%f,%d\n",zoneInfo[idx][zX1], zoneInfo[idx][zY1], zoneInfo[idx][zX2], zoneInfo[idx][zY2], zoneInfo[idx][gangID]); printf(strToPrint); } fclose(zonesFile); } }
public SaveGangZones() { new StrToFile[256]; new File:zonesFile = fopen("gangzones.cfg", io_write); if (zonesFile) { for(new i=0;i<ZonesCount;i++) { format(StrToFile, sizeof(StrToFile), "%f,%f,%f,%f,%d\n",zoneInfo[i][zX1], zoneInfo[i][zY1], zoneInfo[i][zX2], zoneInfo[i][zY2], zoneInfo[i][gangID]); fwrite(zonesFile, StrToFile); } fclose(zonesFile); } }
public IsInsideGangZone(playerid, zoneID) { new Float:pX, Float:pY, Float:pZ; GetPlayerPos(playerid, pX, pY, pZ); new tmpZone = zonesID[zoneID];
if(pX >= zoneInfo[tmpZone][zX1] && pY >= zoneInfo[tmpZone][zY1] && pX <= zoneInfo[tmpZone][zX2] && pY <= zoneInfo[tmpZone][zY2]) { return true; } return false; }
public CheckConnectedPlayer(playerid)//положить в онплэер логин. { if(IsAGangZ(playerid)) { for(new i=0;i<ZonesCount;i++) { new tmpID = zoneInfo[zonesID[i]][gangID]; GangZoneShowForPlayer(playerid, i, gangColors[tmpID]); } } }
public CaptureCheckTimer(num, zoneID, attackGang, defeatGang) { KillTimer(LastTimer[zoneID]); new stillCapturing = 0; new Float:pHP; for(new i=0;i<MAX_PLAYERS;i++) { if(IsPlayerConnected(i) && (PlayerInfo[i] [pMember]== attackGang || PlayerInfo[i] [pLeader]== attackGang)) { GetPlayerHealth(i, pHP); if(pHP > 0.0 && IsInsideGangZone(i, zoneID)) { stillCapturing = 1; } } }
if(stillCapturing) { if(num < 300) { LastTimer [zoneID]= SetTimerEx("CaptureCheckTimer", 1000, 0, "iiii", num+1, zoneID, attackGang, defeatGang); } else { new tmpZone = zonesID[zoneID]; zoneInfo[tmpZone] [gangID]= attackGang;
for(new i=0;i<MAX_PLAYERS;i++) { if(IsPlayerConnected(i) && IsAGangZ(i)) { GangZoneStopFlashForPlayer(i, zoneID); GangZoneHideForPlayer(i, zoneID); GangZoneShowForPlayer(i, zoneID, gangColors[attackGang]); AttackTimer [i]= 0; TextDrawHideForPlayer(i,TextdrawDrugT[i]); } } } } else { for(new i=0;i<MAX_PLAYERS;i++) { if(IsPlayerConnected(i) && IsAGangZ(i)) { GangZoneStopFlashForPlayer(i, zoneID); AttackTimer [i]= 0; TextDrawHideForPlayer(i,TextdrawDrugT[i]); } } } return 1; }
public StartCaptureGangZone(playerid, killerid) { new battleZone = -1; for(new i=0;i<ZonesCount;i++) { if(IsInsideGangZone(playerid, i) && IsInsideGangZone(killerid, i)) { battleZone = i; break; } }
new tmpZone = zonesID[battleZone]; if(battleZone != -1 && zoneInfo[tmpZone] [gangID]== PlayerInfo[playerid][pMember]) { if(IsAGangZ(playerid)) { if(IsAGangZ(killerid)) { if (PlayerInfo[killerid] [pMember]!= PlayerInfo[playerid][pMember]) { for(new i=0;i<MAX_PLAYERS;i++) { if(IsPlayerConnected(i) && IsAGangZ(i)) { TextDrawShowForPlayer(AttackPlayer[killerid],TextdrawDrugT[killerid]); AttackTimer [killerid]= 300; if(PlayerInfo[killerid] [pMember]> 0) { GangZoneFlashForPlayer(i, battleZone, gangColors[PlayerInfo[killerid][pMember]]); } else if(PlayerInfo[killerid] [pLeader]> 0) { GangZoneFlashForPlayer(i, battleZone, gangColors[PlayerInfo[killerid][pLeader]]); } } } if(PlayerInfo[killerid] [pLeader]== 0 && PlayerInfo[playerid] [pLeader]== 0) { LastTimer [battleZone]= SetTimerEx("CaptureCheckTimer", 1000, 0, "iiii", 0, battleZone, PlayerInfo[killerid][pMember], PlayerInfo[playerid][pMember]); } else if(PlayerInfo[killerid] [pMember]== 0 && PlayerInfo[killerid] [pMember]== 0) { LastTimer [battleZone]= SetTimerEx("CaptureCheckTimer", 1000, 0, "iiii", 0, battleZone, PlayerInfo[killerid][pLeader], PlayerInfo[playerid][pLeader]); } else if(PlayerInfo[killerid] [pLeader]== 0 && PlayerInfo[playerid] [pLeader]!= 0) { LastTimer [battleZone]= SetTimerEx("CaptureCheckTimer", 1000, 0, "iiii", 0, battleZone, PlayerInfo[killerid][pMember], PlayerInfo[playerid][pLeader]); } else if(PlayerInfo[killerid] [pMember]== 0 && PlayerInfo[playerid] [pMember]!= 0) { LastTimer [battleZone]= SetTimerEx("CaptureCheckTimer", 1000, 0, "iiii", 0, battleZone, PlayerInfo[killerid][pLeader], PlayerInfo[playerid][pMember]); } } } } } }
public CommandCaptureGangZone(playerid) { new battleZone = -1; for(new i=0;i<ZonesCount;i++) { if(IsInsideGangZone(playerid, i)) { battleZone = i; break; } } if(battleZone != -1) { if(IsAGangZ(playerid)) { new tmpZone = zonesID[battleZone]; if(zoneInfo[tmpZone] [gangID]== 255) { for(new i=0;i<MAX_PLAYERS;i++) { if(IsAGangZ(i)) { if(PlayerInfo[i] [pMember]> 0) { GangZoneFlashForPlayer(i, battleZone, gangColors[PlayerInfo[playerid][pMember]]); } else if(PlayerInfo[i] [pLeader]> 0) { GangZoneFlashForPlayer(i, battleZone, gangColors[PlayerInfo[playerid][pLeader]]); } } } TextDrawShowForPlayer(playerid,TextdrawDrugT[playerid]); AttackTimer [playerid]= 300; if(PlayerInfo[playerid] [pLeader]== 0) { LastTimer [battleZone]= SetTimerEx("CaptureCheckTimer", 1000, 0, "iiii", 0, battleZone, PlayerInfo[playerid][pMember], 255); } else if(PlayerInfo[playerid] [pMember]== 0) { LastTimer [battleZone]= SetTimerEx("CaptureCheckTimer", 1000, 0, "iiii", 0, battleZone, PlayerInfo[playerid][pLeader], 255); } } else { for(new i=0;i<MAX_PLAYERS;i++) { if(IsAGangZ(i)) { if(PlayerInfo[i] [pMember]> 0) { GangZoneFlashForPlayer(i, battleZone, gangColors[PlayerInfo[playerid][pMember]]); } else if(PlayerInfo[i] [pLeader]> 0) { GangZoneFlashForPlayer(i, battleZone, gangColors[PlayerInfo[playerid][pLeader]]); } } } if(PlayerInfo[playerid] [pLeader]== 0) { LastTimer [battleZone]= SetTimerEx("CaptureCheckTimer", 1000, 0, "iiii", 0, battleZone, PlayerInfo[playerid][pMember], zoneInfo[tmpZone][gangID]); } else if(PlayerInfo[playerid] [pMember]== 0) { LastTimer [battleZone]= SetTimerEx("CaptureCheckTimer", 1000, 0, "iiii", 0, battleZone, PlayerInfo[playerid][pLeader], zoneInfo[tmpZone][gangID]); } } } } } В паблик CustomPickups Добавить Код if(AttackTimer [i]> 0) { AttackTimer[i]--; format(string, sizeof(string), "Attack: %d sec", AttackTimer[i]); TextDrawSetString(Text:TextdrawDrugT[i], string); } В паблик OnGameModeInit Код for(new i=0;i<MAX_PLAYERS;i++) { TextdrawDrugT [i]= TextDrawCreate(489.000000, 160.000000, "--"); TextDrawBackgroundColor(TextdrawDrugT[i], 255); TextDrawFont(TextdrawDrugT[i], 1); TextDrawLetterSize(TextdrawDrugT[i], 0.559999, 1.700000); TextDrawColor(TextdrawDrugT[i], -1); TextDrawSetOutline(TextdrawDrugT[i], 1); TextDrawSetProportional(TextdrawDrugT[i], 1); TextDrawSetShadow(TextdrawDrugT[i], 1); } Автор Misha
[url=http://pawno-info.ifolder.ru/24898437][/url]
Подключаю сервера с MySQL - 50 руб. Делаю маппинг на заказ - Цена договорная
|
|
| |