Account System

umar4911

  • Sr. Member
  • Creating own server!
  • Posts: 353
Re: Account System
« Reply #15,  »
Nice one. I hope my registration system goes well too.
I am gamer, programmer and hacker. Try to find me!
xD

=RK=MarineForce

  • Sr. Member
  • why noise ??? Re 100%
  • Posts: 373
Re: Account System
« Reply #16,  »Last edited
hmm its help. I added admin commands too.
Thanks To Kakan For Mute System and Diego For suban system and Mahmoud for help. :P

Code: [Select]
LIMIT_REP_SPAM <- 3;
MUTE_TIME <- 30000;
LIMT_REP_TIME <- 2;

class PlayerAccountStats
{
registered = false;
logged = false;
kills = 0;
deaths = 0;
headshots = 0;
level = 1;
joins = 0;
autologin = "on";
}
function LoadInfo( player )
{
if ( player )
{
  local query = QuerySQL( database, "SELECT * FROM account WHERE player = '" + player.Name.tolower() + "'" );
  if ( query )
  {
   if ( ( GetSQLColumnData( query, 2 ).tostring() == player.UniqueID ) && ( GetSQLColumnData( query, 9 ).tostring() == "on" ) )
   {
    local KILLS = GetSQLColumnData( query, 3 ), DEATHS = GetSQLColumnData( query, 4 ), HEADSHOTS = GetSQLColumnData( query, 5 ), JOINS = GetSQLColumnData( query, 6 ), LEVEL = GetSQLColumnData( query, 8 );
    stats[ player.ID ].kills = KILLS.tointeger();
    stats[ player.ID ].deaths = DEATHS.tointeger();
    stats[ player.ID ].headshots = HEADSHOTS.tointeger();
    stats[ player.ID ].joins = JOINS.tointeger();
    stats[ player.ID ].level = LEVEL.tointeger();
    player.Cash = GetSQLColumnData( query, 7 ).tointeger();
    stats[ player.ID ].autologin = GetSQLColumnData( query, 9 ).tostring();
    stats[ player.ID ].joins++;
    stats[ player.ID ].registered = true;
    stats[ player.ID ].logged = true;
    ClientMessageToAll( format( ">> %s has been auto logged in.", player.Name ), 0, 255, 0 );
    PrivMessage( player, format( "Nickname:[ %s ] Kills:[ %d ] Deaths:[ %d ] Headshots:[ %d ] Level:[ %d ] Joins:[ %d ]", GetSQLColumnData( query, 0 ), KILLS.tointeger(), DEATHS.tointeger(), HEADSHOTS.tointeger(), LEVEL.tointeger(), JOINS.tointeger() ) );
   }
   else if ( ( GetSQLColumnData( query, 2 ).tostring() != player.UniqueID ) || ( GetSQLColumnData( query, 9 ).tostring() == "off" ) )
   {
    stats[ player.ID ].registered = true;
    PrivMessage( player, format( "Welcome back %s! Please log-in into your account using /login <password>", player.Name ) );
   }
  }
  else PrivMessage( player, "You are not registered. Type /register <password> to register an account." );
}
else return 0;
}
function SaveInfo( player )
{
if ( player )
{
  local player_name = player.Name, KILLS = stats[ player.ID ].kills, DEATHS = stats[ player.ID ].deaths, HEADSHOTS = stats[ player.ID ].headshots, JOINS = stats[ player.ID ].headshots, PC = player.Cash, LEVEL = stats[ player.ID ].level, AUTOLOGIN = stats[ player.ID ].autologin;
  local q = QuerySQL( database, "SELECT player FROM account WHERE player = '" + player_name.tolower() + "'" );
  if ( q ) QuerySQL( database, "UPDATE account SET kills = '" + KILLS.tointeger() + "', deaths = '" + DEATHS.tointeger() + "', headshots = '" + HEADSHOTS.tointeger() + "', joins = '" + JOINS.tointeger() + "', cash = '" + PC.tointeger() + "', level = '" + LEVEL.tointeger() + "', autologin = '" + AUTOLOGIN.tostring() + "' WHERE player = '" + player_name.tolower() + "'" );
  print( format( "*** [%d] %s's stats have been successfully saved. (Kills:[ %d ] Deaths:[ %d ] Headshots:[ %d ] Cash:[ $%d ] Level:[ %d ] Autologin:[ %s ] Joins:[ %d ])", player.ID, player_name, KILLS.tointeger(), DEATHS.tointeger(), HEADSHOTS.tointeger(), PC.tointeger(), LEVEL.tointeger(), AUTOLOGIN.tostring(), JOINS.tointeger() ) );
}
else return 0;
}
function inccash( player, amount )
{
if ( ( player ) && ( amount ) ) player.Cash += amount.tointeger();
else return 0;
}
function deccash( player, amount )
{
if ( ( player ) && ( amount ) )
{
  if ( player.Cash > amount.tointeger() ) player.Cash -= amount.tointeger();
  else player.Cash = 0;
}
else return 0;
}

