SA-MP Forums Archive
Chage specific zone's color - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Chage specific zone's color (/showthread.php?tid=579962)



Chage specific zone's color - nezo2001 - 01.07.2015

I want to change one zone's color after some code
PHP код:
    for(new i = 0; i < sizeof(ZoneInfo);i++)
    {
        if(
IsPlayerInGangZone(playerid, i) && IsPlayerInGangZone(killerid, i) && gTeam[playerid] != gTeam[killerid] && ZoneInfo[i][zTeam] != gTeam[killerid] && ZoneInfo[i][zTeam] == gTeam[playerid] && gTeam[playerid] != 0 && capturing[killerid] == false)
        {
            
capturing[killerid] = true;
            
CT2[killerid] = SetTimerEx("capture", 3*60000, false, "i", killerid);
            
CT[killerid] = SetTimerEx("CaptureTime", 1000, true, "i", killerid);
            
SendClientMessage(killerid, COLOR_GREEN, "Stay in the zone for 3 minutes and avoid dying by the other team!");
            
OthersTeam[killerid] = TeamName[playerid];
        }
    } 
PHP код:
public capture(playerid)
{
    if(
capturing[playerid] == true)
    {
        new 
ToAllMe[128];
        
format(ToAllMe, sizeof(ToAllMe), "%s gang has captured a zone from %s",TeamName[playerid], OthersTeam[playerid]);
        
SendClientMessageToAll(COLOR_GREEN, ToAllMe);
        for(new 
i = 0; i < sizeof(ZoneInfo);i++)
        {
            
GangZoneShowForAll(i, GetPlayerColor(playerid));
            
ZoneInfo[i][zColor] = GetPlayerColor(playerid);
            
ZoneInfo[i][zTeam] = zPlayerTeam[playerid];
            
GivePlayerMoney(playerid, 2000);
            
SetPlayerScore(playerid, GetPlayerScore(playerid)+2);
            
KillTimer(CT[playerid]);
            
captureTimer[playerid] = 180;
        }
    }
    return 
1;
} 
But I know this will change all zones' color now only the zone that I'm in


Re: Chage specific zone's color - Suicidal.Banana - 01.07.2015

Quote:
Originally Posted by nezo2001
Посмотреть сообщение
I want to change one zone's color after some code
...
But I know this will change all zones' color now only the zone that I'm in
Updated, added comments to point out the changes
PHP код:
    for(new i = 0; i < sizeof(ZoneInfo);i++)
    {
        if(
IsPlayerInGangZone(playerid, i) && IsPlayerInGangZone(killerid, i) && gTeam[playerid] != gTeam[killerid] && ZoneInfo[i][zTeam] != gTeam[killerid] && ZoneInfo[i][zTeam] == gTeam[playerid] && gTeam[playerid] != 0 && capturing[killerid] == false)
        {
            
capturing[killerid] = true;
            
CT2[killerid] = SetTimerEx("capture", 3*60000, false, "ii", killerid, i); // UPDATED; now has 2 arguments, the second beeing zoneid
            
CT[killerid] = SetTimerEx("CaptureTime", 1000, true, "i", killerid);
            
SendClientMessage(killerid, COLOR_GREEN, "Stay in the zone for 3 minutes and avoid dying by the other team!");
            
OthersTeam[killerid] = TeamName[playerid];
        }
    } 
PHP код:
public capture(playerid, zoneid)
{
    if(
capturing[playerid] == true)
    {
        new 
ToAllMe[128];
        
format(ToAllMe, sizeof(ToAllMe), "%s gang has captured a zone from %s",TeamName[playerid], OthersTeam[playerid]);
        
SendClientMessageToAll(COLOR_GREEN, ToAllMe);
        
// UPDATED; the below used to be the for loop, now that the capture function gets a zoneid it doesnt need the loop anymore
        
GangZoneShowForAll(zoneid, GetPlayerColor(playerid));
        
ZoneInfo[zoneid][zColor] = GetPlayerColor(playerid);
        
ZoneInfo[zoneid][zTeam] = zPlayerTeam[playerid];
        
GivePlayerMoney(playerid, 2000);
        
SetPlayerScore(playerid, GetPlayerScore(playerid)+2);
        
KillTimer(CT[playerid]);
        
captureTimer[playerid] = 180;
    }
    return 
1;
}