SA-MP Forums Archive
Need Help with Capture Zone - 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: Need Help with Capture Zone (/showthread.php?tid=370536)



Need Help with Capture Zone - Pravin - 20.08.2012

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


Re: Need Help with Capture Zone - Gangs_Rocks - 20.08.2012

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..


Re: Need Help with Capture Zone - Pravin - 20.08.2012

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;
}