GM Command Script Explaination (As of rev4322)

Post Reply
User avatar
atom0s
Developer
Posts: 537
Joined: Thu Oct 25, 2012 9:52 am

GM Command Script Explaination (As of rev4322)

Post by atom0s » Sat Dec 28, 2013 7:23 pm

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!

Ayame
Posts: 129
Joined: Sat Jul 21, 2012 10:35 pm

Re: GM Command Script Explaination (As of rev4322)

Post by Ayame » Mon Dec 30, 2013 3:06 pm

i'm getting this error on server startup and the gm command are not working
I have set my char on gm level 3 :(
Attachments
Capture.PNG

n00bgames
Posts: 52
Joined: Tue Dec 24, 2013 12:29 pm

Re: GM Command Script Explaination (As of rev4322)

Post by n00bgames » Mon Dec 30, 2013 3:10 pm

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?

Ayame
Posts: 129
Joined: Sat Jul 21, 2012 10:35 pm

Re: GM Command Script Explaination (As of rev4322)

Post by Ayame » Mon Dec 30, 2013 5:49 pm

ok fix it by wiping the database and redoing everything thanks!

User avatar
atom0s
Developer
Posts: 537
Joined: Thu Oct 25, 2012 9:52 am

Re: GM Command Script Explaination (As of rev4322)

Post by atom0s » Mon Dec 30, 2013 9:16 pm

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.

User avatar
kjLotus
Special Guest
Posts: 1813
Joined: Sun Jul 22, 2012 2:16 pm

Re: GM Command Script Explaination (As of rev4322)

Post by kjLotus » Mon Dec 30, 2013 9:25 pm

atom0s wrote:(Game, Login and Search server.)
ya like anyone ever changes the login or search server

User avatar
atom0s
Developer
Posts: 537
Joined: Thu Oct 25, 2012 9:52 am

Re: GM Command Script Explaination (As of rev4322)

Post by atom0s » Mon Dec 30, 2013 9:33 pm

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.

User avatar
whasf
Site Admin
Posts: 1312
Joined: Thu Jul 19, 2012 9:11 pm

Re: GM Command Script Explaination (As of rev4322)

Post by whasf » Tue Dec 31, 2013 11:36 am

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...
-- Whasf

Post Reply