Gang War help
#1

So i'm creating a gang war base on MadeMan's Gang Zone War tutorial.
The modification works well but the problem is i don't know how could i stop the gang war
if the player who starts the gang war disconnected. If he is only by himself when in gang war, ends the gangwar.
If he is with his men (friends) in gang war, the gangwar remains even one member disconnected.

How do i do this?

How can i also check if the player is in gangwar?

pawn Код:
CMD:attack(playerid, params[])
{
    new
        string[150]
    ;
    if(IsPlayerSpawn(playerid) == 0) return SendClientMessage(playerid, BIKERS, "ERROR: You must be spawned first!");
    if(GetPlayerInterior(playerid) != 0) return SendClientMessage(playerid, BIKERS, "ERROR: You cannot take over turfs inside interior!");
    for(new i=0; i < sizeof(ZoneInfo); i++)
    {
        if(IsPlayerInZone(playerid, i))
        {
            if(ZoneInfo[i][teams] == gTeam[playerid]) return SendClientMessage(playerid, BIKERS, "ERROR: This zone is already taken over by your gang!");
            if(ZoneAttacker[i] == -1)
            {
                for(new t=0; t < sizeof(Teams); t++)
                {
                    if(Teams[t] != ZoneInfo[i][teams] && GetPlayersInZone(i, Teams[t]) >= 1)
                    {
                        ZoneAttacker[i] = Teams[t];
                        ZoneAttackTime[i] = 0;
                        GangZoneFlashForAll(ZoneID[i], GetTeamZoneColor(ZoneAttacker[i]));
                        if(GetPlayersInZone(i, ZoneAttacker[i]) > 1) format(string, sizeof string, "%s %s is taking over \" %s \" turf by his %d men!", GetTeamName(gTeam[playerid]), GetName(playerid), GetTeamName(ZoneInfo[i][teams]), GetPlayersInZone(i, ZoneAttacker[i]));
                        else format(string, sizeof string, "%s %s is taking over \" %s \" turf by himself!", GetTeamName(gTeam[playerid]), GetName(playerid), GetTeamName(ZoneInfo[i][teams]));
                        CheckTime[playerid] = SetTimerEx("TakeOver", 1000, true, "ii", playerid, gTeam[playerid]);
                        printf("%s taking over %s", GetTeamName(gTeam[playerid]), GetTeamName(ZoneInfo[i][teams]));
                        SendClientMessageToAll(BIKERS, string);
                        TextDrawSetString(Textdraw0[playerid], "Time to take over the turf: ~r~0");
                        TextDrawShowForPlayer(playerid, Textdraw0[playerid]);
                        TextDrawShowForPlayer(playerid, Textdraw1);
                    }
                }
            }
        }
    }
    return 1;
}

public TakeOver(playerid, myteam)
{
    new
        str[150]
    ;
    for(new i=0; i < sizeof(ZoneInfo); i++)
    {
        if(ZoneAttacker[i] != -1)
        {
            if(GetPlayersInZone(i, ZoneAttacker[i]) >= 1)
            {
                ZoneAttackTime[i]++;
                if(ZoneAttackTime[i] == TAKEOVER_TIME)
                {
                    GangZoneStopFlashForAll(ZoneID[i]);
                    ZoneInfo[i][teams] = ZoneAttacker[i];
                    GangZoneShowForAll(ZoneID[i], GetTeamZoneColor(gTeam[playerid]));
                    ZoneAttacker[i] = -1;
                    format(str, sizeof str, "%s finally take over %s's turf!", GetTeamName(gTeam[playerid]), GetTeamName(ZoneInfo[i][teams]));
                    SendClientMessageToAll(GREEN, str);
                    printf(str);
                    TextDrawHideForPlayer(playerid, Textdraw0[playerid]);
                    TextDrawHideForPlayer(playerid, Textdraw1);
                    GameTextForPlayer(playerid, "~g~Taked over!", 1500, 3);
                    pInfo[playerid][GangSkills] += 1;
                    GivePlayerMoney(playerid, 9000);
                    GivePlayerScore(playerid, 1);
                    SendClientMessage(playerid, YELLOW, "Payout: You receive 9000$ + Increase Gang Skill + 1 score!");
                    KillTimer(CheckTime[playerid]);
                }
                else if(ZoneAttackTime[i] != TAKEOVER_TIME)
                {
                    format(str, sizeof str, "Time to take over the turf: ~r~%d", ZoneAttackTime[i]);
                    TextDrawSetString(Textdraw0[playerid], str);
                }
            }
            else
            {
                GangZoneStopFlashForAll(ZoneID[i]);
                ZoneAttacker[i] = -1;
                format(str, sizeof str, "%s fails to take over %s's turf!", GetTeamName(gTeam[playerid]), GetTeamName(ZoneInfo[i][teams]));
                SendClientMessageToAll(BIKERS, str);
                TextDrawHideForPlayer(playerid, Textdraw0[playerid]);
                TextDrawHideForPlayer(playerid, Textdraw1);
                printf(str);
                GameTextForPlayer(playerid, "~r~Fail to take over!", 2000, 3);
                KillTimer(CheckTime[playerid]);
            }
        }
    }
    return 1;
}
Reply
#2

GetPlayersInZone Does all the work but by some reason you place it in 1

pawn Код:
if(Teams[t] != ZoneInfo[i][teams] && GetPlayersInZone(i, Teams[t]) > 1)
It test of this way and ensure that GetPlayersInZone use IsPlayerConnected function.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)