Liberty Unleashed

Scripting => Script Help => Topic started by: Merkel on September 02, 2013, 12:57:40 pm

Title: Save Pos.
Post by: Merkel on September 02, 2013, 12:57:40 pm
What is wrong ?

Code: [Select]
function InitStatsTimer( plr )
{
local pos = plr.Pos;
local health = plr.Health;
local armour = plr.Armour;
local FormatPos = format( pos.x + "," + pos.y + "," + pos.z );
local FormatWeapon = format( plr.Weapon + "," + plr.WeaponAmmo );

SetHealth( plr.Name, health );
SetArmour( plr.Name, armour );
SetWeapon( plr.Name, FormatWeapon );
SetPosition( plr.Name, FormatPos );

SaveStatHashes();
}

function ProcessPlayerStatsLog( plr )
{
plr.Health = GetHealth( plr.Name );
plr.Armour = GetArmour( plr.Name );
plr.SetWeapon( GetWeapon( plr.Name ) );
plr.Pos = Vector( GetPosition( plr.Name ) );
if ( !plr.Spawned ) plr.Spawn();
}

Say error in

Code: [Select]
plr.Pos = Vector( GetPosition( plr.Name ) );

Lol.
Title: Re: Save Pos.
Post by: sasha19323 on September 02, 2013, 03:02:33 pm
Show function "GetPosition" please
Title: Re: Save Pos.
Post by: Merkel on September 02, 2013, 03:43:43 pm
Code: [Select]
function GetPosition( name )
{
local pos = zPosition.Get( name.tolower() );
if ( pos != null )
return pos;
}
Title: Re: Save Pos.
Post by: sasha19323 on September 02, 2013, 03:45:32 pm
zPosition.Get() isn't LU function. What is it? Where did you get it?
Title: Re: Save Pos.
Post by: Mido_Pop on September 02, 2013, 04:12:53 pm
You Can Make This Function Easily By Hash. ;)
Title: Re: Save Pos.
Post by: Merkel on September 02, 2013, 04:40:06 pm
Code: [Select]
zPosition <- HashTable( "Position" );

function LoadStatHashes()
{
zPosition.Load( "Hashes/DSS/PlayerStats/Position.hsh" );
}

function SaveStatHashes()
{
zPosition.Save( "Hashes/DSS/PlayerStats/Position.hsh" );
}

function CloseStatHashes()
{
zPosition.Close();

zPosition <- null;
}

L0L
Title: Re: Save Pos.
Post by: sasha19323 on September 02, 2013, 05:34:35 pm
And last, show hash file  :D
Title: Re: Save Pos.
Post by: Mido_Pop on September 02, 2013, 05:57:17 pm
You Can Get The Idea From This >>
Code: [Select]
function onScriptLoad()
{
   LoadHashes();
}

function LoadHashes()
{
    Spawns <- HashTable( "Hashes/Spawns.hsh" );
    Spawns.Load( "Hashes/Spawns.hsh" );
}

function onPlayerSpawn( pPlayer, Spawned )
{
     Spawns.Inc( pPlayer.Name, 1 );
     Spawns.Save( "Hashes/Spawns.hsh" );
     if(Spawns.Get( pPlayer.Name ) != null) MessagePlayer( "Spawns: " + Spawns.Get( pPlayer.Name ), pPlayer, Colour( 0, 255, 0 ) );
     else MessagePlayer( "Spawns: 0", pPlayer, Colour( 0, 255, 0 ) );
}
Title: Re: Save Pos.
Post by: Thijn on September 03, 2013, 01:48:20 pm
All those code is not needed. You can tell the error from the first snippet he posed.

Vector needs 3 parameters: x, y and z. You're giving it a string contain "X Y Z". That wouldn't work that way.

Code: [Select]
local pos = GetPosition( plr.Name );
plr.Pos = Vector( GetTok(pos,", ",1).tofloat(), GetTok(pos,", ",2).tofloat(), GetTok(pos,", ",3).tofloat() );
Title: Re: Save Pos.
Post by: Merkel on September 03, 2013, 07:13:27 pm
Thank Thijn.
And, the pos is not save?
And, how I save the weapons?

Sorry by many questions xD
Title: Re: Save Pos.
Post by: Mido_Pop on September 03, 2013, 09:23:37 pm
Thank Thijn.
And, the pos is not save?
And, how I save the weapons?

Sorry by many questions xD
You Can Save The Weapons Like Pos But You Cant Save The All Weapons.