Author Topic: Save Score  (Read 1713 times)

Dan97

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-1
    • View Profile
Save Score
« on: May 18, 2014, 02:07:27 am »
Well, I need a script to save score, but I can't make this, because I can't make a scritp for Hashes, who can help me?

Thijn

  • Tester
  • Sr. Member
  • ****
  • Posts: 531
  • Karma: +27/-16
    • View Profile
Re: Save Score
« Reply #1 on: May 18, 2014, 11:11:57 am »
Take a look in the Script releases board. There's a few scripts that can save score.

Dan97

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-1
    • View Profile
Re: Save Score
« Reply #2 on: May 23, 2014, 02:49:09 am »
Why this is crash my server? What is wrong?

function onScriptLoad()
{
        LoadHashes();
}
function onScriptUnload()
{
   SaveHashes();
   CloseHashes();
}
function CreateHashes()
{
   Kills<- HashTable( "Kills" );
   Deaths<- HashTable( "Deaths" );
}   
function SaveHashes()
{
        Kills.Save( "Hashes/Kills.hsh" );
        Deaths.Save( "Hashes/Deaths.hsh" );   
}
function LoadHashes()
{
        CreateHashes();
        Kills.Load( "Hashes/Kills.hsh" );
        Deaths.Load( "Hashes/Deaths.hsh" );
}
function CloseHashes()
{
   Kills.Close();
   Deaths.Close();
   Kills<- null;
   Deaths<- null;
}
function onPlayerConnect( pPlayer )
{   
        pPlayer.Score = Kills.Get( pPlayer );
}
function onPlayerKill( pKiller, pKilled, iWeapon, iBodyPart )
{
   /* Get the weapon name and the body part name, putting in an offset for its Unknown */
   local szWeapon = GetWeaponName( iWeapon ), szBodyPart = GetBodyPartName( iBodyPart );
   
   if ( szBodyPart == "Unknown" ) szBodyPart = "Body";
   
   Message( "[#0080ff]" + pKiller + " killed " + pKilled + " (" + szWeapon + ") (" + szBodyPart + ")", Colour( 255, 0, 0 ) );
   pKiller.Score += 1;
    Kills.Inc( pKiller, 1 );
    Deaths.Inc( pKilled, 1 );
}
« Last Edit: May 23, 2014, 02:51:39 am by Dan97 »

Merkel

  • Jr. Member
  • **
  • Posts: 89
  • Karma: +4/-10
    • View Profile
Re: Save Score
« Reply #3 on: May 23, 2014, 07:35:28 pm »
Why this is crash my server? What is wrong?

** code **

Try ...

Code: [Select]
Kills <- HashTable ( "Kills" );
Deaths <- HashTable ( "Deaths" );

function onScriptLoad ( ) {

Kills.Load ( "Hashes/Kills.hsh" );
Deaths.Load ( "Hashes/Deaths.hsh" );
}

function onScriptUnload ( ) {

Kills.Save ( "Hashes/Kills.hsh" );
Deaths.Save ( "Hashes/Deaths.hsh" );

Kills.Close ( );
Deaths.Close ( );

Kills <- null;
Deaths <- null;
}

function onPlayerConnect ( pPlayer ) {

pPlayer.Score = Kills.Get ( pPlayer );
}

function onPlayerKill ( Killer, Killed, Weapon, Part ) {

if ( Part == "Unknown" ) Part = "Body";

Message( "[#0080ff]" + Killer + " killed " + Killed + " (" + GetWeaponName ( Weapon ) + ") (" + GetBodyPartName ( Part ) + ")" );

pKiller.Score ++;

    Kills.Inc ( Killer, 1 );
    Deaths.Inc ( Killed, 1 );
}

offtopic -> i'm banned from the forum, for use the forum i need use Proxy's
« Last Edit: May 24, 2014, 11:21:35 am by Merkel »
Westwood Studios

The best studios company in strategy videogames.

Thijn

  • Tester
  • Sr. Member
  • ****
  • Posts: 531
  • Karma: +27/-16
    • View Profile
Re: Save Score
« Reply #4 on: May 23, 2014, 09:04:13 pm »
offtopic -> i'm banned from the forum, for use the forum i need use Proxy's
You are being caught in a subnet ban belonging to IMMORTAL. Who has been permanently banned for spreading all kinds of harmful files. Unfortunately we're not going to unban those subnets, so as long as you have the 88.1*.*.* subnet you need to find another way to access our forum.

Merkel

  • Jr. Member
  • **
  • Posts: 89
  • Karma: +4/-10
    • View Profile
Re: Save Score
« Reply #5 on: May 23, 2014, 09:11:40 pm »
offtopic -> i'm banned from the forum, for use the forum i need use Proxy's
You are being caught in a subnet ban belonging to IMMORTAL. Who has been permanently banned for spreading all kinds of harmful files. Unfortunately we're not going to unban those subnets, so as long as you have the 88.1*.*.* subnet you need to find another way to access our forum.

Oh, k.

(movistar and dynamic ip, some times i can use the forums, others times nope... [every day change])

p.s.: who is INMORTAL?
Westwood Studios

The best studios company in strategy videogames.

 

© Liberty Unleashed Team.