Mark and Recall
#1

I'm attempting to make two commands, /mark, and /recall.

/mark gets your current position and saves it.

/recall sets your position to the saved /mark location.

When I type /mark, everything seems to go fine, but upon /recall, I am teleported to the coordinates 0,0,0 which leads to an endless fall seeing as how 0,0,0 is underground.

The code is below, anyone know what I did wrong?

pawn Код:
if(strcmp(cmdtext, "/mark", true) == 0)
    if(PlayerAdminLevel[playerid] == 1337)
{
      new Float:p[3];
        GetPlayerPos(playerid,p[0],p[1],p[2]);
        new tempx[MAX_PLAYERS];
        new tempy[MAX_PLAYERS];
        new tempz[MAX_PLAYERS];
       
        p[0]=tempx[playerid];
        p[1]=tempy[playerid];
        p[2]=tempz[playerid];
       
        Markx[playerid]=tempx[playerid];
        Marky[playerid]=tempy[playerid];
        Markz[playerid]=tempz[playerid];
        SendClientMessage(playerid, COLOR_ERROR, "Tether Set!");
    return 1;
}

if(strcmp(cmdtext, "/recall", true) == 0)
    if(PlayerAdminLevel[playerid] == 1337)
{
        SetPlayerPos(playerid,Markx[playerid],Marky[playerid],Markz[playerid]);
        SendClientMessage(playerid, COLOR_ERROR, "Teleported to marker!");
       
    return 1;
}
Reply
#2

pawn Код:
if(strcmp(cmdtext, "/mark", true) == 0 && PlayerAdminLevel[playerid] == 1337)
{
    new Float:p[3];
    GetPlayerPos(playerid,p[0],p[1],p[2]);
    Markx[playerid] = p[0];
    Marky[playerid] = p[1];
    Markz[playerid] = p[2];
    return SendClientMessage(playerid, COLOR_ERROR, "Tether Set!");
}

if(strcmp(cmdtext, "/recall", true) == 0 && PlayerAdminLevel[playerid] == 1337)
{
    SetPlayerPos(playerid,Markx[playerid],Marky[playerid],Markz[playerid]);
    return SendClientMessage(playerid, COLOR_ERROR, "Teleported to marker!");
}
Reply
#3

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  new Float:Pos[MAX_PLAYERS][4];
  if(strcmp(cmdtext, "/mark", true) == 0)
  {
   GetPlayerPos(playerid, Pos[playerid][0], Pos[playerid][1], Pos[playerid][2]);
   GetPlayerFacingAngle(playerid, Pos[playerid][3]);
   SendClientMessage(playerid, 0x000000FF, "Position marked..");
   return 1;
  }
  if(strcmp(cmdtext, "/recall", true) == 0)
  {
   SetPlayerPos(playerid, Pos[playerid][0], Pos[playerid][1], Pos[playerid][2]);
   SetPlayerFacingAngle(playerid, Pos[playerid][3]);
   SendClientMessage(playerid, 0x000000FF, "Set back to your marked position..");
   return 1;
  }
  return 0;
}
Try this..
Reply
#4

@exora, I originally tried that, and it gives an error. I think you have to store the p[#] in a variable before it can be equivalent to something, thus the tempx,y,z.

@_Xeres_ It didn't work, I still find myself falling into the abyss of 0,0,0
Reply
#5

Try making it a global variable instead.
Reply
#6

pawn Код:
new Float:Pos[MAX_PLAYERS][4];
public OnPlayerCommandText(playerid, cmdtext[])
{
  if(strcmp(cmdtext, "/mark", true) == 0)
  {
   GetPlayerPos(playerid, Pos[playerid][0], Pos[playerid][1], Pos[playerid][2]);
   GetPlayerFacingAngle(playerid, Pos[playerid][3]);
   SendClientMessage(playerid, 0x000000FF, "Position marked..");
   return 1;
  }
  if(strcmp(cmdtext, "/recall", true) == 0)
  {
   SetPlayerPos(playerid, Pos[playerid][0], Pos[playerid][1], Pos[playerid][2]);
   SetPlayerFacingAngle(playerid, Pos[playerid][3]);
   SendClientMessage(playerid, 0x000000FF, "Set back to your marked position..");
   return 1;
  }
  return 0;
}
Reply
#7

Yeah.. like that.
Reply
#8

I was making the temps into global variables, when I realized; no matter whether they are local or global when I set p[]=variable, it rearranges p[]'s value to be the value of the variable, which is 0.

When I set my markx,y,z to = the p[] right off the bat it returns an error:

Warning 213: tag mismatch.

What I think we need is a way to store the p[] value to a global variable right off the bat without a tag mismatch.

I'll give the suggestion by MaVe` a try, and post back.
Reply
#9

MaVe's code is mine, he just made the variable global for you.
Reply
#10

Still falling into the abyss. I'm sure that this is possible but I am at a loss.
Reply
#11

My friend just tested it, said it worked. I don't know what to tell you.
Reply
#12

Hm, I'll keep playing with it, and if I see what went wrong on my end I'll post it here.

Thanks for all your help, I really appreciate it.
Reply
#13

well your first code was almost okay, way too many variables, but all you had wrong was
this
pawn Код:
new tempx[MAX_PLAYERS];
p[0]=tempx[playerid];
should be this
pawn Код:
new Float:tempx; // float variable, not MAX_PLAYERS big.
tempx=p[0]; // reversed order.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)