SA-MP Forums Archive
Mark and Recall - 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: Mark and Recall (/showthread.php?tid=127061)



Mark and Recall - Rhemsis - 11.02.2010

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;
}



Re: Mark and Recall - woot - 11.02.2010

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!");
}



Re: Mark and Recall - Grim_ - 11.02.2010

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..


Re: Mark and Recall - Rhemsis - 11.02.2010

@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


Re: Mark and Recall - Grim_ - 11.02.2010

Try making it a global variable instead.



Re: Mark and Recall - Streetplaya - 11.02.2010

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;
}



Re: Mark and Recall - Grim_ - 11.02.2010

Yeah.. like that.


Re: Mark and Recall - Rhemsis - 11.02.2010

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.


Re: Mark and Recall - Grim_ - 11.02.2010

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


Re: Mark and Recall - Rhemsis - 11.02.2010

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


Re: Mark and Recall - Grim_ - 11.02.2010

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


Re: Mark and Recall - Rhemsis - 12.02.2010

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.


Re: Mark and Recall - Daren_Jacobson - 12.02.2010

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.