cp problem
#1

hey guys ,

i have this in my script :

Код:
new cp1[MAX_PLAYERS];
new cp2[MAX_PLAYERS];



cp1[playerid] = SetPlayerCheckpoint(playerid, 1520.5525,-2604.5759,13.5469,3); 
cp2[playerid] = SetPlayerCheckpoint(playerid, 246.6656,65.0490,1003.6406,3);
i want just cp1 be active and cp2 be hidden,, when player enter cp1 ,cp2 will be shown and player pos be here : 246.4716,70.0103,1003.6406,357

and when player back and enter cp2 , cp2 must be hidden and player pos must be 1519.7589,-2597.4492,13.5469


please help and thnx
Reply
#2

pawn Код:
new cp1[MAX_PLAYERS];
new cp2[MAX_PLAYERS];

pawn Код:
// Somewhere in script (maybe in command ex. /setcheckpoint)
SetPlayerCheckpoint(playerid, 1520.5525,-2604.5759,13.5469,3);
cp1[playerid] = 1;

pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
   if(cp1[playerid] == 1)
   {
      DisablePlayerCheckpoint(playerid);
      SetPlayerCheckpoint(playerid, 246.6656,65.0490,1003.6406,3);
      SetPlayerPos(playerid, 246.4716,70.0103,1003.6406);
      cp2[playerid] = 1;
      cp1[playerid] = 0;
   }
   else if(cp2[playerid] == 1)
   {
     // Do something
   }
Reply
#3

thnx mate ill try it right now
Reply
#4

well, you could do some research you know..

pawn Код:
public OnPlayerConnect(playerid)
{
  [...]

  SetPlayerCheckpoint(playerid, 1520.5525,-2604.5759,13.5469,3);

  [...]
  return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
  DisablePlayerCheckpoint(playerid);

  if (PlayerToPoint(playerid, 5, 1520.5525,-2604.5759,13.5469))
  {
    SetPlayerPos(playerid, 246.4716,70.0103,1003.6406);
    SetPlayerCheckpoint(playerid, 246.6656,65.0490,1003.6406,3);
    return 1;
  }
  if (PlayerToPoint(playerid, 5, 246.6656,65.0490,1003.6406))
  {
    SetPlayerPos(playerid, 1519.7589,-2597.4492,13.5469);
    SetPlayerCheckpoint(playerid, 246.6656,65.0490,1003.6406,3);
    return 1;
  }
 
  return 1;
}
Reply
#5

This code will not work. This is just an example. You have to close the { } under OnPlayerEnterCheckPoint and you have to make something to set the first checkpoint maybe a command or public function.
Reply
#6

Hey use this Include n' create this:

zueras-server.110mb.com/cpstream.zip (copy and paste in Url).


#include <cpstream>

new CP_1;
new CP_2;

//OnGameModeInit

CP_1 = CPS_AddCheckpoint(playerid,1520.5525,-2604.5759,13.5469,3.0,20);
CP_2 = CPS_AddCheckpoint(playerid,246.6656,65.0490,1003.6 406,3.0,20);

//40 is the distance that the player sees the checkpoint on radar (use the "01" does not appear that the).

public OnPlayerEnterCheckpoint(playerid)
{
cp = CPS_GetPlayerCheckpoint(playerid);
if(cp == CP_1)
{
//Function
}

if(cp == CP_2)
{
//Function
}

return 1;
}


Reply
#7

Quote:
Originally Posted by Lucas Giovanni
Hey use this Include n' create this:

zueras-server.110mb.com/cpstream.zip (copy and paste in Url).


#include <cpstream>

new CP_1;
new CP_2;

//OnGameModeInit

CP_1 = CPS_AddCheckpoint(playerid,1520.5525,-2604.5759,13.5469,3.0,20);
CP_2 = CPS_AddCheckpoint(playerid,246.6656,65.0490,1003.6 406,3.0,20);

//40 is the distance that the player sees the checkpoint on radar (use the "01" does not appear that the).

public OnPlayerEnterCheckpoint(playerid)
{
cp = CPS_GetPlayerCheckpoint(playerid);
if(cp == CP_1)
{
//Function
}

if(cp == CP_2)
{
//Function
}

return 1;
}


Not function but action xD
Reply
#8


Ok Choice of these functions lol
Reply
#9

dujma when i enter cp1 it be hidden and cp2 be shown , but when i enter cp2 , cp1 be hidden and cp2 not , and i wanted when i enter cp2 , cp2 be hidden and cp1 back
Reply
#10

Quote:
Originally Posted by [D1zZy_vortex
]
hey guys ,

i have this in my script :

Код:
new cp1[MAX_PLAYERS];
new cp2[MAX_PLAYERS];



cp1[playerid] = SetPlayerCheckpoint(playerid, 1520.5525,-2604.5759,13.5469,3); 
cp2[playerid] = SetPlayerCheckpoint(playerid, 246.6656,65.0490,1003.6406,3);
i want just cp1 be active and cp2 be hidden,, when player enter cp1 ,cp2 will be shown and player pos be here : 246.4716,70.0103,1003.6406,357

and when player back and enter cp2 , cp2 must be hidden and player pos must be 1519.7589,-2597.4492,13.5469


please help and thnx
Well, the first thing someone should have said, is that SetPlayerCheckpoint does not ever return a value. So, you're basically just doing this:

pawn Код:
cp1 = 0;
cp2 = 0;
You only need one variable. Set it to true when they've entered the checkpoint, set it to false when they leave:

pawn Код:
new cp[MAX_PLAYERS];

public OnPlayerSpawn(playerid)
{
  SetPlayerCheckpoint(playerid, 1520.5525,-2604.5759,13.5469,3);
  cp[playerid] = 0;
  return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
  if (cp[playerid])
  {
    cp[playerid] = 0;
    SetPlayerPos(playerid, 1519.7589,-2597.4492,13.5469);
    SetPlayerCheckpoint(playerid, 1520.5525,-2604.5759,13.5469,3);
    SendClientMessage(playerid, 0xFFFFFFFF, "Teleported!");
  }
  else
  {
    cp[playerid] = 1;
    SetPlayerPos(playerid, 246.4716,70.0103,1003.6406);
    SetPlayerCheckpoint(playerid, 246.6656,65.0490,1003.6406,3);
    SendClientMessage(playerid, 0xFFFFFFFF, "Teleported!");
  }
  return 1;
}
Tested it, and it looks like you mean to use an interior, too, seeing as I fell through the sky But, the correct checkpoint was there, and you get teleported to the right place.

Just add the interior like so:

pawn Код:
SetPlayerInterior(playerid, 5); // change the 5 to the correct interior id
And when they exit:

pawn Код:
SetPlayerInterior(playerid, 0);
EDIT: Oh, and don't use MAX_PLAYERS if you can help it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)