I need your help

Started by Kelvinvenema, Dec 20, 2019, 09:19 PM

Previous topic - Next topic

Kelvinvenema

Hello guys, can some help me with getting custom stats that I can give the player?
I would like to have a points system, so that I can give players the necessary points, to activate a specific command.
For example, we will work with the Player.Stats.EmergencyPoints, if player.stats.EmergencyPoints <=10) MessagePlayer("you can't use this command",player);
With that way, I can add custom Stats that can only be activated by specific scores.
I don't know how to great that sort of thing, anyway thanks for reading hopefully someone can help me.

umar4911

To add things like custom stats, use Class system.

https://forum.vc-mp.org/?topic=5348
RT Member | Asian City Scripter | CTB Contributor | VKs Contributor | European City Contributor | EAD Scripter

Kelvinvenema

Quote from: umar4911 on Dec 21, 2019, 05:23 AMTo add things like custom stats, use Class system.

https://forum.vc-mp.org/?topic=5348

I will give it a look it looks pretty hardcoded to add new stats but anyway thanks for your reply.

NicusorN5

Quote from: umar4911 on Dec 21, 2019, 05:23 AMuse Class system.
The classes in object oriented programming are not 'systems' , they are actually a type of data.

Kelvinvenema

I tried
Quote from: Athanatos on Dec 21, 2019, 08:30 AM
Quote from: umar4911 on Dec 21, 2019, 05:23 AMuse Class system.
The classes in object oriented programming are not 'systems' , they are actually a type of data.

 I tried to add a new stats.

