SA-MP Forums Archive
Creating A Capturable Ganzone - 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: Creating A Capturable Ganzone (/showthread.php?tid=358246)



Creating A Capturable Ganzone - DarrenReeder - 09.07.2012

Hello,

I have create some gangzones on my server and saved each gangzone on the script like this:

pawn Код:
enum gZone
{
    gID, // ID of the gangzone
    gGangID, // The Gang ID it belongs to (0 for NOT TAKEN)
    Float:gLeft, // Min X
    Float:gBottom, // Min Y
    Float:gRight, // MAX X
    Float:gTop, // Max Y
};
new GangZone[15+1][gZone];
Now I want to make it so if a player is inside the turf that is in a gang, it starts a "turf war" after 30 seconds or so..

My only idea of how i can do this is by having a random timer that runs every 30 wseconds that checks to see all the players positions in the server and starts a gang war if the player is inside an enemy turf AND the player is in a gang.

Any ideas would be great!


Re: Creating A Capturable Ganzone - coole210 - 09.07.2012

I would make a timer that lasts every second, and make a variable decrease by one every second if the player is in the turf. This allows for a "You have %d seconds to leave this turf before you start a turf war" message.

Example:

pawn Код:
//Variables to put under gang enum (or whatever you use)
GangWar[MAX_GANGS] = 0; //Can have a gang war between multiple gangs
//Global:
new Tick_TurfWar[MAX_PLAYERS]
//Under a timer:
Tick_TurfWar[i] -= 1;
I think you can figure the rest out.


Re: Creating A Capturable Ganzone - DarrenReeder - 09.07.2012

Wouldnt having it run every second cause a lot of server lag?


Re: Creating A Capturable Ganzone - coole210 - 09.07.2012

I would assume so, unless you have a OnPlayerTriggerGangZone callback.


Re: Creating A Capturable Ganzone - DarrenReeder - 09.07.2012

How do i make my own callback? With a plugin?


Re: Creating A Capturable Ganzone - coole210 - 09.07.2012

If you have any timer at all, you could trigger the function if the player's gangzone has changed.

Example:

pawn Код:
//In a timer:
if(GangZone[i] != CurrentGangZone)
{
OnPlayerTriggerGangZone(i, CurrentGangZone); //Then in this function you can check to start a turf war
}