function onScriptLoad()
{
warn <- ConnectSQL("scripts/warn.db");
QuerySQL(warn, "create table if not exists warn ( Name VARCHAR(32), Reason TEXT, Admin TEXT, Day VARCHAR(25), Month VARCHAR(25), Year VARCHAR(25), Hour VARCHAR(25), Min VARCHAR(25) )");
rp <- ConnectSQL("scripts/report.db");
QuerySQL(rp, "create table if not exists report ( Plr TEXT, Name TEXT, Reason TEXT, Day VARCHAR(25), Month VARCHAR(25), Year VARCHAR(25), Hour VARCHAR(25), Min VARCHAR(25) )");
 stats <- array( GetMaxPlayers(), null );
 database <- ConnectSQL( "data_base.db" );
IsMuted <- array( GetMaxPlayers(), false);
  antiSpamTime <- array( GetMaxPlayers(), 0 );
  antiSpamWarnings <- array( GetMaxPlayers(), 0 );

print(">>> System SubBan loaded <<<");
db <- ConnectSQL( "DataBase.db" );
QuerySQL( db, "CREATE TABLE IF NOT EXISTS SubBans ( Name VARCHAR(32), IP VARCHAR(25), Admin TEXT, Reason TEXT )" );

stats <- array( GetMaxPlayers(), null );
database <- ConnectSQL( "data_base.db" );
QuerySQL( database, "CREATE TABLE IF NOT EXISTS account ( player VARCHAR(32), password VARCHAR(255), uid VARCHAR(255), kills INTEGER, deaths INTEGER, headshots INTEGER, joins INTEGER, cash INTEGER, level INTEGER, autologin TEXT )" );
print( "Successfully loaded database by =TRC=Kelvin." );
}
function onScriptUnload()
{
DisconnectSQL( db );
DisconnectSQL( database );
}

function CheckBan( user )
{
local player = FindPlayer( user );
if ( player )
{
local ip = player.IP;
local sub = split( ip, "." );
local q = QuerySQL( db,  "SELECT * FROM SubBans WHERE IP='" + sub[0].tofloat() + "." + sub[1].tofloat() + "'" );
if ( GetSQLColumnData( q, 0 ) )
{
Message( ">>> " + player + " Banned From Server <<<");
KickPlayer( player );
return 1;
}
}
}


function onPlayerChat( player, message ) {
local MUTE_DIVIDE = 1000;
       if ( ( time() - antiSpamTime[ player.ID ] ) <= LIMT_REP_TIME ) {
antiSpamWarnings[ player.ID ]++;
if ( antiSpamWarnings[ player.ID ] >= LIMIT_REP_SPAM ) {
  if( !IsMuted[ player.ID ] ){
    IsMuted[ player.ID ] = true;
    Message(format(">> Auto-Muted: %s Reason: Spamming the Chat. Duration[ %d seconds ]",player.Name,MUTE_TIME/MUTE_DIVIDE) );
    NewTimer("autounmute",MUTE_TIME.tointeger(),1,player.ID);
  }
}
} else {
antiSpamWarnings[ player.ID ] = 0;
}
antiSpamTime[ player.ID ] = time();
if( IsMuted[ player.ID] ){
return 0;
MessagePlayer(">> You are muted.",player);
}
else{
return 1;
//Have your code here
}
}

function autounmute(playerID)
{
local player = FindPlayer(playerID)
if (player && IsMuted[ player.ID ] )
{
        Message(">> Auto-UnMuted " + player.Name + " Reason: Mute time over."+ ".");
                IsMuted [ player.ID ] = false;
}
}

