i want to save the players pos wen the player move and reconnect to te server
what is wrong?
//////////////////////////////////////////////////////////////////////////////////////////
function onScriptLoad()
{
LoadHashes();
}
function onScriptUnload()
{
SaveHashes();
CloseHashes();
}
function CreateHashes()
{
Pos<- HashTable( "Pos" );
}
function SaveHashes()
{
Pos.Save( "Accounts/Stats/Pos.hsh" );
}
function LoadHashes()
{
CreateHashes();
Pos.Load( "Accounts/Stats/Pos.hsh" );
}
function CloseHashes()
{
Pos.Close();
Pos<- null;
}
g_Positions <- array( GetMaxPlayers(), null ); // Storage for old positions
function HasPlayerMoved( v1, v2 )
{
return ( ( fabs( v1.x - v2.x ) > 0.1 ) || ( fabs( v1.y - v2.y ) > 0.1 ) || ( fabs( v1.z - v2.z ) > 0.1 ) );
}
function onPlayerUpdate( player )
{
local id = player.ID;
// Grab the current and old positions and store values for future reference
local oldpos = g_Positions[ id ];
local newpos = player.Pos;
g_Positions[ id ] = newpos;
// Do we have stored info about the previous position yet?
if ( !oldpos ) return 1;
if ( HasPlayerMoved( oldpos, newpos ) )
{
// Player has moved, trigger the event
onPlayerMove( player, oldpos, newpos );
}
return 1;
}
function onPlayerMove( player, oldpos, newpos )
{
local pos = pos.x, pos.y, pos.z;
Pos.Add( player.Name , pos );
Pos.Save( "Accounts/Stats/Pos.hsh" );
return 1;
}
function onPlayerSpawn( player, spawn )
{
Pos.Load( "Accounts/Stats/Pos.hsh" );
local newpos = Pos.Get( player.Name );
player.Pos = newpos;
return 1;
}
//////////////////////////
if someone can help me I appreciate
!