Need help with levelup command - already started coding it...

Started by ShadowIce, January 19, 2012, 12:08:38 pm

Previous topic - Next topic

ShadowIce

Hi all, I started work on an admin-only levelup command, to levelup whatever player the admin chooses, with a slash command.


I made some changes to the client's Ruby script as well as some changes to a few of the server files.

Client Ruby Files:


I added the following command module command(s) (levelup) to the (RMX-OS) Script:
 COMMANDS[GROUP_ADMIN] = ['admin', 'levelup']


In the "Descriptions" part of the module, under "# Admin Commands", I added the following command(s) to the (RMX-OS) Script:
DESCRIPTIONS['levelup']   = 'Levels up a player by X levels'


I added the following command(s) to the parameters module to the (RMX-OS) Script:
PARAMETERS['levelup']   = 'USERNAME LEVEL'


In the definition "check_admin_commands(message)", I added the "when" command(s):
when /\A\/levelup (\S+) (\S+)\Z/ # levelup a player
       command_user_levelup($1, $2)
       return true


I added the following def command(s) to the (RMX-OS) Script:
    #--------------------------------------------------------------------------
   # Executes chat command for usergroup change.
   #  username - username of the player
   #  level    - new user level
   #--------------------------------------------------------------------------
   
   def command_user_levelup(username, level)
     self.send("LVL#[username]\lu#[level]")
   end



Server Ruby Files:
I modified the following files:

Client.rb
Action_Handler3.rb


Inside Action_Handler3.rb, I added the "def":
"try_user_levelup(username, level)"


(The SQL command for try_user_levelup(username, level), is:
check = RMXOS.server.sql.query("SELECT username, level FROM users WHERE username = '#{RMXOS.fix_string(username)}' AND level = '#{RMXOS.fix_string(level)}'")



Inside Client.rb, I added the "when" command:
"when /\LVL(.+)\t(.+)/ # change player level"


I also updated the SQL file:
I added:

" `level` int(10) NOT NULL default 1, ", 


to the CREATE TABLE `users` declaration


Here is the WHOLE project with modified files :

http://www.mediafire.com/?vllcbzpi3t49b1i


Thanks for the help! :)

Holyrapid



ForeverZer0

Now, "there".

You need to make it presentable if you expect anybody to even look at it close enough to help.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

ShadowIce


ForeverZer0

It is now that I did I was nice enough to fix it for you.
Mixing code and instructions together in code brackets in one large run-on is not, at least most people's opinion. Its just a suggestion, and I was trying to do something nice for you. Either way, lets not let the topic become a discussion of proper formatting of forum posts.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Blizzard

You have a shitload a mistakes there.

1. IDK what \lu is supposed to do for you, but RMX-OS uses the tab character (\t) to split command parameters.
2. #[username] is wrong, it's used like #{username}. :facepalm:
3. The level is not an attribute in the users or user_data table. Levels are defined in the save data. If you manually add a level attribute, it won't do anything real in the game. The actual save data is still unaffected.
4. (.+) is used for any character, (\S+) is used for non-white space characters. Your code is inconsistent.
5. Even if you change the save data directly, it will be overwritten if the played is currently connected to the game.
6. Actually you would be better of changing the level of a character on the map while he's online rather than going into the database and bothering with messing around with the save data.

I suggest you turn on message logging in the config file to be able to track what the server receives and processes.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.