Spawn on last pos
#1

hello im trying to make it so people spanw on there last pos
the codes are:

Код:
public OnPlayerSpawn(playerid)
{
  new string[256];
  SetPlayerInterior(playerid,PlayerAccount[playerid][pPlayerINT]);
  SetPlayerPos(playerid,PlayerAccount[playerid][pPlayerX],PlayerAccount[playerid][pPlayerY],PlayerAccount[playerid][pPlayerZ]);
  SetPlayerFacingAngle(playerid,PlayerAccount[playerid][pPlayerA]);
  format(string, sizeof(string), "~w~Position~n~Loaded");
  GameTextForPlayer(playerid, string, 5000, 3);
}
public OnPlayerDisconnect(playerid, reason)
{
  new Float:x,Float:y,Float:z;
	new Float:a;
	new Int = GetPlayerInterior(playerid);
	GetPlayerPos(playerid,x,y,z);
	GetPlayerFacingAngle(playerid,a);
	PlayerAccount[playerid][pPlayerX] = x;
	PlayerAccount[playerid][pPlayerY] = y;
	PlayerAccount[playerid][pPlayerZ] = z;
	PlayerAccount[playerid][pPlayerA] = a;
	PlayerAccount[playerid][pPlayerINT] = Int;
	return 1;
}
but they crash when they spawn

why?
Reply
#2

You need to save the last location info into a file and then load it.
And It crashes, because the parameters in
pawn Код:
SetPlayerPos(playerid,PlayerAccount[playerid][pPlayerX],PlayerAccount[playerid][pPlayerY],PlayerAccount[playerid][pPlayerZ]);
are blank
Reply
#3

Quote:
Originally Posted by dice7
You need to save the last location info into a file and then load it.
And It crashes, because the parameters in
pawn Код:
SetPlayerPos(playerid,PlayerAccount[playerid][pPlayerX],PlayerAccount[playerid][pPlayerY],PlayerAccount[playerid][pPlayerZ]);
are blank
I was going to say, are these the only bits of code you have in these sections? You'll need to have it so that users who haven't visited before are given a default spawn point.
Reply
#4

yeah on there first spawn its ok it works they are given a defolt spawn its when they login second time, and ys its saving to a file
Reply
#5

any one..
Reply
#6

I have the Exact same problem can any1 help?
Reply
#7

I am also trying to implement something like this, anyone??
Reply
#8

I got same problem with postion save.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)