Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: wilber32 on Dec 06, 2015, 03:56 PM

Title: Getstats Problem
Post by: wilber32 on Dec 06, 2015, 03:56 PM
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
Title: Re: Getstats Problem
Post by: KAKAN on Dec 06, 2015, 05:43 PM
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
Title: Re: Getstats Problem
Post by: wilber32 on Dec 06, 2015, 05:45 PM
lol KAKAN
Title: Re: Getstats Problem
Post by: KAKAN on Dec 06, 2015, 05:46 PM
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
Title: Re: Getstats Problem
Post by: wilber32 on Dec 06, 2015, 05:49 PM
It is that I am new scripts
Title: Re: Getstats Problem
Post by: wilber32 on Dec 06, 2015, 05:51 PM
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;
      }

Title: Re: Getstats Problem
Post by: wilber32 on Dec 06, 2015, 05:52 PM
I've already seen 3,000 times and nothing
Title: Re: Getstats Problem
Post by: KAKAN on Dec 06, 2015, 06:08 PM
Care to say what's the problem?
Do you have this actually:- stats[ player.ID ].Kills?
Title: Re: Getstats Problem
Post by: wilber32 on Dec 06, 2015, 06:19 PM
yes
Title: Re: Getstats Problem
Post by: MatheuS on Dec 06, 2015, 06:32 PM
try removing

local stats = null;
Title: Re: Getstats Problem
Post by: Thijn on Dec 06, 2015, 10:01 PM
At one point you're doing status[ player.ID ], and another stats[ player.ID ]. Make up your damn mind.
Title: Re: Getstats Problem
Post by: wilber32 on Dec 07, 2015, 12:55 AM
Because you know guionar not mean you badmouth the idiots.
Title: Re: Getstats Problem
Post by: Xmair on Dec 07, 2015, 04:05 AM
What?
Title: Re: Getstats Problem
Post by: KAKAN on Dec 07, 2015, 08:32 AM
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!
Title: Re: Getstats Problem
Post by: wilber32 on Dec 07, 2015, 08:10 PM
No more post it here -.-!