Chaos Project

RPG Maker => RPG Maker Scripts => Topic started by: ShadowIce on January 19, 2012, 12:08:38 pm

Title: Need help with levelup command - already started coding it...
Post by: ShadowIce on January 19, 2012, 12:08:38 pm
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! :)
Title: Re: Need help with levelup command - already started coding it...
Post by: Holyrapid on January 19, 2012, 12:28:51 pm
Put that code inside code tags, and then try again...
Title: Re: Need help with levelup command - already started coding it...
Post by: ShadowIce on January 19, 2012, 12:40:43 pm
There...
Title: Re: Need help with levelup command - already started coding it...
Post by: ForeverZer0 on January 19, 2012, 06:37:15 pm
Now, "there".

You need to make it presentable if you expect anybody to even look at it close enough to help.
Title: Re: Need help with levelup command - already started coding it...
Post by: ShadowIce on January 20, 2012, 09:35:44 am
for god sake, it IS presentable! O_O
Title: Re: Need help with levelup command - already started coding it...
Post by: ForeverZer0 on January 20, 2012, 09:53:14 am
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.
Title: Re: Need help with levelup command - already started coding it...
Post by: Blizzard on January 20, 2012, 10:00:10 am
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.