Saving Clan kills/Deaths in array

Started by Cool, Mar 09, 2017, 06:00 AM

Previous topic - Next topic

Cool

class PlayerClass
ClanKills = 0;
ClanDeaths = 0;
ClanDeads = 0;
Array
pstats <- array( GetMaxPlayers(), null );OnPlayerKill
function onPlayerKill( player, killer, reason, bodypart )
{
local KClan = GetTag( killer.Name ), DClan = GetTag( player.Name );

      if ( killer && player )
      {
                 if ( KClan && IsClanRegister( KClan ).tolower() ) { pstats[ KClan ].ClanKills++; }

                 if ( DClan && IsClanRegister( DClan ).tolower() ) { pstats[ DClan ].ClanDeaths++; }
      }         
}
savestats
function SaveClanStats( player )
{
local id = player.ID;
  local Clan = GetTag( player.Name );
  if ( Clan && IsClanRegister ) {
       
mysql_query( sDB, "UPDATE ClanStats SET Kills='" + pstats[ id ].ClanKills + "', Deaths='" + pstats[ id ].ClanDeaths + "' WHERE lower(Clan) = '" + Clan.tolower() + "'");
   print(mysql_error(sDB));

   print( "Saved Stats of Player" );
}
}

But its giving Error that the clan does not exists while its exists

Xmair

Show us the KClan and IsClanRegister functions.

Credits to Boystang!

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

Cool

@Xmair Kclan and Dclan is already defined as local KClan = GetTag( killer.Name ), DClan = GetTag( player.Name );isclanregister
function IsClanRegister( clan )
{
        local q = ::SafeSelect( sDB, "SELECT Clan FROM ClanStats WHERE Clan='" + clan + "'" );
if( mysql_num_rows( q ) == 1 )
{
local result = mysql_fetch_assoc( q );
local Clan = result[ "Clan" ];
        local Reg = Clan;
        return (Reg) ? Reg : null;
mysql_free_result( q );
}
}