Page 1 of 1

GM Command Script Explaination (As of rev4322)

Posted: Sat Dec 28, 2013 7:23 pm
by atom0s
Revision information:
https://code.google.com/p/onetimexi/sou ... ail?r=4322

I have decided to refactor / recode the entire command handler to be more dynamic last night.
That being said, the command handler no longer requires the commands.conf to define the GM commands for DSP.
Instead, all commands that are found in the scripts/commands folder are automatically loaded/used when requested.

This allows GMs to add and remove commands during runtime of the server without having to restart the server or edit the commands.conf file at all.

New File Format
Instead of relying on the commands.conf file to store the permission level and parameter types for each command, the command files now have this stored within them.
A new command file has this format:

Code: Select all

---------------------------------------------------------------------------------------------------
-- func: addallspells
-- auth: <Unknown> :: Modded by atom0s.
-- desc: Adds all valid spells to the given target. If no target; then to the current player.
---------------------------------------------------------------------------------------------------

cmdprops =
{
    permission = 1,
    parameters = "s"
};

function onTrigger(player, target)
    if (target == nil) then
        player:addAllSpells();
    else
        local targ = GetPlayerByName(target);
        if (targ == nil) then
            player:PrintToPlayer(string.format( "Player named '%s' not found!", target ));
        else
            targ:addAllSpells();
        end
    end
end
Each command file has a table that lists its information: cmdprops

cmdprops holds, as of this check-in, two values:
- permission = The GM level required to use this command.
- parameters = The parameters to be passed to this command. (i = integer, d= float, s = string)

onTrigger
The onTrigger command has not changed at all. This function is still invoked in the same manner and the first argument passed to it is always the player entity that invoked the command.
Each argument after that is based on what you define in the parameters field of the cmdprops table.

Keep in mind; the command handler is not responsible for making sure that all arguments are pushed properly.
The command line passed from the players input (in chat) to the script is not guaranteed to contain all arguments your script requires.
You should always perform checks and validation on each of your arguments to ensure everything is valid. Not doing so can lead to crashes as well as debug breaks!

Re: GM Command Script Explaination (As of rev4322)

Posted: Mon Dec 30, 2013 3:06 pm
by Ayame
i'm getting this error on server startup and the gm command are not working
I have set my char on gm level 3 :(

Re: GM Command Script Explaination (As of rev4322)

Posted: Mon Dec 30, 2013 3:10 pm
by n00bgames
Ayame wrote:i'm getting this error on server startup and the gm command are not working
I have set my char on gm level 3 :(
Did you recompile/rebuild your DS-Game-server.exe after the svn update?

Re: GM Command Script Explaination (As of rev4322)

Posted: Mon Dec 30, 2013 5:49 pm
by Ayame
ok fix it by wiping the database and redoing everything thanks!

Re: GM Command Script Explaination (As of rev4322)

Posted: Mon Dec 30, 2013 9:16 pm
by atom0s
You need to make sure that anytime you update to a new revision:
A. If the updates include changes to a .h or .cpp file, you MUST recompile your server binaries. (Game, Login and Search server.)
B. If the updates include changes to a .sql file, you MUST update that SQL table with the new changes.

Re: GM Command Script Explaination (As of rev4322)

Posted: Mon Dec 30, 2013 9:25 pm
by kjLotus
atom0s wrote:(Game, Login and Search server.)
ya like anyone ever changes the login or search server

Re: GM Command Script Explaination (As of rev4322)

Posted: Mon Dec 30, 2013 9:33 pm
by atom0s
kjLotus wrote:
atom0s wrote:(Game, Login and Search server.)
ya like anyone ever changes the login or search server
Once in a blue moon the login server sees a change. Search not often, but its better to just make it a habbit of recompiling everything just in case. Especially for those that are not too savvy with coding/compiling and may run into issues if they don't.

Re: GM Command Script Explaination (As of rev4322)

Posted: Tue Dec 31, 2013 11:36 am
by whasf
kjLotus wrote:
atom0s wrote:(Game, Login and Search server.)
ya like anyone ever changes the login or search server

I have some changes ready to go for the Search Server, but I need some help getting the task manager functioning...