Getstats Problem

Started by wilber32, Dec 06, 2015, 03:56 PM

Previous topic - Next topic

wilber32

function GetStats( player )
{
      local stats = null;
           local Kills = stats[ player.ID ].Kills;
           local Deaths = stats[ player.ID ].Deaths;
           {
      if ( ( Kills < 0 ) && ( Deaths < 0 ) )
      {
          local ratio = format( "%.2f", Kills.tofloat() / Deaths.tofloat() );
          stats = "Kills: " + Kills + ", Deaths: " + Deaths + ", Ratio: " + ratio + ", Joins: " + Joins + ".";
      }
           else
      {
          stats = "Kills: " + Kills + ", Deaths: " + Deaths + ", Joins: " + Joins + ".";
      }
           }
      return stats;
      }

the index " 0 " not exist

KAKAN

I only expect that from you!
function GetStats( player )
{
      local stats = null;
           local Kills = stats[ player.ID ].Kills;
           local Deaths = stats[ player.ID ].Deaths;

      if ( ( Kills > 0 ) )
      {
          local ratio = format( "%.2f", Kills.tofloat() / Deaths.tofloat() );
          stats = "Kills: " + Kills + ", Deaths: " + Deaths + ", Ratio: " + ratio + ", Joins: " + Joins + ".";
      }
           else stats = "Kills: " + Kills + ", Deaths: " + Deaths + ", Joins: " + Joins + ".";
      return stats;
      }
Your next error: the index Joins doesn't exist, fix that yourself
oh no

wilber32


KAKAN

Quote from: wilber32 on Dec 06, 2015, 05:45 PMlol KAKAN
Why the f*ck are you saying it to me? You may say it to yourself.
Try that code and fix the Joins() error. I won't help you for that shit
oh no

wilber32

It is that I am new scripts

wilber32

look what I've done and still the error
  else if ( cmd == "stats" )
  {
    if ( !text ) Message( ">> " + player.Name + "'s Stats: " + GetStats( player ) );
    else
{
       local plr = GetPlayer( GetTok( text, " ", 1 ) );
if ( !plr ) MessagePlayer( "[Error] - Invalid Player Nick/ID!", player );
else MessagePlayer( plr.Name + "'s Stats: " + GetStats( player ), player );
}

}

functions

function ExecStats()
{
        local id, q;
    for(local i = 0; i < GetMaxPlayers(); i++)
    {
        local plr = FindPlayer( i ),q;
    if ( plr )
    {
id = plr.ID
    q = QuerySQL( db, "UPDATE Accounts SET Kills='" + status[ id ].Kills + "', Deaths='" + status[ id ].Deaths + "', Cash='" + status[ id ].Cash + "', Bank='" + status[ id ].Bank + "' , Joins='" + status[ id ].Joins + "' WHERE Name='" + plr.Name.tolower() + "'" );
FreeSQLQuery( q );
    }
}
}

function SaveStats( player )
{
       try{
   local id = player.ID;
           if ( status[ p.ID ].IsReg == true )
   {
       QuerySQL( db, "UPDATE Accounts SET Kills='" + status[ id ].Kills + "', Deaths='" + status[ player.ID ].Deaths + "', Cash='" + status[ id ].Cash + "', Bank='" + status[ id ].Bank + "', Joins='" + status[id].Joins + "' WHERE Name='" + player.Name.tolower() + "'" );
   print( "Saved Stats of Player " + player.Name + "[" + player.ID + "]" );
   status[ id ] = null;
   }
   }
   catch(e) print( "Save Stats Error: " + e );
}
function GetStats( player )
{
      local stats = null;
           local Kills = stats[ player.ID ].Kills;
           local Deaths = stats[ player.ID ].Deaths;

      if ( ( Kills > 0 ) )
      {
          local ratio = format( "%.2f", Kills.tofloat() / Deaths.tofloat() );
          stats = "Kills: " + Kills + ", Deaths: " + Deaths + ", Ratio: " + ratio + ", Joins: " + Joins + ".";
      }
           else stats = "Kills: " + Kills + ", Deaths: " + Deaths + ", Joins: " + Joins + ".";
      return stats;
      }


wilber32

I've already seen 3,000 times and nothing

KAKAN

Care to say what's the problem?
Do you have this actually:- stats[ player.ID ].Kills?
oh no

wilber32


MatheuS

try removing

local stats = null;
if( !sucess ) tryAgain();
Thanks to the VCMP community. It was the happiest period of my life.

Thijn

At one point you're doing status[ player.ID ], and another stats[ player.ID ]. Make up your damn mind.

wilber32

Because you know guionar not mean you badmouth the idiots.

Xmair


Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

KAKAN

Quote from: wilber32 on Dec 07, 2015, 12:55 AMBecause you know guionar not mean you badmouth the idiots.
Then we're not robots too. So we won't help you, simple as that.
HUMANS are not like ROBOTS!
oh no

wilber32

No more post it here -.-!