login
April 27, 2024, 12:30:53 pm

Author Topic: ( Simple ) Admin System.  (Read 479 times)

0 Members and 1 Guest are viewing this topic.

GiTo

  • Regular
  • ***
  • Posts: 78
  • Country: pk
    • View Profile
( Simple ) Admin System.
« on: July 11, 2021, 06:28:05 am »
----------///---LEVEL SYSTEM---\\\----------

Player Class
Code: [Select]
class PlayerClass
{
    Level = 0;
}

Creating Database
Code: [Select]
Admin <- ConnectSQL("Level.db");
QuerySQL(Admin, "create table if not exists Level ( Name Text ,Level NUMERIC DEFAULT 0) ");

Functions
Code: [Select]
function AdminInfo(player)
{
    local q = QuerySQL(Admin, "SELECT * FROM Level WHERE Name = '" + escapeSQLString(player.Name) + "'");
    if (q)
    {
        stats[ player.ID ].Level = GetSQLColumnData(q, 1);
    }
    else QuerySQL( Admin, "INSERT INTO Level ( Name, Level ) VALUES ( '" + escapeSQLString(player.Name) + "', ' 0 ' )" );
}

function SaveAdmin(player)
{
    QuerySQL( Admin, "UPDATE Level SET Level='"+ stats[ player.ID ].Level +"' WHERE Name = '"+player.Name+"'");
}

OnPlayer Join
Code: [Select]
AdminInfo();

OnPlayer Part
Code: [Select]
SaveAdmin();
Set Level Command
Code: [Select]
   else if ( ( cmd == "setlevel" ) || ( cmd == "setlvl" ) )
{
if ( stats[ player.ID ].Level < 5 ) MessagePlayer("[#ff0000]Error: [#ffffff]You don't have permission to use this command.",player);
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 ) ) ClientMessage( player, "Error: Level must be in numbers...",player, 255, 0, 0 );
else if ( ( lvl.tointeger() < 1 ) || ( lvl.tointeger() > 7 ) ) ClientMessage( "ERROR: Allowed Level amount are between 1 and 7.", 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();
Message( "[#ffffff]"+player.Name+" [#25AAAA]changed the level of[#ffffff] "+plr.Name+"[#25AAAA] to [#ffffff]["+lvl.tointeger()+"].");
                }
}
else PrivMessage( player, format( "Error: Usage /%s <player> <Level>", cmd ) );
}
return 0;
}

Example command
Code: [Select]
else if ( cmd=="assrocket")
{
if(stats[player.ID].Level < 2) return MessagePlayer("[#ff0000]Error: [#ffffff]You don't have permission to use this command.",player);
else
{
if (!text) MessagePlayer("[#51FF06]Usage :[#FFFFFF] /assrocket <Name/ID>",player);
else
{
local plr = FindPlayer(text);
plr.Pos = player.Pos;
Message("[#ffffff]"+player.Name+ "[#25AAAA] has bombed [#ffffff]" +plr.Name);
CreateExplosion( 1, 1,plr.Pos.x -3 , plr.Pos.y -5, plr.Pos.z, -1, true );
CreateExplosion( 1, 2,plr.Pos.x -3, plr.Pos.y -5, plr.Pos.z, -1, true );
CreateExplosion( 1, 3,plr.Pos.x -3, plr.Pos.y -5, plr.Pos.z, -1, true );
CreateExplosion( 1, 4,plr.Pos.x -3 , plr.Pos.y -5, plr.Pos.z, -1, true );
}
}
return 0;
}
« Last Edit: July 18, 2021, 08:30:36 am by GiTo »
Useful Useful x 1 (list)
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor

What happens when the poison expires?

SMD

  • Vice Underdog
  • Crazy Man
  • *
  • Posts: 1182
  • Country: pk
  • Don't teach Father how to make children!Lol Movies
    • View Profile
Re: Simplest Admin-/-Level System.
« Reply #1 on: July 12, 2021, 06:30:50 am »
Xmair you fucking gay you know that why i called you gay
Funny Funny x 3 (list)
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor



Credits : KocKex

mairee

  • Vice Underdog
  • Crazy Man
  • *
  • *
  • *
  • *
  • *
  • Posts: 1040
  • Country: pk
    • View Profile
Re: Simplest Admin-/-Level System.
« Reply #2 on: July 12, 2021, 10:33:35 am »
Xmair you fucking gay you know that why i called you gay
wtf
Funny Funny x 1 (list)
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor

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

Inferno69

  • Vice Underdog
  • Crazy Man
  • *
  • *
  • *
  • Posts: 761
  • Country: pk
  • 👀
    • View Profile
    • VFS
Re: Simplest Admin-/-Level System.
« Reply #3 on: July 12, 2021, 07:05:57 pm »
Xmair you fucking gay you know that why i called you gay
/assrocket SMD
Funny Funny x 1 (list)
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor





Roystang

  • Vice Underdog
  • Crazy Man
  • *
  • *
  • *
  • *
  • *
  • Posts: 1406
  • Country: 00
  • rerere
    • View Profile
Re: Simplest Admin-/-Level System.
« Reply #4 on: July 12, 2021, 08:40:05 pm »
/kick all
Funny Funny x 1 (list)
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor



VCDC 6 Admin/Designer, VW8 Designer, VW9 Mod/Designer, VCDM Developer, VCCNR Admin, EG-A.D Moderator, RTV/TDW Admin