Liberty Unleashed

Scripting => Script Help => Topic started by: TALA on April 02, 2011, 07:51:08 pm

Title: I need help for two commands
Post by: TALA on April 02, 2011, 07:51:08 pm
Hello
In this server ---> 178.63.100.139:5190 have a two commads, which save and load your position
They are /saveloc and /gotoloc
With /saveloc you save your position and with /gotoloc you teleported to saved position
I needed this commands.Please give me the script of the commands or how to created ?

Sorry for my bad english :-\
Title: Re: I need help for two commands
Post by: matheo on April 02, 2011, 08:09:36 pm
Hi TALA!
You want create in your server a commands "/saveloc" and "/gotoloc"

Please read this:
http://forum.liberty-unleashed.co.uk/index.php?topic=391.0

If you download this script

Folder "LocationSaver" Please paste in folder Scripts

When you paste please come to folder LU->content.xml (in content please press right key mouse)

and add in the down
Quote
<script folder="LocationSaver" />


Save and Turn you server ;=]
Title: Re: I need help for two commands
Post by: TALA on April 02, 2011, 08:15:06 pm
You not understand me, i want command for save position in-game and with other command teleport to te saved position, join in the server and see the commands /saveloc and /gotoloc
Title: Re: I need help for two commands
Post by: D4RiFT on April 02, 2011, 11:15:06 pm
You not understand me, i want command for save position in-game and with other command teleport to te saved position, join in the server and see the commands /saveloc and /gotoloc
Yes, download that script., To add onplayjoin commands, simply, look on the wiki site and find the command to put on playerjoin. The location saver works, just have a good look on the wiki site to find the command to show on PLAYERJOIN.. thanks
Title: Re: I need help for two commands
Post by: Orpheus on April 03, 2011, 01:15:09 am
You would have to save the positions with a name, for either the position or the person who saved it, Personally I would use a hash table for this, if you look in FBS or on the wiki you can find some good examples of how to use hashes.
Then /saveloc would save something like the x,y,z,facing angle, and then getloc would load the same based on the name given to each

Regards Orpheus
Title: Re: I need help for two commands
Post by: TALA on April 03, 2011, 08:54:58 pm
Thanks all for help, but i'm not good scripter and that you told me not help me make a script commands.  :-\
Do you will make script ready for the commands ?

Sorry for bad english :-\
Title: Re: I need help for two commands
Post by: Thijn on April 04, 2011, 07:11:26 am
Sorry, But we're here to help not to deliver.
Try looking at the wiki located here (http://liberty-unleashed.co.uk/LUWiki/Main_Page)
If you get stuck we're happy to help ;)
Title: Re: I need help for two commands
Post by: TALA on April 04, 2011, 06:07:29 pm
The admin of the server give me the script of the commands, but still commands is not working
Here the script:

Code: [Select]
function LoadHashes()
{
   SavedLocs <- HashTable( "SavedLocs.hsh" );
   SavedLocs.Load( "SavedLocs.hsh" );
}

function onPlayerCommand( player, cmd, params )
{
   if ( cmd == "saveloc" )
   {
      if ( !params ) MessagePlayer( "[#04a36b]Syntax: /saveloc [Name]", player );
      else
      {
         local pos = player.Pos, formatize = format( "%.10f", pos.x ) + "," + format( "%.10f", pos.y ) + "," + format( "%.10f", pos.z ) + "," + format( "%.10f", player.Angle );
         SavedLocs.Add( params, formatize );
         SavedLocs.Save( "SavedLocs.hsh" );
         MessagePlayer( "[#04a36b]Your current position saved as " + params, player );
      }
   }
   else if ( cmd == "gotoloc" )
   {
      if ( !params ) MessagePlayer( "[#04a36b]Syntax: /gotoloc [Name]", player );
      else if ( !SavedLocs.Get( params ) ) MessagePlayer( "[#ff0000]Error - [#04a36b]Location does not exist.", player );
      else
      {
         local coords = SavedLocs.Get( params ), spl = split( coords, "," );
         local newpos = Vector( spl[ 0 ].tofloat(), spl[ 1 ].tofloat(), spl[ 2 ].tofloat() );
           
         player.Pos = newpos;
         player.Angle = spl[ 3 ].tofloat();
         MessagePlayer( "[#04a36b]Teleporting to location:[ " + params + "]", player );
      }
   }
}

Where is the miskate ?
Title: Re: I need help for two commands
Post by: Thijn on April 04, 2011, 06:56:18 pm
It looks ok, Are you sure you're loading this script?
Title: Re: I need help for two commands
Post by: TALA on April 04, 2011, 07:11:46 pm
Yea, i make new .nut file and it paste the script, i renamed file - SL.nut
Then i create a new Script.xml and paste this <script file="SL.nut" client="0"/>
And finally i open content.xml and paste this <script folder="SL" />

And the commands doesn't, but when i type /saveloc show this - Syntax: /saveloc [Name]
But when i type example: /saveloc axa nothing shows and the commands /gotoloc axa doesn't work
Title: Re: I need help for two commands
Post by: matheo on April 04, 2011, 08:10:03 pm
Maybe turn a uptades in server if no i see this script and edit ;)
Title: Re: I need help for two commands
Post by: TALA on April 04, 2011, 08:18:10 pm
I turn Updater.exe and again doesn't work the commands.I don't know what to do.
Here the text of the ScriptLog.log

