Save position
#1

When I'm saving position with /s, some bug happends. When on-foot you save fine, and your angle is good, but when you save in a car you the angle just goes to random things. When I'm out of my vehicle, and do /l, it does exactly the same. But on-foot saving, and loading in a car or on-foot is fine.

Код:
  if (strcmp(cmdtext, "/s", true)==0)
  {
    GetPlayerPos(playerid, PosX[playerid], PosY[playerid], PosZ[playerid]);
    GetPlayerFacingAngle(playerid, PosA[playerid]);
		SendClientMessage(playerid, COLOR_BASIC, "Position saved! Go to this position with /l.");
    PosI[playerid] = (GetPlayerInterior(playerid));
    PlayerPlaySound(playerid, 1137  , 0.0, 0.0, 0.0);
		return 1;
  }

  if (strcmp(cmdtext, "/l", true)==0)
  {
    if (!floatsqroot(PosX[playerid]+PosY[playerid]+PosZ[playerid]))
    {
      return SendClientMessage(playerid, COLOR_RED, "Use /s first!");
		}
		else
		{
			if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
			{
	      SetVehiclePos(GetPlayerVehicleID(playerid), PosX[playerid], PosY[playerid], PosZ[playerid]);
	      SetVehicleZAngle(GetPlayerVehicleID(playerid), PosA[playerid]);
	      SetPlayerFacingAngle(playerid, PosA[playerid]);
	      SetCameraBehindPlayer(playerid);
	      LinkVehicleToInterior(GetPlayerVehicleID(playerid), PosI[playerid]);
	    }
	    else
	    {
				InCar[playerid] = false;
		    SetPlayerPos(playerid, PosX[playerid], PosY[playerid], PosZ[playerid]);
		    SetPlayerFacingAngle(playerid, PosA[playerid]);
				SetCameraBehindPlayer(playerid);
			}
			PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
			SetPlayerInterior(playerid, PosI[playerid]);
			SendClientMessage(playerid, COLOR_BASIC, "Saved position loaded.");
		}
		return 1;
  }
Why does this happen?
Reply
#2

Might wanna do, if(IsPlayerInAnyVehicle){ then https://sampwiki.blast.hk/wiki/GetVehiclePos
Reply
#3

Quote:
Originally Posted by mavtias
Might wanna do, if(IsPlayerInAnyVehicle){ then https://sampwiki.blast.hk/wiki/GetVehiclePos
Oh thx.. Fixed it.. Other prob now.. I want if somebody does /l you get 5 meters higher . Like z 5, but I dunno how to add in that code.. You maybe have an idea?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)