class PlayerStats
{
 kills = 0;
 headshots = 0;
 deaths = 0;
 rank = 0;
 emergencypoints = 0;

function onPlayerJoin( player )
{
StatsInfo(player);
}


function onPlayerDeath( player, reason )
{
switch (reason)
 {
        case 44:
        {
            Message(player.Name + " [#01403E] fell down and died.");
            break;
        }
        case 41:
        {
            Message(player.Name + " [#7D0804] exploded to bits!");
            break;
        }
        case 43:
        {
            Message(player.Name + " [#090362] drowned to death.");
            break;
        }
        case 39:
        {
            Message(player.Name + " [#23235f] died in a car accident.");
            break;
        }
        case 70:
        {
            Message(player.Name + " [#9954c3] suicided.");
            break;
        }
    }
{
  local pdeath = stats[player.ID].deaths + 1;
  QuerySQL(stats, "UPDATE pstats SET Deaths = '" + pdeath + "' WHERE Name = '" + player.Name + "'");
  rankcheck(player);
}



function onPlayerKill( player, killer, reason, bodypart )
{
rankcheck(killer);
rankcheck(player);

 if(bodypart == 6)
 {
  MessagePlayer("[#FFFFFF]You received $1000 bonus for killing through headshot", killer);
  local pkill = stats[player.ID].kills + 1;
  local phead = stats[player.ID].headshots + 1;
  QuerySQL(stats, "UPDATE pstats SET Kills = '" + pkill + "' WHERE Name = '" + killer.Name + "'");
  QuerySQL(stats, "UPDATE pstats SET Headshots = '" + phead + "' WHERE Name = '" + killer.Name + "'");
  local pdeath = stats[player.ID].deaths + 1;
  QuerySQL(stats, "UPDATE pstats SET Deaths = '"+pdeath+"' WHERE Name = '"+player.Name+"'");

 }
 else
 {
  local q2 = QuerySQL(stats, "SELECT * FROM pstats WHERE Name = '" + killer.Name + "'");
  local pkill = GetSQLColumnData(q2, 2).tointeger() + 1;
  QuerySQL(stats, "UPDATE pstats SET Kills = '" + pkill + "' WHERE Name = '" + killer.Name + "'");
  local q3 = QuerySQL(stats, "SELECT * FROM pstats WHERE Name = '" + player.Name + "'");
  local pdeath = GetSQLColumnData(q3, 2).tointeger() + 1;
  QuerySQL(stats, "UPDATE pstats SET Deaths = '"+pdeath+"' WHERE Name = '"+player.Name+"'");
 }
 
}



function onPlayerCommand(player, command, arguments)
{
local cmd, text;
cmd = command.tolower();
text = arguments;
 if(cmd == "stats")
 {
  if(!arguments)
  {
   MessagePlayer("[#FF0000]Information:[#FFFFFF] Your stats : ", player);
   MessagePlayer("[#FFFFFF]Kills : " + stats[player.ID].kills + " Headshots : " + stats[player.ID].headshots + " Deaths : " + stats[player.ID].deaths + " Rank : " + stats[player.ID].rank + "emergencypoints : " + stats[player.ID].emergencypoints + ".", player);
  }
  else
  {
   local plr = FindPlayer(arguments);
   if(!plr) MessagePlayer("[#FF0000]Usage Error:[#FFFFFF] Unknown Player", player);
   else
   {
    local q = QuerySQL(stats, "SELECT * FROM pstats WHERE Name = '" + plr.Name + "'");
    MessagePlayer("[#FF0000]Information:[#FFFFFF] "+plr.Name+ " stats : ", player);
    MessagePlayer("[#FFFFFF]Kills : " + stats[player.ID].kills + " Headshots : " + stats[player.ID].headshots + " Deaths : " + stats[player.ID].deaths + " Rank : " + stats[player.ID].rank + "emergencypoints : " + stats[player.ID].emergencypoints + ".", player);
   }
  }
 }

 
   else if(cmd == "resetstats")
 {
  if(!arguments) MessagePlayer("[#FF0000]Command Error:[#FFFFFF] Use /" + cmd + " [player] ", player);
  else
  {
   local plr = FindPlayer(arguments);
   if(!plr) MessagePlayer("[#FF0000]Usage Error:[#FFFFFF] Invalid player", player);
   else
   {   
    Message("[#514FFF]Administrator Command:[#FFFFFF] Admin[" + player.Name + "] reseted stats of player : " + plr.Name+ ".");
    MessagePlayer("[#FF0000]Information:[#FFFFFF] Your stats have been reseted by Admin " + player.Name + ".", plr);
    QuerySQL(stats, "UPDATE pstats SET Rank = '1', Kills = '0', Deaths = '0', Headshots = '0' Emergencypoints= '0' WHERE Name = '" + plr.Name + "'");
 stats[plr.ID].kills = 0;
stats[plr.ID].deaths = 0;
stats[plr.ID].headshots = 0;
stats[plr.ID].rank = 1;
stats[plr.ID].emergencypoints = 0;
   }
  }
 }
 
 

 
 else if(cmd == "setstats")
 {
  if(!arguments)
  {
   MessagePlayer("[#FF0000]Command Error:[#FFFFFF] Use /" + cmd + " [player] [stats(0 - 3)] [value]", player);
   MessagePlayer("0 = Rank, 1 = Kills, 2 = Headshots, 3 = Deaths, 4 = Emergencypoints", player);
  }
  else if(NumTok(arguments, " ") < 3 )
  {
   MessagePlayer("[#FF0000]Command Error:[#FFFFFF] Use /" + cmd + " [player] [stats(0 - 4)] [value]", player);
   MessagePlayer("0 = Rank, 1 = Kills, 2 = Headshots, 3 = Deaths, 4 = Emergencypoints", player);
  }
  else if(!IsNum(GetTok(arguments, " ", 2))) MessagePlayer("[#FF0000]Usage Error:[#FFFFFF] Stats should be between 0 - 4", player);
  else if(!IsNum(GetTok(arguments, " ", 3))) MessagePlayer("[#FF0000]Usage Error:[#FFFFFF] value should be in numbers", player);
  else if(GetTok(arguments, " ", 2).tointeger() < 0 ) MessagePlayer("[#FF0000]Usage Error:[#FFFFFF] Stats should be between 0 - 4", player);
  else if(GetTok(arguments, " ", 2).tointeger() > 4 ) MessagePlayer("[#FF0000]Usage Error:[#FFFFFF] Stats should be between 0 - 4", player);
  else if(GetTok(arguments, " ", 3).tointeger() < 0 ) MessagePlayer("[#FF0000]Usage Error:[#FFFFFF] Minimum value is 0", player);
  else
  {
   local plr = FindPlayer(GetTok(arguments, " ", 1));
   local stat = GetTok(arguments, " ", 2).tointeger();
   local val = GetTok(arguments, " ", 3).tointeger();
   if(!plr) MessagePlayer("[#FF0000]Usage Error:[#FFFFFF] Invalid player", player);
   else
   {
    if(stat == 0)
    {
     if(val < 1) MessagePlayer("[#FF0000]Usage Error:[#FFFFFF] Rank cannot be less than 1", player);
     else QuerySQL(stats, "UPDATE pstats SET Rank = '" + val + "' WHERE Name = '" + plr.Name + "'");
  stats[plr.ID].rank = val;
     Message("[#514FFF]Developer Command:[#FFFFFF] Developer[" + player.Name + "] set Player : " + plr.Name +"'s Rank to " + val + ".");
    }
    else if(stat == 1)
    {
     QuerySQL(stats, "UPDATE pstats SET Kills = '" + val + "' WHERE Name = '" + plr.Name + "'");
     Message("[#514FFF]Developer Command:[#FFFFFF] Developer[" + player.Name + "]set Player : " + plr.Name + "'s Kills to " + val + ".");
     stats[plr.ID].kills = val;
    }
    else if(stat == 2)
    {
     QuerySQL(stats, "UPDATE pstats SET HeadShots = '" + val + "' WHERE Name = '" + plr.Name + "'");
     Message("[#514FFF]Developer Command:[#FFFFFF] Developer[" + player.Name + "] set Player : " + plr.Name+ "'s HeadShots to " + val + ".");
     stats[plr.ID].headshots = val;
    }
    else if(stat == 3)
    {
     QuerySQL(stats, "UPDATE pstats SET Deaths = '" + val + "' WHERE Name = '" + plr.Name + "'");
     Message("[#514FFF]Developer Command:[#FFFFFF] Developer[" + player.Name + "] set Player : " + plr.Name+ "'s Deaths to " + val + ".");
     stats[plr.ID].deaths = val;
   }
    else if(stat == 4)
    {
     QuerySQL(stats, "UPDATE pstats SET Emergencypoints = '" + val + "' WHERE Name = '" + plr.Name + "'");
     Message("[#514FFF]Developer Command:[#FFFFFF] Developer[" + player.Name + "] set Player : " + plr.Name+ "'s Emergencypoints to " + val + ".");
     stats[plr.ID].emergencypoints = val;
    }
   }
  }
 }
}


function rankcheck(player)
{
 local q2 = QuerySQL(stats, "SELECT * FROM pstats WHERE Name = '" + player.Name+ "'");
 local ran = GetSQLColumnData(q2, 1).tointeger();
 
 local kills = GetSQLColumnData(q2, 2).tointeger();

 if(kills >= 5000 && ran < 8)
 {
  QuerySQL(stats, "UPDATE pstats SET Rank = '8' WHERE Name = '" + player.Name + "'");
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You have completed 5000 kills. Now your rank is 8", player);
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You received 000 cash", player);
 }
 
 else if(kills >= 4000 && ran < 7 && kills < 5000)
 {
  QuerySQL(stats, "UPDATE pstats SET Rank = '7' WHERE Name = '" + player.Name + "'");
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You have completed 4000 kills. Now your rank is 8", player);
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You received 000 cash", player);
 }

 else if(kills >= 3000 && ran < 6 && kills < 4000)
 {
  QuerySQL(stats, "UPDATE pstats SET Rank = '6' WHERE Name = '" + player.Name + "'");
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You have completed 3000 kills. Now your rank is 8", player);
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You received 000 cash", player);
 }

 else if(kills >= 2000 && ran < 5 && kills < 3000)
 {
  QuerySQL(stats, "UPDATE pstats SET Rank = '5' WHERE Name = '" + player.Name + "'");
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You have completed 2000 kills. Now your rank is 8", player);
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You received 000 cash", player);
 }

 else if(kills >= 1000 && ran < 4 && kills < 2000)
 {
  QuerySQL(stats, "UPDATE pstats SET Rank = '4' WHERE Name = '" + player.Name + "'");
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You have completed 1000 kills. Now your rank is 8", player);
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You received 000 cash", player);
 }

 else if(kills >= 500 && ran < 3 && kills < 1000)
 {
  QuerySQL(stats, "UPDATE pstats SET Rank = '3' WHERE Name = '" + player.Name + "'");
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You have completed 500 kills. Now your rank is 8", player);
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You received 000 cash", player);
 }

 else if(kills >= 100 && ran < 2 && kills < 500)
 {
  QuerySQL(stats, "UPDATE pstats SET Rank = '2' WHERE Name = '" + player.Name + "'");
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You have completed 100 kills. Now your rank is 8", player);
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You received 000 cash", player);
 }
 
}
function StatsInfo(player)
{
 local q = QuerySQL(stats, "SELECT * FROM pstats WHERE Name = '"+player.Name+"'");
 if(!q) QuerySQL(stats, "INSERT INTO pstats ( Name, Rank, Kills, Headshots, Deaths, Emergencypoints ) VALUES ( '" + escapeSQLString(player.Name) + "', '1', '0', '0', '0' '0' )");
 else
 {
 stats[player.ID].kills = GetSQLColumnData(q, 2).tointeger();
 stats[player.ID].headshots = GetSQLColumnData(q, 3).tointeger();
 stats[player.ID].deaths = GetSQLColumnData(q, 4).tointeger();
 stats[player.ID].rank = GetSQLColumnData(q, 1).tointeger();
 stats[player.ID].emergencypoints = GetSQLColumnData(q, 1).tointeger();
 
 }
 }

function GetTok(string, separator, n, ...)
{
local m = vargv.len() > 0 ? vargv[0] : n,
tokenized = split(string, separator),
text = "";
if (n > tokenized.len() || n < 1) return null;
for (; n <= m; n++)
{
text += text == "" ? tokenized[n-1] : separator + tokenized[n-1];
}
return text;
}

function NumTok(string, separator)
{
local tokenized = split(string, separator);
return tokenized.len();
}

function GetPlayer( plr )
{
if ( plr )
{
if ( IsNum( plr ) )
{
plr = FindPlayer( plr.tointeger() );
if ( plr ) return plr;
else return false;
}
else
{
plr = FindPlayer( plr );
if ( plr ) return plr;
else return false;
}
}
else return false;
}


I am running into some issues could you help me

D4rkR420R

[noae]
Quote from: Kelvinvenema on Dec 21, 2019, 09:11 AMI tried[noae]
Quote from: Athanatos on Dec 21, 2019, 08:30 AM[noae]
Quote from: umar4911 on Dec 21, 2019, 05:23 AMuse Class system.
[/noae]
The classes in object oriented programming are not 'systems' , they are actually a type of data.
[/noae]

 I tried to add a new stats.

class PlayerStats
{
 kills = 0;
 headshots = 0;
 deaths = 0;
 rank = 0;
 emergencypoints = 0;

function onPlayerJoin( player )
{
StatsInfo(player);
}


function onPlayerDeath( player, reason )
{
switch (reason)
 {
        case 44:
        {
            Message(player.Name + " [#01403E] fell down and died.");
            break;
        }
        case 41:
        {
            Message(player.Name + " [#7D0804] exploded to bits!");
            break;
        }
        case 43:
        {
            Message(player.Name + " [#090362] drowned to death.");
            break;
        }
        case 39:
        {
            Message(player.Name + " [#23235f] died in a car accident.");
            break;
        }
        case 70:
        {
            Message(player.Name + " [#9954c3] suicided.");
            break;
        }
    }
{
  local pdeath = stats[player.ID].deaths + 1;
  QuerySQL(stats, "UPDATE pstats SET Deaths = '" + pdeath + "' WHERE Name = '" + player.Name + "'");
  rankcheck(player);
}



function onPlayerKill( player, killer, reason, bodypart )
{
rankcheck(killer);
rankcheck(player);

 if(bodypart == 6)
 {
  MessagePlayer("[#FFFFFF]You received $1000 bonus for killing through headshot", killer);
  local pkill = stats[player.ID].kills + 1;
  local phead = stats[player.ID].headshots + 1;
  QuerySQL(stats, "UPDATE pstats SET Kills = '" + pkill + "' WHERE Name = '" + killer.Name + "'");
  QuerySQL(stats, "UPDATE pstats SET Headshots = '" + phead + "' WHERE Name = '" + killer.Name + "'");
  local pdeath = stats[player.ID].deaths + 1;
  QuerySQL(stats, "UPDATE pstats SET Deaths = '"+pdeath+"' WHERE Name = '"+player.Name+"'");

 }
 else
 {
  local q2 = QuerySQL(stats, "SELECT * FROM pstats WHERE Name = '" + killer.Name + "'");
  local pkill = GetSQLColumnData(q2, 2).tointeger() + 1;
  QuerySQL(stats, "UPDATE pstats SET Kills = '" + pkill + "' WHERE Name = '" + killer.Name + "'");
  local q3 = QuerySQL(stats, "SELECT * FROM pstats WHERE Name = '" + player.Name + "'");
  local pdeath = GetSQLColumnData(q3, 2).tointeger() + 1;
  QuerySQL(stats, "UPDATE pstats SET Deaths = '"+pdeath+"' WHERE Name = '"+player.Name+"'");
 }
 
}



function onPlayerCommand(player, command, arguments)
{
local cmd, text;
cmd = command.tolower();
text = arguments;
 if(cmd == "stats")
 {
  if(!arguments)
  {
   MessagePlayer("[#FF0000]Information:[#FFFFFF] Your stats : ", player);
   MessagePlayer("[#FFFFFF]Kills : " + stats[player.ID].kills + " Headshots : " + stats[player.ID].headshots + " Deaths : " + stats[player.ID].deaths + " Rank : " + stats[player.ID].rank + "emergencypoints : " + stats[player.ID].emergencypoints + ".", player);
  }
  else
  {
   local plr = FindPlayer(arguments);
   if(!plr) MessagePlayer("[#FF0000]Usage Error:[#FFFFFF] Unknown Player", player);
   else
   {
    local q = QuerySQL(stats, "SELECT * FROM pstats WHERE Name = '" + plr.Name + "'");
    MessagePlayer("[#FF0000]Information:[#FFFFFF] "+plr.Name+ " stats : ", player);
    MessagePlayer("[#FFFFFF]Kills : " + stats[player.ID].kills + " Headshots : " + stats[player.ID].headshots + " Deaths : " + stats[player.ID].deaths + " Rank : " + stats[player.ID].rank + "emergencypoints : " + stats[player.ID].emergencypoints + ".", player);
   }
  }
 }

 
   else if(cmd == "resetstats")
 {
  if(!arguments) MessagePlayer("[#FF0000]Command Error:[#FFFFFF] Use /" + cmd + " [player] ", player);
  else
  {
   local plr = FindPlayer(arguments);
   if(!plr) MessagePlayer("[#FF0000]Usage Error:[#FFFFFF] Invalid player", player);
   else
   {   
    Message("[#514FFF]Administrator Command:[#FFFFFF] Admin[" + player.Name + "] reseted stats of player : " + plr.Name+ ".");
    MessagePlayer("[#FF0000]Information:[#FFFFFF] Your stats have been reseted by Admin " + player.Name + ".", plr);
    QuerySQL(stats, "UPDATE pstats SET Rank = '1', Kills = '0', Deaths = '0', Headshots = '0' Emergencypoints= '0' WHERE Name = '" + plr.Name + "'");
 stats[plr.ID].kills = 0;
stats[plr.ID].deaths = 0;
stats[plr.ID].headshots = 0;
stats[plr.ID].rank = 1;
stats[plr.ID].emergencypoints = 0;
   }
  }
 }
 
 

 
 else if(cmd == "setstats")
 {
  if(!arguments)
  {
   MessagePlayer("[#FF0000]Command Error:[#FFFFFF] Use /" + cmd + " [player] [stats(0 - 3)] [value]", player);
   MessagePlayer("0 = Rank, 1 = Kills, 2 = Headshots, 3 = Deaths, 4 = Emergencypoints", player);
  }
  else if(NumTok(arguments, " ") < 3 )
  {
   MessagePlayer("[#FF0000]Command Error:[#FFFFFF] Use /" + cmd + " [player] [stats(0 - 4)] [value]", player);
   MessagePlayer("0 = Rank, 1 = Kills, 2 = Headshots, 3 = Deaths, 4 = Emergencypoints", player);
  }
  else if(!IsNum(GetTok(arguments, " ", 2))) MessagePlayer("[#FF0000]Usage Error:[#FFFFFF] Stats should be between 0 - 4", player);
  else if(!IsNum(GetTok(arguments, " ", 3))) MessagePlayer("[#FF0000]Usage Error:[#FFFFFF] value should be in numbers", player);
  else if(GetTok(arguments, " ", 2).tointeger() < 0 ) MessagePlayer("[#FF0000]Usage Error:[#FFFFFF] Stats should be between 0 - 4", player);
  else if(GetTok(arguments, " ", 2).tointeger() > 4 ) MessagePlayer("[#FF0000]Usage Error:[#FFFFFF] Stats should be between 0 - 4", player);
  else if(GetTok(arguments, " ", 3).tointeger() < 0 ) MessagePlayer("[#FF0000]Usage Error:[#FFFFFF] Minimum value is 0", player);
  else
  {
   local plr = FindPlayer(GetTok(arguments, " ", 1));
   local stat = GetTok(arguments, " ", 2).tointeger();
   local val = GetTok(arguments, " ", 3).tointeger();
   if(!plr) MessagePlayer("[#FF0000]Usage Error:[#FFFFFF] Invalid player", player);
   else
   {
    if(stat == 0)
    {
     if(val < 1) MessagePlayer("[#FF0000]Usage Error:[#FFFFFF] Rank cannot be less than 1", player);
     else QuerySQL(stats, "UPDATE pstats SET Rank = '" + val + "' WHERE Name = '" + plr.Name + "'");
  stats[plr.ID].rank = val;
     Message("[#514FFF]Developer Command:[#FFFFFF] Developer[" + player.Name + "] set Player : " + plr.Name +"'s Rank to " + val + ".");
    }
    else if(stat == 1)
    {
     QuerySQL(stats, "UPDATE pstats SET Kills = '" + val + "' WHERE Name = '" + plr.Name + "'");
     Message("[#514FFF]Developer Command:[#FFFFFF] Developer[" + player.Name + "]set Player : " + plr.Name + "'s Kills to " + val + ".");
     stats[plr.ID].kills = val;
    }
    else if(stat == 2)
    {
     QuerySQL(stats, "UPDATE pstats SET HeadShots = '" + val + "' WHERE Name = '" + plr.Name + "'");
     Message("[#514FFF]Developer Command:[#FFFFFF] Developer[" + player.Name + "] set Player : " + plr.Name+ "'s HeadShots to " + val + ".");
     stats[plr.ID].headshots = val;
    }
    else if(stat == 3)
    {
     QuerySQL(stats, "UPDATE pstats SET Deaths = '" + val + "' WHERE Name = '" + plr.Name + "'");
     Message("[#514FFF]Developer Command:[#FFFFFF] Developer[" + player.Name + "] set Player : " + plr.Name+ "'s Deaths to " + val + ".");
     stats[plr.ID].deaths = val;
   }
    else if(stat == 4)
    {
     QuerySQL(stats, "UPDATE pstats SET Emergencypoints = '" + val + "' WHERE Name = '" + plr.Name + "'");
     Message("[#514FFF]Developer Command:[#FFFFFF] Developer[" + player.Name + "] set Player : " + plr.Name+ "'s Emergencypoints to " + val + ".");
     stats[plr.ID].emergencypoints = val;
    }
   }
  }
 }
}


function rankcheck(player)
{
 local q2 = QuerySQL(stats, "SELECT * FROM pstats WHERE Name = '" + player.Name+ "'");
 local ran = GetSQLColumnData(q2, 1).tointeger();
 
 local kills = GetSQLColumnData(q2, 2).tointeger();

 if(kills >= 5000 && ran < 8)
 {
  QuerySQL(stats, "UPDATE pstats SET Rank = '8' WHERE Name = '" + player.Name + "'");
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You have completed 5000 kills. Now your rank is 8", player);
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You received 000 cash", player);
 }
 
 else if(kills >= 4000 && ran < 7 && kills < 5000)
 {
  QuerySQL(stats, "UPDATE pstats SET Rank = '7' WHERE Name = '" + player.Name + "'");
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You have completed 4000 kills. Now your rank is 8", player);
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You received 000 cash", player);
 }

 else if(kills >= 3000 && ran < 6 && kills < 4000)
 {
  QuerySQL(stats, "UPDATE pstats SET Rank = '6' WHERE Name = '" + player.Name + "'");
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You have completed 3000 kills. Now your rank is 8", player);
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You received 000 cash", player);
 }

 else if(kills >= 2000 && ran < 5 && kills < 3000)
 {
  QuerySQL(stats, "UPDATE pstats SET Rank = '5' WHERE Name = '" + player.Name + "'");
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You have completed 2000 kills. Now your rank is 8", player);
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You received 000 cash", player);
 }

 else if(kills >= 1000 && ran < 4 && kills < 2000)
 {
  QuerySQL(stats, "UPDATE pstats SET Rank = '4' WHERE Name = '" + player.Name + "'");
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You have completed 1000 kills. Now your rank is 8", player);
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You received 000 cash", player);
 }

 else if(kills >= 500 && ran < 3 && kills < 1000)
 {
  QuerySQL(stats, "UPDATE pstats SET Rank = '3' WHERE Name = '" + player.Name + "'");
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You have completed 500 kills. Now your rank is 8", player);
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You received 000 cash", player);
 }

 else if(kills >= 100 && ran < 2 && kills < 500)
 {
  QuerySQL(stats, "UPDATE pstats SET Rank = '2' WHERE Name = '" + player.Name + "'");
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You have completed 100 kills. Now your rank is 8", player);
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You received 000 cash", player);
 }
 
}
function StatsInfo(player)
{
 local q = QuerySQL(stats, "SELECT * FROM pstats WHERE Name = '"+player.Name+"'");
 if(!q) QuerySQL(stats, "INSERT INTO pstats ( Name, Rank, Kills, Headshots, Deaths, Emergencypoints ) VALUES ( '" + escapeSQLString(player.Name) + "', '1', '0', '0', '0' '0' )");
 else
 {
 stats[player.ID].kills = GetSQLColumnData(q, 2).tointeger();
 stats[player.ID].headshots = GetSQLColumnData(q, 3).tointeger();
 stats[player.ID].deaths = GetSQLColumnData(q, 4).tointeger();
 stats[player.ID].rank = GetSQLColumnData(q, 1).tointeger();
 stats[player.ID].emergencypoints = GetSQLColumnData(q, 1).tointeger();
 
 }
 }

function GetTok(string, separator, n, ...)
{
local m = vargv.len() > 0 ? vargv[0] : n,
tokenized = split(string, separator),
text = "";
if (n > tokenized.len() || n < 1) return null;
for (; n <= m; n++)
{
text += text == "" ? tokenized[n-1] : separator + tokenized[n-1];
}
return text;
}

function NumTok(string, separator)
{
local tokenized = split(string, separator);
return tokenized.len();
}

function GetPlayer( plr )
{
if ( plr )
{
if ( IsNum( plr ) )
{
plr = FindPlayer( plr.tointeger() );
if ( plr ) return plr;
else return false;
}
else
{
plr = FindPlayer( plr );
if ( plr ) return plr;
else return false;
}
}
else return false;
}


I am running into some issues could you help me
[/noae]

We can't help you if you don't identify the problem you're facing with, along with screenshots.

Kelvinvenema

Quote from: DarkRaZoR^ on Dec 31, 2019, 06:00 AM[noae]
Quote from: Kelvinvenema on Dec 21, 2019, 09:11 AMI tried[noae]
Quote from: Athanatos on Dec 21, 2019, 08:30 AM[noae]
Quote from: umar4911 on Dec 21, 2019, 05:23 AMuse Class system.
[/noae]
The classes in object oriented programming are not 'systems' , they are actually a type of data.
[/noae]

 I tried to add a new stats.

class PlayerStats
{
 kills = 0;
 headshots = 0;
 deaths = 0;
 rank = 0;
 emergencypoints = 0;

function onPlayerJoin( player )
{
StatsInfo(player);
}


function onPlayerDeath( player, reason )
{
switch (reason)
 {
        case 44:
        {
            Message(player.Name + " [#01403E] fell down and died.");
            break;
        }
        case 41:
        {
            Message(player.Name + " [#7D0804] exploded to bits!");
            break;
        }
        case 43:
        {
            Message(player.Name + " [#090362] drowned to death.");
            break;
        }
        case 39:
        {
            Message(player.Name + " [#23235f] died in a car accident.");
            break;
        }
        case 70:
        {
            Message(player.Name + " [#9954c3] suicided.");
            break;
        }
    }
{
  local pdeath = stats[player.ID].deaths + 1;
  QuerySQL(stats, "UPDATE pstats SET Deaths = '" + pdeath + "' WHERE Name = '" + player.Name + "'");
  rankcheck(player);
}



function onPlayerKill( player, killer, reason, bodypart )
{
rankcheck(killer);
rankcheck(player);

 if(bodypart == 6)
 {
  MessagePlayer("[#FFFFFF]You received $1000 bonus for killing through headshot", killer);
  local pkill = stats[player.ID].kills + 1;
  local phead = stats[player.ID].headshots + 1;
  QuerySQL(stats, "UPDATE pstats SET Kills = '" + pkill + "' WHERE Name = '" + killer.Name + "'");
  QuerySQL(stats, "UPDATE pstats SET Headshots = '" + phead + "' WHERE Name = '" + killer.Name + "'");
  local pdeath = stats[player.ID].deaths + 1;
  QuerySQL(stats, "UPDATE pstats SET Deaths = '"+pdeath+"' WHERE Name = '"+player.Name+"'");

 }
 else
 {
  local q2 = QuerySQL(stats, "SELECT * FROM pstats WHERE Name = '" + killer.Name + "'");
  local pkill = GetSQLColumnData(q2, 2).tointeger() + 1;
  QuerySQL(stats, "UPDATE pstats SET Kills = '" + pkill + "' WHERE Name = '" + killer.Name + "'");
  local q3 = QuerySQL(stats, "SELECT * FROM pstats WHERE Name = '" + player.Name + "'");
  local pdeath = GetSQLColumnData(q3, 2).tointeger() + 1;
  QuerySQL(stats, "UPDATE pstats SET Deaths = '"+pdeath+"' WHERE Name = '"+player.Name+"'");
 }
 
}



function onPlayerCommand(player, command, arguments)
{
local cmd, text;
cmd = command.tolower();
text = arguments;
 if(cmd == "stats")
 {
  if(!arguments)
  {
   MessagePlayer("[#FF0000]Information:[#FFFFFF] Your stats : ", player);
   MessagePlayer("[#FFFFFF]Kills : " + stats[player.ID].kills + " Headshots : " + stats[player.ID].headshots + " Deaths : " + stats[player.ID].deaths + " Rank : " + stats[player.ID].rank + "emergencypoints : " + stats[player.ID].emergencypoints + ".", player);
  }
  else
  {
   local plr = FindPlayer(arguments);
   if(!plr) MessagePlayer("[#FF0000]Usage Error:[#FFFFFF] Unknown Player", player);
   else
   {
    local q = QuerySQL(stats, "SELECT * FROM pstats WHERE Name = '" + plr.Name + "'");
    MessagePlayer("[#FF0000]Information:[#FFFFFF] "+plr.Name+ " stats : ", player);
    MessagePlayer("[#FFFFFF]Kills : " + stats[player.ID].kills + " Headshots : " + stats[player.ID].headshots + " Deaths : " + stats[player.ID].deaths + " Rank : " + stats[player.ID].rank + "emergencypoints : " + stats[player.ID].emergencypoints + ".", player);
   }
  }
 }

 
   else if(cmd == "resetstats")
 {
  if(!arguments) MessagePlayer("[#FF0000]Command Error:[#FFFFFF] Use /" + cmd + " [player] ", player);
  else
  {
   local plr = FindPlayer(arguments);
   if(!plr) MessagePlayer("[#FF0000]Usage Error:[#FFFFFF] Invalid player", player);
   else
   {   
    Message("[#514FFF]Administrator Command:[#FFFFFF] Admin[" + player.Name + "] reseted stats of player : " + plr.Name+ ".");
    MessagePlayer("[#FF0000]Information:[#FFFFFF] Your stats have been reseted by Admin " + player.Name + ".", plr);
    QuerySQL(stats, "UPDATE pstats SET Rank = '1', Kills = '0', Deaths = '0', Headshots = '0' Emergencypoints= '0' WHERE Name = '" + plr.Name + "'");
 stats[plr.ID].kills = 0;
stats[plr.ID].deaths = 0;
stats[plr.ID].headshots = 0;
stats[plr.ID].rank = 1;
stats[plr.ID].emergencypoints = 0;
   }
  }
 }
 
 

 
 else if(cmd == "setstats")
 {
  if(!arguments)
  {
   MessagePlayer("[#FF0000]Command Error:[#FFFFFF] Use /" + cmd + " [player] [stats(0 - 3)] [value]", player);
   MessagePlayer("0 = Rank, 1 = Kills, 2 = Headshots, 3 = Deaths, 4 = Emergencypoints", player);
  }
  else if(NumTok(arguments, " ") < 3 )
  {
   MessagePlayer("[#FF0000]Command Error:[#FFFFFF] Use /" + cmd + " [player] [stats(0 - 4)] [value]", player);
   MessagePlayer("0 = Rank, 1 = Kills, 2 = Headshots, 3 = Deaths, 4 = Emergencypoints", player);
  }
  else if(!IsNum(GetTok(arguments, " ", 2))) MessagePlayer("[#FF0000]Usage Error:[#FFFFFF] Stats should be between 0 - 4", player);
  else if(!IsNum(GetTok(arguments, " ", 3))) MessagePlayer("[#FF0000]Usage Error:[#FFFFFF] value should be in numbers", player);
  else if(GetTok(arguments, " ", 2).tointeger() < 0 ) MessagePlayer("[#FF0000]Usage Error:[#FFFFFF] Stats should be between 0 - 4", player);
  else if(GetTok(arguments, " ", 2).tointeger() > 4 ) MessagePlayer("[#FF0000]Usage Error:[#FFFFFF] Stats should be between 0 - 4", player);
  else if(GetTok(arguments, " ", 3).tointeger() < 0 ) MessagePlayer("[#FF0000]Usage Error:[#FFFFFF] Minimum value is 0", player);
  else
  {
   local plr = FindPlayer(GetTok(arguments, " ", 1));
   local stat = GetTok(arguments, " ", 2).tointeger();
   local val = GetTok(arguments, " ", 3).tointeger();
   if(!plr) MessagePlayer("[#FF0000]Usage Error:[#FFFFFF] Invalid player", player);
   else
   {
    if(stat == 0)
    {
     if(val < 1) MessagePlayer("[#FF0000]Usage Error:[#FFFFFF] Rank cannot be less than 1", player);
     else QuerySQL(stats, "UPDATE pstats SET Rank = '" + val + "' WHERE Name = '" + plr.Name + "'");
  stats[plr.ID].rank = val;
     Message("[#514FFF]Developer Command:[#FFFFFF] Developer[" + player.Name + "] set Player : " + plr.Name +"'s Rank to " + val + ".");
    }
    else if(stat == 1)
    {
     QuerySQL(stats, "UPDATE pstats SET Kills = '" + val + "' WHERE Name = '" + plr.Name + "'");
     Message("[#514FFF]Developer Command:[#FFFFFF] Developer[" + player.Name + "]set Player : " + plr.Name + "'s Kills to " + val + ".");
     stats[plr.ID].kills = val;
    }
    else if(stat == 2)
    {
     QuerySQL(stats, "UPDATE pstats SET HeadShots = '" + val + "' WHERE Name = '" + plr.Name + "'");
     Message("[#514FFF]Developer Command:[#FFFFFF] Developer[" + player.Name + "] set Player : " + plr.Name+ "'s HeadShots to " + val + ".");
     stats[plr.ID].headshots = val;
    }
    else if(stat == 3)
    {
     QuerySQL(stats, "UPDATE pstats SET Deaths = '" + val + "' WHERE Name = '" + plr.Name + "'");
     Message("[#514FFF]Developer Command:[#FFFFFF] Developer[" + player.Name + "] set Player : " + plr.Name+ "'s Deaths to " + val + ".");
     stats[plr.ID].deaths = val;
   }
    else if(stat == 4)
    {
     QuerySQL(stats, "UPDATE pstats SET Emergencypoints = '" + val + "' WHERE Name = '" + plr.Name + "'");
     Message("[#514FFF]Developer Command:[#FFFFFF] Developer[" + player.Name + "] set Player : " + plr.Name+ "'s Emergencypoints to " + val + ".");
     stats[plr.ID].emergencypoints = val;
    }
   }
  }
 }
}


function rankcheck(player)
{
 local q2 = QuerySQL(stats, "SELECT * FROM pstats WHERE Name = '" + player.Name+ "'");
 local ran = GetSQLColumnData(q2, 1).tointeger();
 
 local kills = GetSQLColumnData(q2, 2).tointeger();

 if(kills >= 5000 && ran < 8)
 {
  QuerySQL(stats, "UPDATE pstats SET Rank = '8' WHERE Name = '" + player.Name + "'");
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You have completed 5000 kills. Now your rank is 8", player);
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You received 000 cash", player);
 }
 
 else if(kills >= 4000 && ran < 7 && kills < 5000)
 {
  QuerySQL(stats, "UPDATE pstats SET Rank = '7' WHERE Name = '" + player.Name + "'");
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You have completed 4000 kills. Now your rank is 8", player);
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You received 000 cash", player);
 }

 else if(kills >= 3000 && ran < 6 && kills < 4000)
 {
  QuerySQL(stats, "UPDATE pstats SET Rank = '6' WHERE Name = '" + player.Name + "'");
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You have completed 3000 kills. Now your rank is 8", player);
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You received 000 cash", player);
 }

 else if(kills >= 2000 && ran < 5 && kills < 3000)
 {
  QuerySQL(stats, "UPDATE pstats SET Rank = '5' WHERE Name = '" + player.Name + "'");
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You have completed 2000 kills. Now your rank is 8", player);
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You received 000 cash", player);
 }

 else if(kills >= 1000 && ran < 4 && kills < 2000)
 {
  QuerySQL(stats, "UPDATE pstats SET Rank = '4' WHERE Name = '" + player.Name + "'");
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You have completed 1000 kills. Now your rank is 8", player);
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You received 000 cash", player);
 }

 else if(kills >= 500 && ran < 3 && kills < 1000)
 {
  QuerySQL(stats, "UPDATE pstats SET Rank = '3' WHERE Name = '" + player.Name + "'");
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You have completed 500 kills. Now your rank is 8", player);
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You received 000 cash", player);
 }

 else if(kills >= 100 && ran < 2 && kills < 500)
 {
  QuerySQL(stats, "UPDATE pstats SET Rank = '2' WHERE Name = '" + player.Name + "'");
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You have completed 100 kills. Now your rank is 8", player);
  MessagePlayer("[#FF0000]Information:[#FFFFFF] You received 000 cash", player);
 }
 
}
function StatsInfo(player)
{
 local q = QuerySQL(stats, "SELECT * FROM pstats WHERE Name = '"+player.Name+"'");
 if(!q) QuerySQL(stats, "INSERT INTO pstats ( Name, Rank, Kills, Headshots, Deaths, Emergencypoints ) VALUES ( '" + escapeSQLString(player.Name) + "', '1', '0', '0', '0' '0' )");
 else
 {
 stats[player.ID].kills = GetSQLColumnData(q, 2).tointeger();
 stats[player.ID].headshots = GetSQLColumnData(q, 3).tointeger();
 stats[player.ID].deaths = GetSQLColumnData(q, 4).tointeger();
 stats[player.ID].rank = GetSQLColumnData(q, 1).tointeger();
 stats[player.ID].emergencypoints = GetSQLColumnData(q, 1).tointeger();
 
 }
 }

function GetTok(string, separator, n, ...)
{
local m = vargv.len() > 0 ? vargv[0] : n,
tokenized = split(string, separator),
text = "";
if (n > tokenized.len() || n < 1) return null;
for (; n <= m; n++)
{
text += text == "" ? tokenized[n-1] : separator + tokenized[n-1];
}
return text;
}

function NumTok(string, separator)
{
local tokenized = split(string, separator);
return tokenized.len();
}

function GetPlayer( plr )
{
if ( plr )
{
if ( IsNum( plr ) )
{
plr = FindPlayer( plr.tointeger() );
if ( plr ) return plr;
else return false;
}
else
{
plr = FindPlayer( plr );
if ( plr ) return plr;
else return false;
}
}
else return false;
}


I am running into some issues could you help me
[/noae]

We can't help you if you don't identify the problem you're facing with, along with screenshots.


I got the problem solved anyways thanks for answering i forgot to lock the topic

SOLVED