Code: [Select]
<04/04/2011 - 18:15:26> - Pickup Handling Script Loaded
<04/04/2011 - 18:15:56>
AN ERROR HAS OCCURED [wrong number of parameters]

<04/04/2011 - 18:15:56>
CALLSTACK

<04/04/2011 - 18:15:56>
LOCALS

<04/04/2011 - 18:15:56>
AN ERROR HAS OCCURED [getVarInfo: Could not retrieve UserData]

<04/04/2011 - 18:15:56>
CALLSTACK

<04/04/2011 - 18:15:56> *FUNCTION [onPlayerCommand()] Scripts/SL/SL.nut line [15]

<04/04/2011 - 18:15:56>
LOCALS

<04/04/2011 - 18:15:56> [formatize] "98.9099960327,-951.1000366211,26.1599998474,8.1635065079"

<04/04/2011 - 18:15:56> [pos] INSTANCE

<04/04/2011 - 18:15:56> [params] "test"

<04/04/2011 - 18:15:56> [cmd] "saveloc"

<04/04/2011 - 18:15:56> [player] INSTANCE

<04/04/2011 - 18:15:56> [this] TABLE

<04/04/2011 - 18:16:02>
AN ERROR HAS OCCURED [wrong number of parameters]

<04/04/2011 - 18:16:02>
CALLSTACK

<04/04/2011 - 18:16:02>
LOCALS

<04/04/2011 - 18:16:02>
AN ERROR HAS OCCURED [getVarInfo: Could not retrieve UserData]

<04/04/2011 - 18:16:02>
CALLSTACK

<04/04/2011 - 18:16:02> *FUNCTION [onPlayerCommand()] Scripts/SL/SL.nut line [23]

<04/04/2011 - 18:16:02>
LOCALS

<04/04/2011 - 18:16:02> [params] "test"

<04/04/2011 - 18:16:02> [cmd] "gotoloc"

<04/04/2011 - 18:16:02> [player] INSTANCE

<04/04/2011 - 18:16:02> [this] TABLE

<04/04/2011 - 18:16:15> - Pickup Handling Script Unloaded
Title: Re: I need help for two commands
Post by: Tamas on April 04, 2011, 09:58:10 pm
There is nothing wrong with that script, you've messed up something I guess.
Title: Re: I need help for two commands
Post by: VRocker on April 05, 2011, 12:13:44 am
Are you calling LoadHashes? seems like your not so the SavedLocs pointer is invalid. Call LoadHashes when the script starts and it should work
Title: Re: I need help for two commands
Post by: TALA on April 05, 2011, 03:08:47 pm
So how to Call LoadHashes ?
Title: Re: I need help for two commands
Post by: Tamas on April 06, 2011, 03:22:49 pm
Quote
So how to Call LoadHashes ?

Code: [Select]
function onScriptLoad()
{
LoadHashes();
}
Title: Re: I need help for two commands
Post by: TALA on April 06, 2011, 08:11:33 pm
Thanks all, the commands work it ;)
Special Thanks to VRocker and Tamas :)