Author Topic: Save Pos.  (Read 1991 times)

Merkel

  • Jr. Member
  • **
  • Posts: 89
  • Karma: +4/-10
    • View Profile
Save Pos.
« on: September 02, 2013, 01: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.
Westwood Studios

The best studios company in strategy videogames.

sasha19323

  • Jr. Member
  • **
  • Posts: 99
  • Karma: +25/-24
    • View Profile
Re: Save Pos.
« Reply #1 on: September 02, 2013, 04:02:33 pm »
Show function "GetPosition" please

Merkel

  • Jr. Member
  • **
  • Posts: 89
  • Karma: +4/-10
    • View Profile
Re: Save Pos.
« Reply #2 on: September 02, 2013, 04:43:43 pm »
Code: [Select]
function GetPosition( name )
{
local pos = zPosition.Get( name.tolower() );
if ( pos != null )
return pos;
}
Westwood Studios

The best studios company in strategy videogames.

sasha19323

  • Jr. Member
  • **
  • Posts: 99
  • Karma: +25/-24
    • View Profile
Re: Save Pos.
« Reply #3 on: September 02, 2013, 04:45:32 pm »
zPosition.Get() isn't LU function. What is it? Where did you get it?

Mido_Pop

  • Full Member
  • ***
  • Posts: 168
  • Karma: +6/-20
  • The_Pops ( War )
    • View Profile
Re: Save Pos.
« Reply #4 on: September 02, 2013, 05:12:53 pm »
You Can Make This Function Easily By Hash. ;)



Merkel

  • Jr. Member
  • **
  • Posts: 89
  • Karma: +4/-10
    • View Profile
Re: Save Pos.
« Reply #5 on: September 02, 2013, 05: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
Westwood Studios

The best studios company in strategy videogames.

sasha19323

  • Jr. Member
  • **
  • Posts: 99
  • Karma: +25/-24
    • View Profile
Re: Save Pos.
« Reply #6 on: September 02, 2013, 06:34:35 pm »
And last, show hash file  :D

Mido_Pop

  • Full Member
  • ***
  • Posts: 168
  • Karma: +6/-20
  • The_Pops ( War )
    • View Profile
Re: Save Pos.
« Reply #7 on: September 02, 2013, 06: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 ) );
}



Thijn

  • Tester
  • Sr. Member
  • ****
  • Posts: 531
  • Karma: +27/-16
    • View Profile
Re: Save Pos.
« Reply #8 on: September 03, 2013, 02: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() );

Merkel

  • Jr. Member
  • **
  • Posts: 89
  • Karma: +4/-10
    • View Profile
Re: Save Pos.
« Reply #9 on: September 03, 2013, 08:13:27 pm »
Thank Thijn.
And, the pos is not save?
And, how I save the weapons?

Sorry by many questions xD
Westwood Studios

The best studios company in strategy videogames.

Mido_Pop

  • Full Member
  • ***
  • Posts: 168
  • Karma: +6/-20
  • The_Pops ( War )
    • View Profile
Re: Save Pos.
« Reply #10 on: September 03, 2013, 10: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.



 

© Liberty Unleashed Team.