function onPlayerJoin( player )
{
NewTimer( "CheckBan", 1000, 1, player.ID );
stats[ player.ID ] = PlayerAccountStats();
LoadInfo( player );
}
function onPlayerPart( player, reason )
{
IsMuted[ player.ID ] = false;
if ( stats[ player.ID ].logged ) SaveInfo( player );
stats[ player.ID ] = null;
}
function onPlayerSpawn( player )
{
if ( !stats[ player.ID ].registered ) PrivMessage( player, "You are not registered. Type /register <password> to register an account." );
else if ( !stats[ player.ID ].logged )
{
  ClientMessageToAll( format( "Auto-kicked:[ %s ] Reason:[ Not logged-in ]", player.Name ), 255, 0, 0 );
  KickPlayer( player );
}
}
function onPlayerDeath( player, reason )
{
stats[ player.ID ].deaths++;
deccash( player, 5000 );
}
function onPlayerKill( player, killer, reason, bodypart )
{
if ( bodypart == 6 )
{
  local headshot_reward = 50000; // If you want, change this amount.
  stats[ player.ID ].headshots++;
  inccash( player, headshot_reward );
  PrivMessage( player, format( "HEADSHOT on %s! Reward: $%d.", killer.Name, headshot_reward.tointeger() ) );
}
stats[ player.ID ].kills++;
inccash( player, 5000 );
stats[ killer.ID ].deaths++;
deccash( killer, 5000 );
}
function onPlayerCommand( player, cmd, text )
{
if ( cmd == "register" )
{
  if ( ( stats[ player.ID ].registered ) || ( stats[ player.ID ].logged ) ) PrivMessage( player, "Error: You are already registered." );
  else if ( !text ) PrivMessage( player, format( "Error: Use /%s <password>", cmd ) );
  else
  {
   inccash( player, 20000 );
   QuerySQL( database, "INSERT INTO account ( player, password, uid, kills, deaths, headshots, joins, cash, level, autologin ) VALUES ( '" + player.Name.tolower() + "', '" + SHA256( text ) + "', '" + player.UniqueID + "', '0', '0', '0', '1', '0', '1', 'on' )" );
   stats[ player.ID ].registered = true;
   stats[ player.ID ].logged = true;
   PrivMessage( player, format( "You have been successfully registered! Nickname:[ %s ] Password:[ %s ]", player.Name, text ) );
   MessageAllExcept( format( "[#00FF00]>> %s has been successfully registered.", player.Name ), player );
  }
}
else if ( cmd == "login" )
{
  if ( stats[ player.ID ].logged ) PrivMessage( player, "Error: You are already logged-in." );
  else if ( !text ) PrivMessage( player, format( "Error: Use /%s <password>", cmd ) );
  else if ( SHA256( text ) != GetSQLColumnData( QuerySQL( database, "SELECT password FROM account WHERE player = '" + player.Name.tolower() + "'" ), 0 ) ) PrivMessage( player, "INVALID PASSWORD." );
  else
  {
   local query = QuerySQL( database, "SELECT * FROM account WHERE player = '" + player.Name.tolower() + "'" );
   if ( query )
   {
    local KILLS = GetSQLColumnData( query, 3 ), DEATHS = GetSQLColumnData( query, 4 ), HEADSHOTS = GetSQLColumnData( query, 5 ), JOINS = GetSQLColumnData( query, 6 ), LEVEL = GetSQLColumnData( query, 8 );
    stats[ player.ID ].kills = KILLS.tointeger();
    stats[ player.ID ].deaths = DEATHS.tointeger();
    stats[ player.ID ].headshots = HEADSHOTS.tointeger();
    stats[ player.ID ].joins = JOINS.tointeger();
    stats[ player.ID ].level = LEVEL.tointeger();
    player.Cash = GetSQLColumnData( query, 7 ).tointeger();
    stats[ player.ID ].autologin = GetSQLColumnData( query, 9 ).tostring();
    stats[ player.ID ].joins++;
    stats[ player.ID ].registered = true;
    stats[ player.ID ].logged = true;
    PrivMessage( player, format( "Nickname:[ %s ] Kills:[ %d ] Deaths:[ %d ] Headshots:[ %d ] Level:[ %d ] Joins:[ %d ]", GetSQLColumnData( query, 0 ), KILLS.tointeger(), DEATHS.tointeger(), HEADSHOTS.tointeger(), LEVEL.tointeger(), JOINS.tointeger() ) );
    ClientMessageToAll( format( ">> %s has logged-in.", player.Name ), 0, 255, 0 );
   }
   else PrivMessage( player, "wtf" );
  }
}
else if ( ( cmd == "changepass" ) || ( cmd == "changepassword" ) )
{
  if ( !stats[ player.ID ].logged ) PrivMessage( player, "Error: You are not logged-in. Type /login <password>" );
  else if ( !text ) PrivMessage( player, format( "Error: Use /%s <new password>", cmd ) );
  else
  {
   local q = QuerySQL( database, "SELECT password FROM account WHERE player = '" + player.Name.tolower() + "'" );
   if ( q )
   {
    QuerySQL( database, "UPDATE account SET password = '" + SHA256( text ) + "' WHERE player = '" + player.Name.tolower() + "'" );
    PrivMessage( player, format( "Your password has been successfully changed to:[ %s ]", text ) );
   }
   else PrivMessage( player, "Error: Your account was not found in database." );
  }
}
else if ( cmd == "autologin" )
{
  if ( !stats[ player.ID ].logged ) PrivMessage( player, "Error: You are not logged-in. Type /login <password>" );
  else if ( !text ) PrivMessage( player, format( "Error: Use /%s <on/off>", cmd ) );
  else if ( text == "on" )
  {
   if ( stats[ player.ID ].autologin == "on" ) PrivMessage( player, "Error: Your autologin is already turned on." );
   else
   {
    stats[ player.ID ].autologin = "on";
    PrivMessage( player, "Your autologin has been turned on." );
   }
  }
  else if ( text == "off" )
  {
   if ( stats[ player.ID ].autologin == "off" ) PrivMessage( player, "Error: Your autologin is already turned off." );
   else
   {
    stats[ player.ID ].autologin = "off";
    PrivMessage( player, "Your autologin has been turned off." );
   }
  }
  else PrivMessage( player, format( "Error: Use /%s <on/off>", cmd ) );
}
else if ( cmd == "stats" )
{
  if ( !text ) PrivMessage( player, format( "Error: Use /%s <player>", cmd ) );
  else
  {
   local plr = FindPlayer( text );
   if ( !plr ) PrivMessage( player, "Error: Unknown player." );
   else
   {
    if ( stats[ plr.ID ].logged ) ClientMessageToAll( format( ">> %s's stats: Kills:[ %d ] Deaths:[ %d ] Headshots:[ %d ] Cash:[ $%d ] Level:[ %d ] Joins:[ %d ]", plr.Name, stats[ plr.ID ].kills, stats[ plr.ID ].deaths, stats[ plr.ID ].headshots, plr.Cash, stats[ plr.ID ].level, stats[ plr.ID ].joins ), 255, 0, 0 );
    else PrivMessage( player, format( "Error: %s is not logged-in.", plr.Name ) );
   }
  }
}

////////////////////////////////////// Admin Commands ////////////////////////////////////

else if ( ( cmd == "admin" ) || ( cmd == "admins" ) )
{
local plr, b;
for( local i = 0; i <= GetMaxPlayers(); i++ )
{
plr = FindPlayer( i );
if ( ( plr ) && ( stats[ plr.ID ].level >= 3 ) )
{
if ( b ) b = b + ", " + plr.Name + " - " + levelTag( plr ) + ""
else b = plr.Name + " - " + levelTag( plr ) + ""
}
}
if ( b ) Message( " [#ffcc00] Admins Online: " + b + "  " );
else Message( " [#ff0000] No Admins Online." );
Message( " [#0000ff]Requested By " + player.Name +"" );
}

else if ( cmd == "settime" )
    {
if ( stats[ player.ID ].level < 4 ) PrivMessage( player, "Error: You are not authorized to use this command." );
else{
     if ( !text ) MessagePlayer( "[#ff0000]Correct syntax : /settime <hr> <min>", player );
      else if ( split(text, " ").len() < 2) return MessagePlayer("[#ff0000]Correct syntax : /settime <hr> <min>", player )
      else
   {
   local a = split(text, " ");
      if ( !IsNum( a[0] )) MessagePlayer( "[#ffbb00]Format: /settime <hr> <min>", player );
      else if ( !IsNum( a[1] )) MessagePlayer( "[#ffbb00]Format: /settime <hr> <min>", player );
      else SetTime( a[0].tointeger(), a[1].tointeger() ) ; 
      }
   }
      }

else if( cmd == "sethp" )
{
if ( stats[ player.ID ].level < 4 ) PrivMessage( player, "Error: You are not authorized to use this command." );
else{
      if( !text )
      MessagePlayer("Use /sethp <plr> <hp>", player);
      local params = split( text, " " );
      if( params.len() < 1 ) MessagePlayer("Wrong no. of parameters.", player);
      else if( !IsNum( params[1] ) ) return MessagePlayer("HP must be an integer.", player);
      else if( params[1].tointeger() > 100 || params[1].tointeger() < 0 ) return MessagePlayer("It can't be more than 100 or less than 0.", player);
      local plr = IsNum( params[0] ) ? FindPlayer( params[0].tointeger() ) : FindPlayer( params[0] );
      if( !plr ) return MessagePlayer( "Wrong player.", player );
      else plr.Health = params[1].tointeger();
     Message("Admin [#FF0000] " + player.Name + " [#FF0000] Set Health [#0000cc]" + plr.Name + "  [#ccff00]  " + plr.Health + " ");
}
   
}

else if ( cmd == "state" )
{
if(!text) MessagePlayer("[#FF0000] Syntax /state <Nick> ",player);
local plr = FindPlayer(text);
if(!plr) MessagePlayer("[#FF0000] Error- " + text + " is not online ",player);
else if ( !plr.IsSpawned ) MessagePlayer( "[#FF0000]The Player hasn't spawned yet..", player );
else{
if( plr.State == 1 ) MessagePlayer("[#CCFF00] " + plr.Name + " state: OnFoot " + plr.State + " ",player);
if( plr.State == 2 ) MessagePlayer("[#CCFF00] " + plr.Name + " state: OnFire " + plr.State + " ",player);
if( plr.State == 3 ) MessagePlayer("[#CCFF00] " + plr.Name + " state: Driver " + plr.State + " ",player);
if( plr.State == 4 ) MessagePlayer("[#CCFF00] " + plr.Name + " state: Passenger " + plr.State + "  ",player);
if( plr.State == 5 ) MessagePlayer("[#CCFF00] " + plr.Name + " state: Enter Vehicle " + plr.State + "  ",player);
if( plr.State == 6 ) MessagePlayer("[#CCFF00] " + plr.Name + " state: Enter Passenger " + plr.State + "  ",player);
if( plr.State == 7 ) MessagePlayer("[#CCFF00] " + plr.Name + " state: Exit Vehicle " + plr.State + " ",player);
}
}



else if ( cmd == "setweather" )
{
if ( stats[ player.ID ].level < 4 ) PrivMessage( player, "Error: You are not authorized to use this command." );
else{
if (!text ) return MessagePlayer( "[#ff0000]Usage: setweather [Weather/ID]", player );
if (!IsNum(text) ) return MessagePlayer( "[#ff0000]Use integers/numbers", player );
SetWeather( text.tointeger() );
Message( "[#ff0000] Admin "+ player.Name +" Set The Weather To "+GetWeatherName());
return
}

}

 else if (cmd == "ann")
    {
if ( stats[ player.ID ].level < 3 ) PrivMessage( player, "Error: You are not authorized to use this command." );
else{
       if (!text) return ClientMessage("[#FF0000][Syntax]/ann <ID> <All/Nick/ID> <Text>", player, 0, 0, 0);
        local v = split(text, " ");
        if (v.len() < 3) return ClientMessage("[#FF0000][Syntax]/ann <ID> <All/Nick/ID> <Text>", player, 0, 0, 0);
        if (v[1].tolower() == "all") AnnounceAll(text.slice(v[0].len() + v[1].len() + 2), v[0].tointeger());
        else Announce(text.slice(v[0].len() + v[1].len() + 2), FindPlayer(v[1]), v[0].tointeger());
    }
       
}


 
else if( cmd == "setarmour" )
{
if ( stats[ player.ID ].level < 3 ) PrivMessage( player, "Error: You are not authorized to use this command." );
else{
      if( !text )
      MessagePlayer("Use /setarmour <plr> <hp>", player);
      local params = split( text, " " );
      if( params.len() < 1 ) MessagePlayer("Wrong no. of parameters.", player);
      else if( !IsNum( params[1] ) ) return MessagePlayer("Armour must be an integer.", player);
      else if( params[1].tointeger() > 100 || params[1].tointeger() < 0 ) return MessagePlayer("It can't be more than 100 or less than 0.", player);
      local plr = IsNum( params[0] ) ? FindPlayer( params[0].tointeger() ) : FindPlayer( params[0] );
      if( !plr ) return MessagePlayer( "Wrong player.", player );
      else plr.Armour = params[1].tointeger();
      Message("Admin [#0000FF] " + player.Name + " [#FFFF00] Set Arm [#0000ff] of " + plr.Name + "  [#ccff00]  " + plr.Armour + " ");
}

}

else if ( cmd == "warn" )
{
if ( stats[ player.ID ].level < 3 ) PrivMessage( player, "Error: You are not authorized to use this command." );
if(!text) MessagePlayer("/warn <Player> <Reason>",player);
else{
local plr = GetPlayer( GetTok( text, " ", 1 ) );
if ( !plr ) MessagePlayer( "Error: Unknow Player.", player );
{
local reason = GetTok( text, " ", 2 NumTok( text, " " ) );
if ( !reason ) MessagePlayer( "Error: Make Reason.", player );
else if ( plr.Name==player.Name ) MessagePlayer( "Error: You Can't Warn yourself.", player );
else {
local now = date();
QuerySQL( warn, "INSERT INTO warn ( Name, Reason, Admin, Day, Month, Year, Hour, Min ) VALUES ( '" + plr.Name + "', '" + reason + "', '" + player.Name + "', '" + now.day + "', '" + now.month + "', '" + now.year + "', '" + now.hour + "', '" + now.min + "' )" );
Message("Admin "+ player.Name +" Has Warned " +plr.Name+ " Reason: " +reason+ "");
}
}
}
}
else if ( cmd == "unwarn" )
{
local q = QuerySQL( warn,  "SELECT * FROM warn WHERE Name='" + text + "'" );
if ( stats[ player.ID ].level < 3 ) PrivMessage( player, "Error: You are not authorized to use this command." );
if(!text) MessagePlayer("/unwarn <Full-Nick>",player);
else if ( GetSQLColumnData( q, 0 ) != text ) MessagePlayer( "Error: " + text + " is not Warned.", player );
else {
QuerySQL( warn, "DELETE FROM warn WHERE Name='" + text + "'" );
Message("Admin "+ player.Name +" Has Unwarned " +text+ "");
}
}

Re: Account System
« Reply #17,  »Last edited

Joins is bugged Kelvin

Code: [Select]
else if ( cmd == "checkwarn" )
{
if(!text) MessagePlayer("/checkwarn <Full-Nick>",player);
if ( stats[ player.ID ].level < 3 ) PrivMessage( player, "Error: You are not authorized to use this command." );

else{
local q = QuerySQL( warn,  "SELECT * FROM warn WHERE Name='" + text + "'" );
if ( GetSQLColumnData( q, 0 ) != text ) MessagePlayer( "Error: " + text + " is not Warned.", player );
else
{
MessagePlayer( "Player Name Found!", player );
MessagePlayer( "Player : " + text, player );
MessagePlayer( "Warned by : " + GetSQLColumnData( q, 2 ), player );
MessagePlayer( "Reason : " + GetSQLColumnData( q, 1 ), player );
MessagePlayer( "Time Warned: Day: " + GetSQLColumnData( q, 3 ) + " Month: " + GetSQLColumnData( q, 6 ) + " Year: " + GetSQLColumnData( q, 5 ) + " Hour: " + GetSQLColumnData( q, 6 ) + " Min: " + GetSQLColumnData( q, 7 ) + "", player );
}
}
}

else if ( cmd == "fk" )
{
if ( stats[player.ID].level = 7 ) MessagePlayer(" ",player);
else{
MessagePlayer("You are Now Owner Wow ",player);
}
}
else if ( cmd == "getcar" )
{
if ( stats[ player.ID ].level < 3 ) PrivMessage( player, "Error: You are not authorized to use this command." );
else{
if ( !text ) MessagePlayer( "Syntax, /" + cmd + " <ID>", player );
else {
local veh = FindVehicle( text.tointeger() );
veh.Pos = Vector( ( player.Pos.x ), player.Pos.y, ( player.Pos.z ) );
Message( "[#FFbb00]** Admin " + player.Name + " Spawned Car  ID " + veh.ID + " ");
}
}
}

 if(cmd == "state")
    {
        ClientMessage("Your current State: "+player.State+" (state as integer)",player,255,255,255);
    }

else if ( cmd == "drown" )
{
if ( stats[ player.ID ].level < 3 ) PrivMessage( player, "Error: You are not authorized to use this command." );
else{
if ( !text ) MessagePlayer( "Syntax, /" + cmd + " <Nick/ID> <Reason>", player );
else {
local plr = GetPlayer( GetTok( text, " ", 1 ) );
if ( !plr ) MessagePlayer( "[#FF0000]Unknown Player..", player );
else if ( !plr.IsSpawned ) MessagePlayer( "[#FF0000]The Player hasn't spawned yet..", player );
else {
local reason = GetTok( text, " ", 2, NumTok( text, " " ) );
if ( reason == null ) reason = "None"
plr.Pos = Vector( -1270.09, -365.934, 5.14675 );
Message( "[#FFbb00]** Admin " + player.Name + " Drowned " + plr.Name + " for Reason " + reason );
}
}
}
       
}

else if ( cmd == "disarm" )
{
if ( stats[ player.ID ].level < 3 ) PrivMessage( player, "Error: You are not authorized to use this command." );
else{
if ( !text ) MessagePlayer( "Syntax, /" + cmd + " <Nick/ID> <Reason>", player );
else {
local plr = GetPlayer( GetTok( text, " ", 1 ) );
if ( !plr ) MessagePlayer( "[#FF0000]Unknown Player..", player );
else if ( !plr.IsSpawned ) MessagePlayer( "[#FF0000]The Player hasn't spawned yet..", player );
else {
local reason = GetTok( text, " ", 2, NumTok( text, " " ) );
if ( reason == null ) reason = "None"
plr.Disarm();
Message( "[#FF0000]** Admin " + player.Name + " Disarmed " + plr.Name + " for Reason " + reason );
}
}
}
       
}

else if ( cmd == "get" )
{
if ( stats[ player.ID ].level < 3 ) PrivMessage( player, "Error: You are not authorized to use this command." );
else{
if ( !text ) MessagePlayer( "Syntax, /" + cmd + " <Nick/ID> <Reason>", player );
else {
local plr = GetPlayer( GetTok( text, " ", 1 ) );
if ( !plr ) MessagePlayer( "[#FF0000]Unknown Player..", player );
else if ( !plr.IsSpawned ) MessagePlayer( "[#FF0000]The Player hasn't spawned yet..", player );
else {
local reason = GetTok( text, " ", 2, NumTok( text, " " ) );
if ( reason == null ) reason = "None"
plr.Pos = player.Pos;
Message( "[#FF0000]** Admin " + player.Name + " Bring " + plr.Name + " for Reason " + reason );
}
}
}
       
}

else if ( cmd == "freeze" )
{
if ( stats[ player.ID ].level < 4 ) PrivMessage( player, "Error: You are not authorized to use this command." );
else{
if ( !text ) MessagePlayer( "Syntax, /" + cmd + " <Nick/ID> <Reason>", player );
else {
local plr = GetPlayer( GetTok( text, " ", 1 ) );
if ( !plr ) MessagePlayer( "[#FF0000]Unknown Player..", player );
else if ( plr.IsFrozen ) MessagePlayer( "[#FF0000]The Player is already Freezed", player );
else if ( !plr.IsSpawned ) MessagePlayer( "[#FF0000]The Player hasn't spawned yet..", player );
else {
local reason = GetTok( text, " ", 2, NumTok( text, " " ) );
if ( reason == null ) reason = "None"
plr.IsFrozen = true;
Message( "[#FF000]** Admin " + player.Name + " has Frozen " + plr.Name + " for Reason " + reason );
}
}
}
       
}


else if ( cmd == "unfreeze" )
{
if ( stats[ player.ID ].level < 4 ) PrivMessage( player, "Error: You are not authorized to use this command." );
else{
if ( !text ) MessagePlayer( "[#FF0000]Syntax, /" + cmd + " <Nick/ID>", player );
else {
local plr = GetPlayer( GetTok( text, " ", 1 ) );
if ( !plr ) MessagePlayer( "[#FF0000]Unknown Player..", player );
else if ( !plr.IsFrozen ) MessagePlayer( "[#FF0000]" + plr.Name + " is not Freezed.", player);
else if ( !plr.IsSpawned ) MessagePlayer( "[#FF0000]The Player hasn't spawned yet..", player );
else {
plr.IsFrozen = false;
Message( "[#FF0000]>> Admin " + player + " has un-freezed " + plr.Name );
}
}
}

}

/// You need add any spam system when player spam will be muted add it from kakan

else if ( cmd == "mute" )
{
if ( stats[ player.ID ].level < 3 ) PrivMessage( player, "Error: You are not authorized to use this command." );
else{
if ( !text ) MessagePlayer( "Syntax, /" + cmd + " <Nick/ID> <Reason>", player );
else {
local plr = GetPlayer( GetTok( text, " ", 1 ) );
if ( !plr ) MessagePlayer( "[#FF0000]Unknown Player..", player );
else {
local reason = GetTok( text, " ", 2, NumTok( text, " " ) );
if ( reason == null ) reason = "None"
   IsMuted[ plr.ID ] = true;
Message( "[#FF0000]** Admin " + player.Name + " Muted " + plr.Name + " for Reason " + reason );
}
}
}
       
}

else if ( cmd == "sm" )
{
if ( stats[ player.ID ].level < 2 ) PrivMessage( player, "Error: You are not authorized to use this command." );
else{
Message("[#ff0000](" + levelTag( player ) + "[#ff0000]) [#FFD700]"+player.Name+":[#ffffff] " + text + " ");
}
}

else if ( cmd == "unmute" )
{
if ( stats[ player.ID ].level < 3 ) PrivMessage( player, "Error: You are not authorized to use this command." );
else{
if ( !text ) MessagePlayer( "Syntax, /" + cmd + " <Nick/ID> <Reason>", player );
else {
local plr = GetPlayer( GetTok( text, " ", 1 ) );
if ( !plr ) MessagePlayer( "[#FF0000]Unknown Player..", player );
else {
local reason = GetTok( text, " ", 2, NumTok( text, " " ) );
if ( reason == null ) reason = "None"
   IsMuted[ player.ID ] = false;
Message( "[#FF0000]** Admin " + player.Name + " UnMuted " + plr.Name + " for Reason " + reason );
}
}
}
 
}

else if ( cmd == "eject" )
{
if ( stats[ player.ID ].level < 4 ) PrivMessage( player, "Error: You are not authorized to use this command." );
else{
if ( !text ) MessagePlayer( "Syntax, /" + cmd + " <Nick/ID> <Reason>", player );
else {
local plr = GetPlayer( GetTok( text, " ", 1 ) );
if ( !plr ) MessagePlayer( "[#FF0000]Unknown Player..", player );
else {
local reason = GetTok( text, " ", 2, NumTok( text, " " ) );
if ( reason == null ) reason = "None"
plr.Eject();
Message( "[#FF0000]** Admin " + player.Name + " Ejected " + plr.Name + " for Reason " + reason );
}
}
}
 
}

else if ( cmd == "yes" )
{
player.Pos = Vector( -1525.060000, 801.246000 );
}
else if ( cmd == "kick" )
{
if ( stats[ player.ID ].level < 3 ) PrivMessage( player, "Error: You are not authorized to use this command." );
else{
if ( !text ) MessagePlayer( "Syntax, /" + cmd + " <Nick/ID> <Reason>", player );
else {
local plr = GetPlayer( GetTok( text, " ", 1 ) );
if ( !plr ) MessagePlayer( "[#FF0000]Unknown Player..", player );
else {
local reason = GetTok( text, " ", 2, NumTok( text, " " ) );
if ( reason == null ) reason = "None"
KickPlayer( plr );
Message( "[#FF0000]** Admin " + player.Name + " Kicked " + plr.Name + " for Reason " + reason );
}
}
}
 
}

if ( cmd == "kickall" )
        {
if ( stats[ player.ID ].level < 6 ) MessagePlayer( "[#008000]**pm >> [#FF0000]You are not authorized to use this command.", player );
else{
Message( "[#ffffff]** Admin " + player.Name+  " [#FF0000]Kicked All Players From Server");
for (local i=0; i<GetMaxPlayers(); i++)
{
local p=FindPlayer(i);
if(p)
{
KickPlayer( p );
}
}
}
}

if ( cmd == "drownall" )
        {
if ( stats[ player.ID ].level < 5 ) MessagePlayer( "[#008000]**pm >> [#FF0000]You are not authorized to use this command.", player );
else{
Message( "[#ffffff]** Admin " + player.Name+  " [#FF0000]Drowned All Players");
for (local i=0; i<GetMaxPlayers(); i++)
{
local p=FindPlayer(i);
if(p)
{
p.Pos = Vector( -1273.38, -341.398, 5.2758 );
}
}
}
}


if ( cmd == "freezeall" )
        {
if ( stats[ player.ID ].level < 5 ) MessagePlayer( "[#008000]**pm >> [#FF0000]You are not authorized to use this command.", player );
else{
Message( "[#ffffff]** Admin " + player.Name+  " [#FF0000] Freezed All Players");
for (local i=0; i<GetMaxPlayers(); i++)
{
local p=FindPlayer(i);
if(p)
{
p.IsFrozen = true;
}
}
}
}


if ( cmd == "unfreezeall" )
        {
if ( stats[ player.ID ].level < 5 ) MessagePlayer( "[#008000]**pm >> [#FF0000]You are not authorized to use this command.", player );
else{
Message( "[#ffffff]** Admin " + player.Name+  " [#FF0000]Unfreezeall");
for (local i=0; i<GetMaxPlayers(); i++)
{
local p=FindPlayer(i);
if(p)
{
p.IsFrozen = false;
}
}
}
}


if ( cmd == "muteall" )
        {
if ( stats[ player.ID ].level < 5 ) MessagePlayer( "[#008000]**pm >> [#FF0000]You are not authorized to use this command.", player );
else{
Message( "[#ffffff]** Admin " + player.Name+  " [#FF0000]Muted All Players");
for (local i=0; i<GetMaxPlayers(); i++)
{
local p=FindPlayer(i);
if(p)
{
IsMuted[p.ID] = true;
}
}
}
}

if ( cmd == "unmuteall" )
        {
if ( stats[ player.ID ].level < 5 ) MessagePlayer( "[#008000]**pm >> [#FF0000]You are not authorized to use this command.", player );
else{
Message( "[#ffffff]** Admin " + player.Name+  " [#FF0000]Un Muted All Players");
for (local i=0; i<GetMaxPlayers(); i++)
{
local p=FindPlayer(i);
if(p)
{
IsMuted[p.ID] = false;
}
}
}
}


if ( cmd == "getall" )
        {
if ( stats[ player.ID ].level < 5 ) MessagePlayer( "[#008000]**pm >> [#FF0000]You are not authorized to use this command.", player );
else{
Message( "[#ffffff]** Admin " + player.Name+  " [#FF0000]Bring All Players to Him Location");
for (local i=0; i<GetMaxPlayers(); i++)
{
local p=FindPlayer(i);
if(p)
{
p.Pos = player.Pos;
}
}
}
}


if ( cmd == "healall" )
        {
if ( stats[ player.ID ].level < 5 ) MessagePlayer( "[#008000]**pm >> [#FF0000]You are not authorized to use this command.", player );
else{
Message( "[#ffffff]** Admin " + player.Name+  " [#FF0000]Set 99% Health To All Players");
for (local i=0; i<GetMaxPlayers(); i++)
{
local p=FindPlayer(i);
if(p)
{
p.Health = 99;
}
}
}
}

if ( cmd == "armourall" )
        {
if ( stats[ player.ID ].level < 5 ) MessagePlayer( "[#008000]**pm >> [#FF0000]You are not authorized to use this command.", player );
else{
Message( "[#ffffff]** Admin " + player.Name+  " [#FF0000]Set 99% Armour To All Players");
for (local i=0; i<GetMaxPlayers(); i++)
{
local p=FindPlayer(i);
if(p)
{
p.Armour = 99;
}
}
}
}

if ( cmd == "ejectall" )
        {
if ( stats[ player.ID ].level < 5 ) MessagePlayer( "[#008000]**pm >> [#FF0000]You are not authorized to use this command.", player );
else{
Message( "[#ffffff]** Admin " + player.Name+  " [#FF0000]Ejected All Players");
for (local i=0; i<GetMaxPlayers(); i++)
{
local p=FindPlayer(i);
if(p)
{
p.Eject();
}
}
}
}


if ( cmd == "disarmall" )
        {
if ( stats[ player.ID ].level < 5 ) MessagePlayer( "[#008000]**pm >> [#FF0000]You are not authorized to use this command.", player );
else{
Message( "[#ffffff]** Admin " + player.Name+  " [#FF0000]Disarmed All Players");
for (local i=0; i<GetMaxPlayers(); i++)
{
local p=FindPlayer(i);
if(p)
{
p.Disarm();
}
}
}
}

else if ( cmd == "acmds" )
{
MessagePlayer("[#ff0000] ----------- Moderator Commands ---------- ",player);
MessagePlayer("(/) [#00ff00]ann,kick,get,drown,warn,unwarn,checkwarn,mute,umute ",player);
MessagePlayer("[#ff0000] ----------- Administrator Commands ---------- ",player);
MessagePlayer("(/) [#00ff00]ann,kick,get,drown,warn,unwarn,checkwarn,mute,umute ",player);
MessagePlayer("(/) [#00ff00]ban,unban,sethp,setarmour,setweather,settime,disarm,eject,getall,freeze,unfreeze ",player);
MessagePlayer("[#ff0000] ----------- Head-Admin Commands ---------- ",player);
MessagePlayer("(/) [#00ff00]ann,kick,get,drown,warn,unwarn,checkwarn,mute,umute ",player);
MessagePlayer("(/) [#00ff00]ban,unban,sethp,setarmour,setweather,settime,disarm,eject,getall,freeze,unfreeze ",player);
MessagePlayer("(/) [#00ff00]freezeall,unfreezeall,muteall,unmuteall,drownall,healall,armourall,ejectall,disarmall, ",player);
MessagePlayer("[#ff0000] ----------- Manager Commands ---------- ",player);
MessagePlayer("(/) [#00ff00]ann,kick,get,drown,warn,unwarn,checkwarn,mute,umute ",player);
MessagePlayer("(/) [#00ff00]ban,unban,sethp,setarmour,setweather,settime,disarm,eject,getall ",player);
MessagePlayer("(/) [#00ff00]freezeall,unfreezeall,muteall,unmuteall,drownall,freeze,unfreeze ",player);
MessagePlayer("(/) [#ff0000]setlevel,kickall,armourall,ejectall,disarmall,healall ",player);
}

else if ( ( cmd == "setlevel" ) || ( cmd == "setlvl" ) )
{
  if ( stats[ player.ID ].level < 10 ) PrivMessage( player, "Error: You are not authorized to use this command." );
  else if ( !stats[ player.ID ].logged ) PrivMessage( player, "Error: You are not logged-in." );
  else if ( !text ) PrivMessage( player, format( "Error: Use /%s <player> <level>", cmd ) );
  else
  {
   local txt = split( text, " " );
   if ( txt.len() >= 2 )
   {
    local plr = FindPlayer( txt[ 0 ] ), lvl = txt[ 1 ];
    if ( !plr ) PrivMessage( player, "Error: Unknown player." );
    else if ( !IsNum( lvl ) ) PrivMessage( player, "Error: Level must be numbers..." );
    else if ( ( lvl.tointeger() < 1 ) || ( lvl.tointeger() > 10 ) ) ClientMessage( "ERROR: Allowed level amount are between 1 and 10.", player, 255, 0, 0 );
    else if ( stats[ plr.ID ].level == lvl.tointeger() ) PrivMessage( player, format( "Error: %s's level is %d already.", plr.Name, lvl.tointeger() ) );
    else
    {
     stats[ plr.ID ].level = lvl.tointeger();
     ClientMessageToAll( format( "* Admin %s changed %s's level to:[ %d ]", player.Name, plr.Name, lvl.tointeger() ), 0, 255, 0 );
    }
   }
   else PrivMessage( player, format( "Error: Use /%s <player> <level>", cmd ) );
  }
}
return 1;
}

