vladbro
Ученик
Такие дела,1: Цвет ГЗ как в сингле,нужен ярче.2.После рестарта не сохраняются захваченные зоны,восстанавливаются которые были...
Вот SaveGangZones:
А вот и всё остальное:
Вот SaveGangZones:
PHP:
public GameModeInitExitFunc()
{
new string[128];
format(string, sizeof(string), "Restart");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
DisablePlayerCheckpoint(i);
gPlayerCheckpointStatus[i] = CHECKPOINT_NONE;
GameTextForPlayer(i, string, 4000, 5);
SetPlayerCameraPos(i,1460.0, -1324.0, 287.2);
SetPlayerCameraLookAt(i,1374.5, -1291.1, 239.0);
OnPlayerUpdate_GF(i);
gPlayerLogged[i] = 0;
}
}
SaveGangZones();
SaveStuff();
SaveAccounts();
dini_IntSet("dandm.ini","materials",matsi);
dini_IntSet("dandm.ini","pritondrugs",pritondru);
dini_IntSet("dandm.ini","ambardrugs",ambardru);
return 1;
}
PHP:
public InitGangZones() //ïîëîæèòü â îíãàìåìîäå èíèò
{
//çàïîëíÿåì òîëüêî íóæíûå ÈÄ
gangColors[255] = 0xC0C0C0AA;
gangColors[14] = 0x36D352AA;
gangColors[16] = 0xDE17E4AA;
gangColors[18] = 0xB8860BAA;
gangColors[15] = 0x00FDFDAA;
gangColors[17] = 0x86B7B3AA;
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] == 14) { GroveGangZ+=1; }
else if(zoneInfo[idx][gangID] == 16) { BallasGangZ+=1; }
else if(zoneInfo[idx][gangID] == 18) { 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)//ïîëîæèòü â îíïëýåð ëîãèí.
{
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)//ïîëîæèòü â OnPlayerDeath
{
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))
{
//ìèãàåì çîíó, îòïðàâëÿåì ñîîáùåíèå :)
//new tmpVar = zonesID[battleZone];
//new gang = zoneInfo[tmpVar][gangID];
//if(AntiGangFlood == 0) { SendTeamMessage(gang, COLOR_ADMRED, "Çîíó âàøåé áàíäû çàõâàòûâþò! Îòáåéòå å¸"); AntiGangFlood = 1; }
TextDrawShowForPlayer(AttackPlayer[killerid],TextdrawDrugT[killerid]);
AttackTimer[killerid] = 100;
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))
{
//new tmpVar = zonesID[battleZone];
//new gang = zoneInfo[tmpVar][gangID];
//if(AntiGangFlood == 0) { SendTeamMessage(gang, COLOR_ADMRED, "Çîíó âàøåé áàíäû çàõâàòûâþò! Îòáåéòå å¸"); AntiGangFlood = 1; }
//ìèãàåì çîíó, îòïðàâëÿåì ñîîáùåíèå :)
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] = 200;
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))
{
//new tmpVar = zonesID[battleZone];
//new gang = zoneInfo[tmpVar][gangID];
//if(AntiGangFlood == 0) { SendTeamMessage(gang, COLOR_ADMRED, "Çîíó âàøåé áàíäû çàõâàòûâþò! Îòáåéòå å¸"); AntiGangFlood = 1; }
//ìèãàåì çîíó, îòïðàâëÿåì ñîîáùåíèå :)
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]); }
}
}
}
}
Последнее редактирование:
