Gang zone prevent to capture again
#1

Hi!


Are there anyway I can prevent a player to capture a gang zone he already owns?..

I guess it works with getting the color of the player and then compare it to the zone..

Or are there any more smarter way?, show some small example..

Preferably a pretty easy way..
Reply
#2

Save the owner of each gangzone in a variable?

pawn Код:
forward OnPlayerCaptureZone(playerid, zoneid);
public OnPlayerCaptureZone(playerid, zoneid)
{
    Owner[zoneid] = playerid;
    return 1;
}

forward OnPlayerAttemptCaptureZone(playerid, zoneid);
public OnPlayerAttemptCaptureZone(playerid, zoneid)
{
      if(Owner[zoneid] == playerid)
          return 0;
}
You should get the idea with those examples; The player color one is a good one as long as no one has repeated colors, however with this way you could add flexibility to check more things, list zone owners, etc..

If you don't need these things then go with the colors one. Remember getplayercolor only works if setplayercolor is used before.
Reply
#3

Remember if it's a 'gang' zone, that normally means that there's more than one person, so why don't you store the gang value into a variable..? using them examples given above, you should be able to get around doing this. Need any help pm me

ps, i only say this because if you just do the gang owner, then the other gang members will be able to capture the zone.
Reply
#4

Hmm I don't actually don't get it to fully, I tired with that variable example.
But I have a completely different turf script, as mine is very very simple.

Forgot to mention it in first post sorry..

pawn Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    if(checkpointid == GolfCP)
    {
   
    TurfOwner[GolfZone] = playerid;
    SetTimerEx("GolfTurfT",9000,0,"i",playerid);
    GangZoneShowForAll(GolfZone,GetPlayerColor(playerid)); //Old color 0xFF71B896
    GangZoneFlashForAll(GolfZone,(playerid));
    }

pawn Код:
public GolfTurfT(playerid)
{
    if(TurfOwner[GolfZone] == playerid)
    GangZoneStopFlashForAll(GolfZone);
    GivePlayerMoney(playerid, 9000);
}

But it didn't happened anything.

Maybe have done it wrong some how.. Damn tired right now xD..

Edit:

ross8839 @ Thanks, I'll look into it tomorrow, my brain won't work properly right now
to tired xD.
Reply
#5

Alright, you have to set the owner of the turf AFTER the player has captured it, so following your code it would be

pawn Код:
public GolfTurfT(playerid)
{
    TurfOwner[GolfZone] = playerid;
    GangZoneStopFlashForAll(GolfZone);
    GivePlayerMoney(playerid, 9000);
}
And then check before the player initiates capturing

pawn Код:
if(checkpointid == GolfCP)
    {
   
    if(TurfOwner[GolfZone] == playerid)
           return 1;

    SetTimerEx("GolfTurfT",9000,0,"i",playerid);
    GangZoneShowForAll(GolfZone,GetPlayerColor(playerid)); //Old color 0xFF71B896
    GangZoneFlashForAll(GolfZone,(playerid));
    }
Consider making protection, if there's more than one person in the turf it will be captured for both.
Reply
#6

Quote:
Originally Posted by CuervO
Посмотреть сообщение
Alright, you have to set the owner of the turf AFTER the player has captured it, so following your code it would be

pawn Код:
public GolfTurfT(playerid)
{
    TurfOwner[GolfZone] = playerid;
    GangZoneStopFlashForAll(GolfZone);
    GivePlayerMoney(playerid, 9000);
}
And then check before the player initiates capturing

pawn Код:
if(checkpointid == GolfCP)
    {
   
    if(TurfOwner[GolfZone] == playerid)
           return 1;

    SetTimerEx("GolfTurfT",9000,0,"i",playerid);
    GangZoneShowForAll(GolfZone,GetPlayerColor(playerid)); //Old color 0xFF71B896
    GangZoneFlashForAll(GolfZone,(playerid));
    }
Consider making protection, if there's more than one person in the turf it will be captured for both.
I tired that but it didn't worked to capture at all now.
Reply
#7

Set TurfOwner as INVALID_PLAYER_ID as default, as otherwise it'll be default 0 and it wont work if you're player id 0
Reply
#8

Quote:
Originally Posted by CuervO
Посмотреть сообщение
Set TurfOwner as INVALID_PLAYER_ID as default, as otherwise it'll be default 0 and it wont work if you're player id 0
Can you show a example?, thanks .
Reply
#9

Bump!
Reply
#10

Quote:
Originally Posted by davve95
Посмотреть сообщение
Hi!


Are there anyway I can prevent a player to capture a gang zone he already owns?..

I guess it works with getting the color of the player and then compare it to the zone..

Or are there any more smarter way?, show some small example..

Preferably a pretty easy way..
I hope this tutorial would say things well, read it out well.
https://sampforum.blast.hk/showthread.php?tid=276352
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)