SA-MP Forums Archive
Checkpoint help - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Checkpoint help (/showthread.php?tid=96781)



Checkpoint help - Ov3rl0rd - 10.09.2009

While I was scripting a new GM, I came across an idea that involves checkpoints. Now my idea is that a attacking team is to capture a target(the checkpoint). When the attacking team enters the checkpoint, the now have the "target" and are suppose to take it to another checkpoint to end the round. Now I also want it to work so that if the player carrying the target is killed, the target drops at the players dead body. Any suggestions on the easiest and best way to do this? Because I have been messing with checkpoints for a while now and can't get it to work right.


Re: Checkpoint help - [HiC]TheKiller - 11.09.2009

This would be very simple if you gave it thought.

1. You set the checkpoint of the player.
2. When the player gets to the checkpoint it sets another one back at their base and sets a variable.
3. The player gets back to the base and wins
pawn Код:
new GotTarger[MAX_PLAYERS];

public OnPlayerEnterCheckpoint(playerid)
{
  if(GotTarget[playerid] == 1)
  {
    new pName[24], string[126];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    format(string, sizeof(string), "%s has delivered the target to the home base!", pName);
    SendClientMessageToAll(COLOUR, string);
    //SendRconCommand("gmx"); Include this if you want to reset the gm.
  }
  else
  {
    SetPlayerCheckpoint(/*...*/); // The base checkpoint
    GotTarget[playerid] = 1;
  }
  return 1;
}
pawn Код:
new Pickup1;
public OnPlayerDeath(playerid, killerid, reason)
{
  if(GotTarget[playerid] == 1)
  {
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    Pickup1 = CreatePickup(/*Find a model ID*/, 3, X, Y, Z, -1)
    GotTarget[playerid] = 0;
  }
  return 1;
}
pawn Код:
public OnPlayerPickUpPickup(playerid,pickupid)
{
  if(pickupid == Pickup1)
  {
    GotTarger[playerid] = 1;
    new pName[24], string[126];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    format(string, sizeof(string), "%s has picked up the target!", pName);
    SendClientMessageToAll(COLOUR, string);
    SetPlayerCheckpoint(/*base checkpoint*/);
  }
  return 1;
}



Re: Checkpoint help - Ov3rl0rd - 11.09.2009

Wow that works perfectly. Thanks for the help I cant believe I couldn't remember how to do checkpoints >.<


Re: Checkpoint help - Ov3rl0rd - 11.09.2009

Alright now that I have all the checkpoints working I have one major issue which I am assuming will only be fixed by defining the checkpoints individually and checking which checkpoint the player is in. Anyway the issue is this: I have it set so that when a player on one team enters a checkpoint, they have the target. But if they die, it drops the target where they died and sends a checkpoint to both teams saying they dropped the target. Now here is where all the problems begin. 1. if a player picks up the target from the checkpoint, another player still can, which its only suppose to allow 1 person to. And 2. if the second person picks up the target than the round automatically ends saying the player placed the target at the finish. So what are my options on fixing this?


Re: Checkpoint help - [HiC]TheKiller - 12.09.2009

Quote:
Originally Posted by Ov3rl0rd
Anyway the issue is this: I have it set so that when a player on one team enters a checkpoint, they have the target. But if they die, it drops the target where they died and sends a checkpoint to both teams saying they dropped the target.
Quote:
Originally Posted by [HiC
TheKiller ]
pawn Код:
new Pickup1;
public OnPlayerDeath(playerid, killerid, reason)
{
  if(GotTarget[playerid] == 1)
  {
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    Pickup1 = CreatePickup(/*Find a model ID*/, 3, X, Y, Z, -1)
    GotTarget[playerid] = 0;
  }
  return 1;
}
Just edit parts of this so it looks like this:
pawn Код:
new Pickup1;
public OnPlayerDeath(playerid, killerid, reason)
{
  if(GotTarget[playerid] == 1)
  {
    for(new i=0;i<GetMaxPlayers();i++)
    {
      new Float:X, Float:Y, Float:Z;
      GetPlayerPos(playerid, X, Y, Z);
      Pickup1 = CreatePickup(/*Find a model ID*/, 3, X, Y, Z, -1)
      GotTarget[playerid] = 0;
      SetPlayerCheckpoint(i, X, Y, Z, 3);
      new pName[24], string[126];
      GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
      format(string, sizeof(string), "%s has dropped the target! Get it before the other team does!", pName);
      SendClientMessageToAll(COLOUR, string);
    }
   
  }
  return 1;
}
Quote:
Originally Posted by Ov3rl0rd
here is where all the problems begin. 1. if a player picks up the target from the checkpoint, another player still can, which its only suppose to allow 1 person to. And 2. if the second person picks up the target than the round automatically ends saying the player placed the target at the finish. So what are my options on fixing this?
OK, there are 2 ways to fix this:

1.
pawn Код:
DestroyPickup(Pickup1);
This needs to go under OnPlayerPickUpPickup.

2. I'm not sure which ID it is, but change the pickup type.


Re: Checkpoint help - Ov3rl0rd - 12.09.2009

I had already set up my OnPlayerDeath like that, except for the CreatePickup. I get a warning for "number of arguments does not match definition" even though the arguments are this Pickup1 = CreatePickup(2914, 3, x, y, z, -1);