Liberty Unleashed
Scripting => Script Help => Topic started 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 :-\
-
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
<script folder="LocationSaver" />
Save and Turn you server ;=]
-
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
-
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
-
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
-
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 :-\
-
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 ;)
-
The admin of the server give me the script of the commands, but still commands is not working
Here the script:
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 ?
-
It looks ok, Are you sure you're loading this script?
-
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
-
Maybe turn a uptades in server if no i see this script and edit ;)
-
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
<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
-
There is nothing wrong with that script, you've messed up something I guess.
-
Are you calling LoadHashes? seems like your not so the SavedLocs pointer is invalid. Call LoadHashes when the script starts and it should work
-
So how to Call LoadHashes ?
-
So how to Call LoadHashes ?
function onScriptLoad()
{
LoadHashes();
}
-
Thanks all, the commands work it ;)
Special Thanks to VRocker and Tamas :)