Guidance on returning to Squirrel

Started by Mötley, Jun 20, 2016, 10:04 PM

Previous topic - Next topic

Mötley

**So this move has been a B****

I put my pc on the floor as I knew my scripting has possibly gotten rusty..
So I started to the think of what I should do to get back used to Squirrel scripting.

So far I am creating an extremely simple admin server.
There is no account system.
The admin system is held within an array and the admin must match the password within that array,
*There is other stuff in that system of arrays :P

Once I get it where I want it, I plan to create my own saving system with wb+ but expanded in squirrel (not a module),.
So far this is the easiest method to help me get back into squirrel scripting so any pointers would be liked...

DizzasTeR

_Admins <- [
    "Your_Admin_Pass"
];

local Admin_Password = _Admins[0];

function onPlayerCommand( player, command, arguments ) {
    if( command == "admin" ) {
        if( !text ) return;
        else if( text != Admin_Password ) return MessagePlayer( "Wrong password KTHXBYE", player );
        MessagePlayer( "You typed the correct pass, you're admin, but too bad there is nothing you can do!", player );
        MessagePlayer( "KTHXBYE", player );
        print( player.Name + " logged in as Admin" );
    }
}

Mötley

#2
Interesting Method.

I will share Mine at another time as I just started working on it,.

I plan on possibly doing something similar to http://forum.liberty-unleashed.co.uk/index.php/topic,2229.0.html
Not sure though..

*I'm actually expanding your method now as I did not like were mine was leading

@Doom_Kill3R so I basically got it down to an extent. I have made sure to not look at any scripts of mine, But now I noticed my main flaws and that is Validation checks(Meh I was so good at validations)

So now I will finnaly begen to read over all of my many unfinnished scripts as well finnished to re-impliment into my mind on correct/valid scripting

Example from a hash test server I talked about in the past
*The code moved around I'm not going to fix it its just an example

/*Level system is only 1 - 10*/
enum AdminFlagTypes{
Mute = 4,
Unmute = 4,
Kick = 5,
Ban = 5,
Unban = 5
Money = 10,
Setlevel = 10,
Goto = 5,
Sub = 10
}

function onPlayerCommand( player, cmd, text ) {
       
        local Level = Account[player.ID].Level; 
if (cmd == "setlevel") {
  if ((Level < AdminFlagTypes.Setlevel)) {
        UnknownCommand(player);
        return true;
      }

      if (!text) {
        Language("English", "Set admin level: /setadmin [id] [level]", player, Red );
Language("Spanish", "Establecer el nivel de administrador: / setadmin [id] [nivel]", player, Red );
        return true;
      }

      local params = split(text, " ");

      if (params.len() < 2) {
        Language("English", "Set admin level: /setadmin [id] [level]", player, Red );
Language("Spanish", "Establecer el nivel de administrador: / setadmin [id] [nivel]", player, Red );
        return true;
      }

      if (!IsNum(params[0]) || !IsNum(params[1])) {
        Language("English", "Set admin level: /setadmin [id] [level]", player, Red );
Language("Spanish", "Establecer el nivel de administrador: / setadmin [id] [nivel]", player, Red );
        return true;
      }
   
      local plr = FindPlayer(params[0].tointeger());
      local level = params[1].tointeger();
   
      if (!plr) {
        Language("English", "Set admin level: /setadmin [id] [level]", player, Red );
Language("Spanish", "Establecer el nivel de administrador: / setadmin [id] [nivel]", player, Red );
        return true;
      }

      if (level < 1 || level > 10) {
   Language("English", "Set admin level: /setadmin [id] [level]", player, Red );
   Language("Spanish", "Establecer el nivel de administrador: / setadmin [id] [nivel]", player, Red );
        return true;
      }

      Language("English", "Administrator " + player.Name + " has set " + plr.Name + " admin level", player, Green );
  Language("Spanish", "Administrador " + player.Name + " se ajuste " + plr.Name + " nivel de administracion", player, Green );


      Account[plr.ID].Level = level;
  HAdd( "HSH_Level", plr + " Level", level );
   
      return true;
}
   
UnknownCommand(player);
 
    return false;
}

If you have other Idea's on what I should refresh my memory on I would appreciate that,,.

EK.IceFlake