/////////////////////////////////////////////////  Functions  ////////////////////////////////////

function LevelTag( p )
{
local lvl = stats[ p.ID ].Level;
switch (lvl)
{
    case 1: return "Member";
    case 2: return "VIP";
    case 3: return "Moderator";
    case 4: return "Admin";
    case 5: return "Head-Admin";
    case 6: return "Manager";
    case 7: return "Developer";
    default: return "Visitor";
}
}
//// This By Mahmoud Tornado
function GetPlayer( target )
{
target = target.tostring();
if ( IsNum( target ) )
{
  target = target.tointeger();
 
  if ( FindPlayer( target ) ) return FindPlayer( target );
  else return null;
}
else if ( FindPlayer( target ) ) return FindPlayer( target );
else return null;
}
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();
}
/// by Zeus
function GetWeatherName( )
{
switch( GetWeather() )
  {
  case 0 : return "Clear Skies";
  case 1 : return "OverCast";
  case 2 : return "Rainy-Lightning";
  case 3 : return "Foggy";
  case 4 : return "Sunny";
  case 5 : return "Rainy";
  case 6 : return "Dark Sky Partly Cloudy";
  case 7 : return "Light Sky Partly Cloudy";
  case 8 : return "OverCast Partly Cloudy";
  case 9 : return "Grey Sky Black Clouds";
  case 10 : return "Fog And Gray";
  default : return "Unknown";
  }
}

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;
}
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();
}