SA-MP Forums Archive
save and loadpos - 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: save and loadpos (/showthread.php?tid=188182)



save and loadpos - XxerykxX - 06.11.2010

Hey guys. I have a save and loadpos system. Savepos works perfectly but loadpos doesnt. It teleports player where it is, but if player is in vehicle the vehicle doesnt teleport with player. How do you fix it? This is my code:

Код:
	if(strcmp(cmdtext, "/s", true) == 0)
   {
	GetPlayerFacingAngle(playerid, Float:storea[playerid]);
    stored[playerid] = 0;
    storeint[playerid] = GetPlayerInterior(playerid);
    GetPlayerPos(playerid, Float:storex[playerid], Float:storey[playerid], Float:storez[playerid]);
    SendClientMessage(playerid, COLOR_LIGHTBLUE, "Twoja pozycja została zapisana. Aby ją wczytaćwpisz /l.");
    stored[playerid] = 1;
    return 1;
  }
  
  if(strcmp(cmdtext, "/l", true) == 0)
  {
    if(stored[playerid] == 1)
	{
      SetPlayerInterior(playerid, storeint[playerid]);
      SetPlayerPos(playerid, storex[playerid],storey[playerid],storez[playerid]);
      SetPlayerFacingAngle(playerid, storea[playerid]);
      SetCameraBehindPlayer(playerid);
      SendClientMessage(playerid, COLOR_LIGHTBLUE, "Wczytałeś swoją pozycję.");
    }
    else return SendClientMessage(playerid, COLOR_LIGHTBLUE, "Pierw musisz zapisać pozycje przez wpisywanie /s.");
    return 1;
  }



Re: save and loadpos - Mike_Peterson - 06.11.2010

SetPlayerPos will only set the players position, when the player is in a vehicle it will put the player out the vehicle then teleports him..
I recently made a /afk /back and /sl /ll system so i know this..
use a check if the player is in any vehicle and tele the vehicle position there then put the player in the vehicle


Re: save and loadpos - XxerykxX - 06.11.2010

I dunno how you do it :/ I check it on wiki didnt get it :/ The only thing i dont know is where should i write it in my command...


Re: save and loadpos - Mike_Peterson - 06.11.2010

Heres a copy and paste out of my command:
Код:
	if (strcmp("/gotopos", cmdtext, true, 10) == 0)
	{
	if(!stored[playerid]) return SendClientMessage(playerid,YELLOW,"[ERROR]Please /savepos first then /gotopos");
	{
	SendClientMessage(playerid,YELLOW,"You have teleported to your last saved position.");
	if(IsPlayerInAnyVehicle(playerid))
	{
	new vehid = GetPlayerVehicleID(playerid);
	SetVehiclePos(vehid,Xpos[playerid],Ypos[playerid],Zpos[playerid]);
	SetVehicleZAngle(vehid,Apos[playerid]);
	LinkVehicleToInterior(vehid,Interior[playerid]);
	return 1;
	}
	else
	{
	SetPlayerPos(playerid,Xpos[playerid],Ypos[playerid],Zpos[playerid]);
	SetPlayerFacingAngle(playerid,Apos[playerid]);
	SetPlayerInterior(playerid,Interior[playerid]);
	return 1;
	}
}
}
edit it to your variables


Re: save and loadpos - XxerykxX - 06.11.2010

Код:
if(strcmp(cmdtext, "/l", true) == 0)
  {
    if(stored[playerid] == 1)
	{
      if(IsPlayerInAnyVehicle(playerid))
      {
      new vehid = GetPlayerVehicleID(playerid);
      SetVehiclePos(vehid,storex[playerid],storey[playerid],storez[playerid]);
	  SetVehicleZAngle(vehid,storea[playerid]);
	  SetPlayerFacingAngle(playerid, storea[playerid]);
	  SetCameraBehindPlayer(playerid);
      }
      else
      {
      SetPlayerInterior(playerid, storeint[playerid]);
      SetPlayerPos(playerid, storex[playerid],storey[playerid],storez[playerid]);
      SetPlayerFacingAngle(playerid, storea[playerid]);
      SetCameraBehindPlayer(playerid);
      SendClientMessage(playerid, COLOR_LIGHTBLUE, "Wczytałeś swoją pozycję.");
      }
    }
    return 1;
  }
Thats my command it works, but, vehicle teleports with player in it but it changes it direction how do you fix it?


Re: save and loadpos - Mike_Peterson - 06.11.2010

try this
Код:
if(strcmp(cmdtext, "/l", true) == 0)
  {
    if(stored[playerid] == 1)
	{
      if(IsPlayerInAnyVehicle(playerid))
      {
      new vehid = GetPlayerVehicleID(playerid);
      SetVehiclePos(vehid,storex[playerid],storey[playerid],storez[playerid]);
	  SetVehicleZAngle(vehid,storea[playerid]);
	  SetCameraBehindPlayer(playerid);
      }
      else
      {
      SetPlayerInterior(playerid, storeint[playerid]);
      SetPlayerPos(playerid, storex[playerid],storey[playerid],storez[playerid]);
      SetPlayerFacingAngle(playerid, storea[playerid]);
      SetCameraBehindPlayer(playerid);
      SendClientMessage(playerid, COLOR_LIGHTBLUE, "Wczytałeś swoją pozycję.");
      }
    }
    return 1;
  }



Re: save and loadpos - XxerykxX - 06.11.2010

Doesnt work... Like im facing NORTH then i type /l and it like go on SOUTH-EAST...