Author Topic: admin system for newbies  (Read 787 times)

mega mind

  • Newbie
  • *
  • Posts: 20
  • Karma: +1/-12
  • Developer of ( "Web-Net" ) search engine
    • View Profile
    • Web-Net
admin system for newbies
« on: April 03, 2018, 10:50:25 am »
i have seen many newbies trying to make a server but they donot have an admin system so heres a little snipper for you guyzz

Code: [Select]
/*top of script*/

const AdminPassword = "adminpassword"
class PlayerInfo
{
admin = false;
}
//=================================

/*onscriptload*/

pinfo <- array(GetMaxPlayers(), null);
//===================================


/*anywhere*/

function PlayerIsAdmin(player)
{
 if(pinfo[pPlayer.ID].admin== true) return 1;
 else return 0;
}
//========================================

/*playerjoin*/

pinfo[pPlayer.ID] = PlayerInfo();
//==========================================



/*playercmd*/
else if(szCommand == "admins")
{
 {
  if ((  pPlayer.Name == "admin" ) || (  pPlayer.Name == "admin1" ))
{
 //MessagePlayer( "[#00ff00]Admins are on Duty [ " + pPlayer.Name + " ] " , pPlayer );
 Message( "Admins are on Duty [ " + pPlayer.Name + " ] ", 0, 255, 0 );
 }
else
{
MessagePlayer( "[#00ff00]Admins available [#00ffff]"+pinfo[pPlayer.ID].admin+"" , pPlayer );
}
}
}

else if (szCommand == "admin")
 {
 if(!szArgs) MessagePlayer( "-> Error: [#ffd700]Please type /admin <admin password>", pPlayer,255,0,102);
 else if ( szArgs != AdminPassword ) MessagePlayer( "-> Error: [#ffd700]Invalid PASSWORD.", pPlayer,255,0,102);
 else
 {
 MessagePlayer( "-> [#00ffff]Welcome "+pPlayer.Name+". You are logged as admin in server.", pPlayer,255,0,102); pinfo[pPlayer.ID].admin = true;
 }
 }

 else if ( szCommand == "ban" )
    {
        if ( (  pPlayer.Name == "admin" ) || (  pPlayer.Name == "admin1" ) )
        {
            if ( szArgs )
            {
           local plr = FindPlayer( szArgs );
               if ( plr )
               {
               BanPlayer( plr );
               }
               else MessagePlayer( "[#00ff00]Invalid Player " , pPlayer );
            }
            else MessagePlayer( "[#0f00f0]Type /ban <player> " , pPlayer );
        }
        else MessagePlayer( "[#F02F0F] Your are not admin. " , pPlayer )
    }

else if ( szCommand == "kick" )
    {
        if ( (  pPlayer.Name == "admin" ) || (  pPlayer.Name == "admin1" ) )
        {
            if ( szArgs )
            {
           local plr = FindPlayer( szArgs );
               if ( plr )
               {
               KickPlayer( plr );
               }
               else MessagePlayer( "[#00ff00]Invalid Player " , pPlayer );
            }
            else MessagePlayer( "[#0f00f0]Type /kick <player> " , pPlayer );
        }
        else MessagePlayer( "[#F02F0F] Your are not admin. " , pPlayer )
    }

   else if ( szCommand == "settime" )
     {
        if ( (  pPlayer.Name == "admin" ) || (  pPlayer.Name == "admin1" ) ){
          local aTime = split( szArgs, " " );
          local szHour = aTime[0], szMin = aTime[1];
         
          SetTime( szHour.tointeger(), szMin.tointeger() );
     }
}

    else if (szCommand == "setweather" )
     {
if ( (  pPlayer.Name == "admin" ) || (  pPlayer.Name == "admin1" ) ){
          SetWeather( szArgs.tointeger() );
     }
}

else if ( szCommand == "ann" )
{
if ( (  pPlayer.Name == "admin" ) || (  pPlayer.Name == "admin1" ) ){
if ( szArgs ) BigMessage( szArgs, 5000, 1 );
}
}
// ==================================

 

© Liberty Unleashed Team.