why is this text showing?
#1

Well, first, here is my code:


in the part where it says "%s captured %s" it kinda fails, look:



pawn Код:
new ZoneAttackTime[sizeof(ZoneInfo)];
stock GetTeamZoneColor(teamid)
{
    switch(teamid)
    {
        case TEAM_USA: return COLOR_BLUE;
        case TEAM_CHINA: return COLOR_RED;
        case TEAM_RUSSIA: return COLOR_GREEN;
        case TEAM_JAPAN: return COLOR_WHITE;
        case TEAM_IRAQ: return COLOR_YELLOW;
        case RANDOM: return COLOR_PINK;
    }
    return -1;
}
new ZoneID[sizeof(ZoneInfo)];
new ZoneAttacker[sizeof(ZoneInfo)] = {-1, ...};

#define MIN_MEMBERS_TO_START_WAR 1 // how many team members needed in a zone to start a war
#define TAKEOVER_TIME 4 // how many seconds needed to take over the zone
#define MIN_DEATHS_TO_START_WAR 0 // how many team members must be killed in a zone to start a war

new Teams[] = {
    TEAM_USA,
    TEAM_CHINA,
    TEAM_RUSSIA,
    TEAM_JAPAN,
    TEAM_IRAQ
};

stock IsPlayerInZone(playerid, zoneid)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    return (x > ZoneInfo[zoneid][zMinX] && x < ZoneInfo[zoneid][zMaxX] && y > ZoneInfo[zoneid][zMinY] && y < ZoneInfo[zoneid][zMaxY]);
}

stock GetPlayersInZone(zoneid, teamid)
{
    new count;
    for(new i=0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && GetPlayerTeam(i) == teamid && IsPlayerInZone(i, zoneid))
        {
            count++;
        }
    }
    return count;
}
forward ZoneTimer();
public ZoneTimer()
{
    for(new i=0; i < sizeof(ZoneInfo); i++) // loop all zones
    {
       
       
        if(ZoneAttacker[i] != -1) // zone is being attacked
        {
                      if(GetPlayersInZone(i, ZoneAttacker[i]) >= MIN_MEMBERS_TO_START_WAR) // team has enough members in the zone
            {
                ZoneAttackTime[i]++;
                if(ZoneAttackTime[i] == TAKEOVER_TIME) // zone has been under attack for enough time and attackers take over the zone
                {
                    new string[64];
                    format(string,sizeof string,">>>>>>>>>>%s captured %s's Territory!<<<<<<<<<<<<<<<",ZoneInfo,ZoneInfo[i][zTeam]);
                    SendClientMessageToAll(0xFFFFFFAA,string);
                    GangZoneStopFlashForAll(ZoneID[i]);
                    ZoneInfo[i][zTeam] = ZoneAttacker[i];
                    GangZoneShowForAll(ZoneID[i], GetTeamZoneColor(ZoneInfo[i][zTeam])); // update the zone color for new team
                    ZoneAttacker[i] = -1;
                }
            }
            else // attackers failed to take over the zone
            {
                GangZoneStopFlashForAll(ZoneID[i]);
                ZoneAttacker[i] = -1;
            }
        }
        else // check if somebody is attacking
        {
           
            for(new t=0; t < sizeof(Teams); t++) // loop all teams
            {
               
                if(GetPlayersInZone(i, Teams[t]) >= MIN_MEMBERS_TO_START_WAR) // if there are enough enemies in the zone
                {
                   
                } else continue;
               
                if(Teams[t] != ZoneInfo[i][zTeam])
                {
                    ZoneAttacker[i] = Teams[t];
                    ZoneAttackTime[i] = 0;
                    GangZoneFlashForAll(ZoneID[i], GetTeamZoneColor(ZoneAttacker[i]));
                    new string[128];
                    format(string,sizeof string,">>>>>>>>>>>%s's base is being CAPTURED!<<<<<<<<<<",ZoneInfo[i][zTeam]);
                    SendClientMessageToAll(0xFFFFFFAA,string);
                }

            }
        }
    }
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    /*if (PRESSED(KEY_JUMP))
    {
        new
            Float:x,
            Float:y,
            Float:z;
        GetPlayerPos(playerid, x, y, z);
        SetPlayerPos(playerid, x, y, z + 10.0);
    }*/

    return 1;
}
stock GetPlayerZone(playerid)
{
    for(new i=0; i < sizeof(ZoneInfo); i++)
    {
        if(IsPlayerInZone(playerid, i))
        {
            return i;
        }
    }
    return -1;
}
Reply
#2

Check the format(), you have two strings in the format (%s %s) and 3 values after the format string.
Reply
#3

They are just 2....

pawn Код:
ZoneInfo,ZoneInfo[i][zTeam]
Reply
#4

ZoneInfo is an array, you can't use it by itself. For the first one, you need ZoneInfo[ID_OF_THE_CAPTURING_TEAM][zTeam]
Reply
#5

And How will i know the id of the capturing team? it can be random.

Like how will i know when team_usa is capturing team_china or team_china to team_iraq?
Reply
#6

Quote:
Originally Posted by Super_Panda
Посмотреть сообщение
And How will i know the id of the capturing team? it can be random.

Like how will i know when team_usa is capturing team_china or team_china to team_iraq?
Check the players team, use it in a variable and display it's zone correctly.
Reply
#7

Any example?
If you fix it i will click that donate button
Reply
#8

@super_panda try instead of %s use %d and then write if it is fixed or not
Reply
#9

pawn Код:
format(string,sizeof string,">>>>>>>>>>Attention: %s captured %s's Territory!<<<<<<<<<<",ZoneInfo,ZoneInfo[i][zTeam]);
That works! But it shows this creepy shit:

Reply
#10

ZoneInfo isn't a string
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)