save and loadpos
#1

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;
  }
Reply
#2

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
Reply
#3

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...
Reply
#4

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
Reply
#5

Код:
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?
Reply
#6

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)