[FilterScript] [FS] Saving player position and loading it on the next login
#21

Quote:
Originally Posted by Cracker
doesnt work for me or it works but woutn save.
Made a corinanate file also but everytime il spawn in normal spawn not the place where i loged out
Made this cordinates:
Код:
PositionX=1565
PositionY=-2294
PositionZ=14
You'll need to check it you have teleport command in the OnPlayerSpawn other than the one I told you about.
Reply
#22

Ah, interesting to work with.
Greetz,
Machine.
Reply
#23

PLEASE reupload !
Reply
#24

Quote:
Originally Posted by revenngeR
what about if player is in a interior and the player exits?
well make it get players interior then save it with co ords then load it the same it would take about 20 to 30 seconds to add somthing that simple.
Reply
#25

Link is not working
Reply
#26

Please add a new link
Reply
#27

Wo , Great its working good for me
Reply
#28

very good for roleplay servers nice job
Reply
#29

Reupload please
Reply
#30

Quote:
Originally Posted by ruarai
Посмотреть сообщение
Yes, i have tested it and it is IMPOSSIBLE for you to know when a player is going to disconnect!
And i do know pawno, so stop saying i don't.
LOL sorry for bringing this thread up again but I found this so god damn funny! XD
What a n00b...
Reply
#31

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
Dini is just bad to use now since more advanced things are out; see if you can learn those. Give y_ini a shot!
I heard also Dof2 is not bad but I've never seen it. Anyway suggest y_ini
Reply
#32

IF this does work, it will only save the position for ID 0, and load other players position where ID 0 last logged off. trust me. Ive been there.
Reply
#33

wow 10/10!! topic old but me helping
Reply
#34

Kind of usefull
Reply
#35

And for saving and loading the interior, virtual world and the angle?

Quote:
Originally Posted by salehyassin
Посмотреть сообщение
This is a simple way to save player position after closing the game and loading it after the player gets back.

First include these files (It will be attached with the script)

Код:
#include <Dini>
#include <dudb>
and then copy this to the end of the script.

Код:
Player(playerid)
{
 new player[MAX_PLAYER_NAME];
 GetPlayerName(playerid, player, sizeof(player));
 return player;
}
Second declare these three variables as a global variables in the top of your script,

Код:
new Float:positionx;
new Float:positiony;
new Float:positionz;
Float for real numbers or decimal numbers.

Now we need to open a file on scriptfiles to save our coordinates, to do that put this code at the end of your script.

Код:
FileStats(playerid)
{
  new a[256]; format(a, sizeof(a), "%s.ini",udb_encode(Player(playerid)));
  return a;
}
This will open a file in scriptfiles with the player name.

Now we need to store these positions in the file, to do that type this under the above code.

Код:
SaveStats(playerid)
{
  dini_IntSet(FileStats(playerid), "PositionX", floatround(positionx));
  dini_IntSet(FileStats(playerid), "PositionY", floatround(positiony));
  dini_IntSet(FileStats(playerid), "PositionZ", floatround(positionz));
}
This will store positionx as PositionX = the x position of the player and so on.

Next is to load the positions from the file, to do that type under the above code,

Код:
LoadStats(playerid)
{
  positionx = dini_Int(FileStats(playerid), "PositionX");
  positiony = dini_Int(FileStats(playerid), "PositionY");
  positionz = dini_Int(FileStats(playerid), "PositionZ");
}
This will make the positions saved in the file equals to the positions the player will teleport to when he/she login.

Ok now we need to load the file when the player connect, so we type this under OnPlayerConnect

Код:
LoadStats(playerid);
Ofcourse we need to save the positions in the file when the player disconnect, so we type this under OnPlayerDisconnect

Код:
new Float:x;
new Float:y;
new Float:z;

GetPlayerPos(playerid,x,y,z);
positionx = x;
positiony = y;
positionz = z;
if (!dini_Exists(FileStats(playerid)))
{
	dini_Create(FileStats(playerid));
}

SaveStats(playerid);
variables x, y and z is the current player position when the command GetPlayerPos used, so we make the positions of the file equal the one of the player.

Now we need to set the player position when he/she enters so we copy this code under OnPlayerSpawn,

Код:
SetPlayerPos(playerid,positionx,positiony,positionz);
Finally we need to set the player position when he/she dies so we have to copy this code under OnPlayerDeath

Код:
SetPlayerPos(playerid,1182.7733,-1323.6193,13.5785);
positionx = 1182.7733;
positiony = -1323.6193;
positionz = 13.5785;
This will set the player to all saints los santos hospital, ofcourse you can change the position of the place where you want your player to spawn when he/she dies. If you don't put this code the player will keep spawning in the loaded positions in the file.

Ok Now the script will look like:

Код:
#include <Dini>
#include <dudb>

new Float:positionx;
new Float:positiony;
new Float:positionz;

public OnPlayerConnect(playerid)
{
	LoadStats(playerid);
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	new Float:x;
	new Float:y;
	new Float:z;

	GetPlayerPos(playerid,x,y,z);
	positionx = x;
	positiony = y;
	positionz = z;
	if (!dini_Exists(FileStats(playerid)))
	{
		dini_Create(FileStats(playerid));
	}

	SaveStats(playerid);
	return 1;
}

public OnPlayerSpawn(playerid)
{
	SetPlayerPos(playerid,positionx,positiony,positionz);
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	SetPlayerPos(playerid,1182.7733,-1323.6193,13.5785);
	positionx = 1182.7733;
	positiony = -1323.6193;
	positionz = 13.5785;
	return 1;
}

Player(playerid)
{
 new player[MAX_PLAYER_NAME];
 GetPlayerName(playerid, player, sizeof(player));
 return player;
}

FileStats(playerid)
{
  new a[256]; format(a, sizeof(a), "%s.ini",udb_encode(Player(playerid)));
  return a;
}

SaveStats(playerid)
{
  dini_IntSet(FileStats(playerid), "PositionX", floatround(positionx));
  dini_IntSet(FileStats(playerid), "PositionY", floatround(positiony));
  dini_IntSet(FileStats(playerid), "PositionZ", floatround(positionz));
}

LoadStats(playerid)
{
  positionx = dini_Int(FileStats(playerid), "PositionX");
  positiony = dini_Int(FileStats(playerid), "PositionY");
  positionz = dini_Int(FileStats(playerid), "PositionZ");
}
For those who need it for GF Edits, I included it with a full working pure gf Edit. I downloaded the origional gf edit and added my script to it, just run it and test it.

Here is the gf edit with full server included with my save position script.
Download From Here
http://discoveryweb.net/savepositiongf.zip

Here is the full working script with the included files.
Download From Here
http://discoveryweb.net/saveposition.zip

Tell me if you need any help or if the link is broken.

Saleh Yassin
Reply
#36

10 fucking years later..
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)