Need Help with Capture Zone
#1

Hey guyz..
I made a capture Zone.
But it can be captured again and again by the player.
It doesnt stop :S

This is my code.

pawn Code:
new Checkpoint[MAX_PLAYERS];
new timer;


public OnPlayerEnterCheckpoint(playerid)
{
    SendClientMessage(playerid, -1, "<< Stay in the checkpoint for 30 seconds to capture it >>");
    if(gTeam[playerid] == TEAM_EURASIA)
{
    GangZoneFlashForAll(GZ_ZONE2,TEAM_EURASIA_COLOR);
}
if(gTeam[playerid] == TEAM_ARAB)
{
    GangZoneFlashForAll(GZ_ZONE2,TEAM_ARAB_COLOR);
}
if(gTeam[playerid] == TEAM_SOVIET)
{
    GangZoneFlashForAll(GZ_ZONE2,TEAM_SOVIET_COLOR);
}
if(gTeam[playerid] == TEAM_USA)
{
    GangZoneFlashForAll(GZ_ZONE2,TEAM_USA_COLOR);
}
if(gTeam[playerid] == TEAM_AUS)
{
    GangZoneFlashForAll(GZ_ZONE2,TEAM_AUS_COLOR);
}
    timer = SetTimerEx("SetZone", 30000, false, "i", playerid);
    Checkpoint[playerid] = 1;

return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
if(Checkpoint[playerid] == 1)
    {
        SendClientMessage(playerid, 0x00FF007A, "<< You have left the checkpoint and failed to capture the zone >>");
        GangZoneStopFlashForAll(GZ_ZONE2);
        KillTimer(timer);
        Checkpoint[playerid] = 0;
    }
return 1;
}
Pls help me..
ofc, +REP :P
Reply
#2

You need to make a more dynamic system,

Your current system doesn't store which team owns the zone, or if it's being attacked or not. You need to store that data.

Next, You're using a very inefficient system. I'd suggest you use GetTeamColor (Create a custom stock for yourself) instead of checking each team.

OnPlayerEnterCP
You gotta perform a CHECK here.

pawn Code:
if(OwnedBy[GANGZONENAME] == gTeam[playerid] ) return SendClientMessage(playerid, -1, "Your team already owns this place! ");
else
{
// cODE
}

I'll make a tutorial on how to make capture zones soon to clear out people's doubts, but for now, You're doing it COMPLETELY wrong.

Try to look for a turf-capturing system and try to make it that way..
Reply
#3

pawn Code:
D:\gta sanandreas\All Sa-Mp related Things\ScriptsSource\gamemodes\VG-TDM.pwn(1071) : error 017: undefined symbol "OwnedBy"
D:\gta sanandreas\All Sa-Mp related Things\ScriptsSource\gamemodes\VG-TDM.pwn(1071) : warning 215: expression has no effect
D:\gta sanandreas\All Sa-Mp related Things\ScriptsSource\gamemodes\VG-TDM.pwn(1071) : error 001: expected token: ";", but found "]"
D:\gta sanandreas\All Sa-Mp related Things\ScriptsSource\gamemodes\VG-TDM.pwn(1071) : error 029: invalid expression, assumed zero
D:\gta sanandreas\All Sa-Mp related Things\ScriptsSource\gamemodes\VG-TDM.pwn(1071) : fatal error 107: too many error messages on one line
Line :

pawn Code:
public OnPlayerEnterCheckpoint(playerid)
{
if(OwnedBy[GZ_ZONE2] == gTeam[playerid] ) return SendClientMessage(playerid, -1, "Your team already owns this place! ");
else
{
    TextDrawShowForAll(Att);
    TextDrawShowForAll(Att1);
    SendClientMessage(playerid, -1, "<< Stay in the checkpoint for 30 seconds to capture it >>");
    if(gTeam[playerid] == TEAM_EURASIA)
{
    GangZoneFlashForAll(GZ_ZONE2,TEAM_EURASIA_COLOR);
}
if(gTeam[playerid] == TEAM_ARAB)
{
    GangZoneFlashForAll(GZ_ZONE2,TEAM_ARAB_COLOR);
}
if(gTeam[playerid] == TEAM_SOVIET)
{
    GangZoneFlashForAll(GZ_ZONE2,TEAM_SOVIET_COLOR);
}
if(gTeam[playerid] == TEAM_USA)
{
    GangZoneFlashForAll(GZ_ZONE2,TEAM_USA_COLOR);
}
if(gTeam[playerid] == TEAM_AUS)
{
    GangZoneFlashForAll(GZ_ZONE2,TEAM_AUS_COLOR);
}
    timer = SetTimerEx("SetZone", 30000, false, "i", playerid);
    Checkpoint[playerid] = 1;
}
return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
if(Checkpoint[playerid] == 1)
    {
        TextDrawHideForAll(Att);
        TextDrawHideForAll(Att1);
        SendClientMessage(playerid, 0x00FF007A, "<< You have left the checkpoint and failed to capture the zone >>");
        GangZoneStopFlashForAll(GZ_ZONE2);
        KillTimer(timer);
        Checkpoint[playerid] = 0;
    }
return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)