Author Topic: Help with positions.  (Read 1711 times)

Nicholas(RU)

  • Newbie
  • *
  • Posts: 15
  • Karma: +1/-0
    • View Profile
Help with positions.
« on: January 21, 2016, 10:57:13 pm »
Hello.

I used this:

Code: [Select]
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.
« Last Edit: January 21, 2016, 11:00:30 pm by Nicholas(RU) »

Motley

  • Full Member
  • ***
  • Posts: 252
  • Karma: +32/-34
    • View Profile
Re: Help with positions.
« Reply #1 on: January 22, 2016, 01:12:47 am »
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.
« Last Edit: January 22, 2016, 04:18:16 am by Motley »

Nicholas(RU)

  • Newbie
  • *
  • Posts: 15
  • Karma: +1/-0
    • View Profile
Re: Help with positions.
« Reply #2 on: January 22, 2016, 05:41:32 am »
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?

Motley

  • Full Member
  • ***
  • Posts: 252
  • Karma: +32/-34
    • View Profile
Re: Help with positions.
« Reply #3 on: January 22, 2016, 09:06:30 am »
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

Code: [Select]
Position.Get( player.Name );This should get the saved position if it does not work in the login part attemt to add to

Code: [Select]
function onPlayerSpawn That would definetly do the trick.

Code: [Select]
.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

Code: [Select]
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

Code: [Select]
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
Code: [Select]
.Get the position when the player spawns.

But in case you should have something like

Code: [Select]
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
Code: [Select]
/loadpos i dont like that..

Please let me know how this goes  :D
« Last Edit: January 22, 2016, 09:10:53 am by Motley »

Nicholas(RU)

  • Newbie
  • *
  • Posts: 15
  • Karma: +1/-0
    • View Profile
Re: Help with positions.
« Reply #4 on: January 22, 2016, 10:02:35 pm »
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.

Nicholas(RU)

  • Newbie
  • *
  • Posts: 15
  • Karma: +1/-0
    • View Profile
Re: Help with positions.
« Reply #5 on: January 22, 2016, 10:24:07 pm »
I'm sorry. The problem is solved. Topic can be closed. Thank you Motley for responsiveness.

SugarD

  • Argonath RPG Dev/Manager
  • Tester
  • Sr. Member
  • ****
  • Posts: 820
  • Karma: +37/-75
  • STOP IN THE NAME OF THE COLESLAW!
    • View Profile
    • Clan Xperience
Re: Help with positions.
« Reply #6 on: May 03, 2016, 08:50:01 pm »
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.

 

© Liberty Unleashed Team.