Liberty Unleashed
Scripting => Script Help => Topic started by: Nicholas(RU) on January 21, 2016, 09:57:13 pm
-
Hello.
I used this:
function onPlayerCommand( player, cmd, text )
{
if ( cmd == "pos" )
{
local pos = player.Pos; // Save the position vector to a local variable
MessagePlayer( "Your position: " + pos.x + ", " + pos.y + ", " + pos.z , player );
}
}
Describe the position to spawn, but when entering the server it is different.
What to do?
Thanks in advance, friends.
-
im at work at the moment....but i do see there is no hash table that adds and saves the position. I'll help out more later ;)
This only appears to tell the player his current position.
-
im at work at the moment....but i do see there is no hash table that adds and saves the position. I'll help out more later ;)
This only appears to tell the player his current position.
You're right, I know it. I write the
location to spawn, but when
entering the server, these
coordinates spawned me in a
completely different place. You
know? Here's the problem. Any
ideas?
-
Well first no clue on what you have server wise.
You need a hashtable
Some people use .xml for those type of pos idk why.. ???
-Stick with hashes,,..
Btw im not familiar with saving positions yet, So i could be false on anything but i am 99% sure i should be correct!
-First
I dont know if you have a login system..
If you do have a login system you will need a something like
Position.Get( player.Name );This should get the saved position if it does not work in the login part attemt to add to
function onPlayerSpawn That would definetly do the trick.
.Get will Get the players data in this case the position.
You should be some what okay on your CMD for saving positions
Unable to test
function onPlayerCommand( player, cmd, text )
{
if ( cmd == "pos" )
{
local pos = player.Pos;
Position.Add( player.Name , pos.x + "," + pos.y + "," + pos.z + "," );
Position.Save(LU/data/Position.hsh
MessagePlayer( "Your position was saved at: " + pos.x + ", " + pos.y + ", " + pos.z , player );
MessagePlayer( "You will spawn hear at your next login", player );
SaveHashes();
}
You may not need to create the hashtable idk but in case
function CreateHashes()
{
Positions <- HashTable( "Positions" );
}
I dont think you will need to call for a load on this hashtable due to your making a call to .Get the position when the player spawns.
But in case you should have something like
function LoadHashes()
{
// This is where we are going to be loading the hash files
// First we need to create them
CreateHashes();
// And then load them
Position.Load(LU/data/Positions.hsh" );
}
Like i said though i have not got into positions and this should have you 99% there. i actually plan on doing something like this on my server.
Some reason when i see others create this it never loads the pos,. usaly you have to type something like /loadpos i dont like that..
Please let me know how this goes :D
-
Thank you for such an extensive, concise and informative answer. I'm afraid that You misunderstood me. I don't need to maintain this position. I just need to know it is true. I used the template from the Wiki, when you type the command, I got your coordinates in the chat. When I used these coordinates in content.xml they on the server do not coincide with those where I got those same coordinates. I hope You understand me.
-
I'm sorry. The problem is solved. Topic can be closed. Thank you Motley for responsiveness.
-
I'm sorry. The problem is solved. Topic can be closed. Thank you Motley for responsiveness.
Closed as per the topic creator's request. If you need this opened again later, please shoot me a PM with a link to the topic and what you are requesting.