Gang Zone [HELP]
#1

I'm creating capture-able turf's for my server. I'm using Mademan's Tutorial and another code a friend gave me. Here is the pawn code :
Код:
#define FILTERSCRIPT

#include <a_samp>

// ----- Variables

#define MAX_GANGZONES   15

new Checkpoint[MAX_PLAYERS];
new GroveTurf;
new timer;

// ----- Callbacks

public OnFilterScriptInit()
{
	GroveTurf = GangZoneCreate(2402.546, -1737.13, 2604.096, -1630.541); // Creating the GangZone
	GangZoneShowForAll(GroveTurf, 0x00FF007A);
	return 1;
}

public OnFilterScriptExit()
{
	GangZoneDestroy(GroveTurf);
	return 1;
}

public OnPlayerSpawn(playerid)
{
    SetPlayerCheckpoint(playerid, 2487.0391,-1668.5784,13.3438,8);
	SetPlayerColor(playerid, 0xFF80FFFF); // Pink
	return 1;
}

public OnPlayerEnterCheckpoint(playerid) // If the player enters a particluar checkpoint
{
	SendClientMessage(playerid, 0x00FF007A, "Please Wait 20 Seconds - To Caputre this turf."); // Telling the player to wait 20 seconds.
	GangZoneFlashForAll(GroveTurf,  0xFF80FF76); // Makes the turf Flash Pink ( telling everyone its being taken over )
	SendClientMessageToAll(0xFF80FFFF, "The Grove Street Turf is being taken over"); // Sending Message to all players.
	timer = SetTimerEx("SetZone", 20000, false, "i", playerid); // Setting the Timer... ( 20 seconds )
	Checkpoint[playerid] = 1; // Telling the variable that the player is in the checkpoint.
	return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
	if(Checkpoint[playerid] == 1)
	{
		SendClientMessage(playerid, 0x00FF007A, "ERROR : You have left the checkpoint");
		GangZoneStopFlashForAll(GroveTurf);
		SendClientMessageToAll(0x00FF007A, "The Grove Street Turf is now safe");
		KillTimer(timer);
		Checkpoint[playerid] = 0;
	}
	else
	{
	    // nothing
	}
	return 1;
}

// Custom Callbacks

forward SetZone(playerid);
public SetZone(playerid)
{
	if(Checkpoint[playerid] == 1)
	{
		GangZoneStopFlashForAll(GroveTurf); // Stopping it Flashing.
		GangZoneHideForAll(GroveTurf); // Hiding the GangZone
		GangZoneShowForAll(GroveTurf, 0xFF80FF76); // Showing the GangZone with the new colour
		SendClientMessageToAll(0x00FF007A, "The Grove Street Turf, has been sucessfully taken over");
		Checkpoint[playerid] = 0;
		// You could delete the check point then make it spawn again in 10 minutes or something...
	}
	return 1;
}
Now, For OnPlayerSpawn, I will create a pickup Icon. Not a checkpoint. So , I move all the OnPlayerCheckpoint variables to OnPlayPickupPickup. I want a small checkpoint around him, showing he only can move in that space. If he leaves the checkpoint, it stops flashing. How do I do that? And I disable the Checkpoints. Just make it icons, and when the player pickups the icon, a small checkpoint appears to show him that he can't leave the place. And when he is done capturing, the checkpoint disappears or also when he leaves the checkpoint. Can someone help me upgrade this pawn code.
Reply
#2

Anyone? Need help.
Reply
#3

Well, there is only OnPlayerPickUpPickup and there isn't OnPlayerLeavePickup or something. I suggest you to create a timer (SetTimerEx), which checks how near are you from a position (starts when you pick up), if you are too far (let's say, 5 metres from it), we kill this timer and we say that a player left the checkpoint.
Reply
#4

use IsPlayerInRangeOfPoint(playerid,10.0,chkx,chky,chk z); to check that the player is in range or not
Reply
#5

Yes. Good ideas.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)