Skip to content
Permalink
Browse files
Merge pull request #457 from rathena/feature/script_engine_upgrade
Script Engine Upgrade
* More information here: https://rathena.org/board/topic/102946-script-engine-upgrade/
  • Loading branch information
aleos89 committed Aug 31, 2015
2 parents 5c9472d + 3452b93 commit 6295c77d393555fe5a366f092a75f4cf0d2de933
@@ -80,9 +80,12 @@ mysql_reconnect_count: 1

// Login Database Tables
login_server_account_db: login
login_server_accreg_db: global_reg_value
ipban_table: ipbanlist

// Shared
global_acc_reg_num_table: global_acc_reg_num
global_acc_reg_str_table: global_acc_reg_str

// Char Database Tables
char_db: char
hotkey_db: hotkey
@@ -91,7 +94,6 @@ cart_db: cart_inventory
inventory_db: inventory
charlog_db: charlog
storage_db: storage
reg_db: global_reg_value
skill_db: skill
interlog_db: interlog
memo_db: memo
@@ -117,6 +119,10 @@ elemental_db: elemental
ragsrvinfo_db: ragsrvinfo
skillcooldown_db: skillcooldown
bonus_script_db: bonus_script
acc_reg_num_table: acc_reg_num
acc_reg_str_table: acc_reg_str
char_reg_str_table: char_reg_str
char_reg_num_table: char_reg_num

// Map Database Tables
buyingstore_db: buyingstores
@@ -135,7 +141,7 @@ mob_skill_db_db: mob_skill_db
mob_skill_db_re_db: mob_skill_db_re
mob_skill_db2_db: mob_skill_db2
//mob_skill_db2_db: mob_skill_db2_re
mapreg_db: mapreg
mapreg_table: mapreg
vending_db: vendings
vending_items_db: vending_items
market_table: market
@@ -3,7 +3,7 @@
//===== By: ==================================================
//= rAthena Dev Team
//===== Last Updated: ========================================
//= 20140313
//= 20150610
//===== Description: =========================================
//= A reference manual for the rAthena scripting language.
//= Commands are sorted depending on their functionality.
@@ -616,6 +616,8 @@ same name. You can tell between the specific variables of an array with an

<variable name>[<array index>]

All variable types can be used as arrays.

Variables stored in this way, inside an array, are also called 'array elements'.
Arrays are specifically useful for storing a set of similar data (like several
item IDs for example) and then looping through it. You can address any array
@@ -631,8 +633,9 @@ value from an another array) to get at an array value:

This will make @arrayofnumbers[100] equal to 10.

Notice that index numbering always starts with 0. Arrays cannot hold more than
128 variables. (So the last one can't have a number higher than 127)
Index numbering always starts with 0 and arrays can hold over 2 billion
variables. As such, the (guaranteed) allowed values for indices are in the
range 0 ~ 2147483647.

And array indexes probably can't be negative. Nobody tested what happens when
you try to get a negatively numbered variable from an array, but it's not going
@@ -644,41 +647,6 @@ Arrays can naturally store strings:
the '$', normally denoting a string variable, before the square brackets that
denotes an array index.

Resume of the allowed variable and array scopes
-----------------------------------------------

+==========+======+=======+
|VarType | Norm | Array |
+==========+======+=======+
|$Str$ | OK! | OK! |
+----------+------+-------+
|$@Str$ | OK! | OK! |
+----------+------+-------+
|@Str$ | OK! | OK! |
+----------+------+-------+
|#Str$ | OK! | FAIL! |
+----------+------+-------+
|Str$ | OK! | FAIL! |
+----------+------+-------+
|$Int | OK! | OK! |
+----------+------+-------+
|$@Int | OK! | OK! |
+----------+------+-------+
|@Int | OK! | OK! |
+----------+------+-------+
|#Int | OK! | FAIL! |
+----------+------+-------+
|Int | OK! | FAIL! |
+----------+------+-------+
|.Str$ | OK! | OK! |
+----------+------+-------+
|.Int | OK! | OK! |
+----------+------+-------+
|.@Str$ | OK! | OK! |
+----------+------+-------+
|.@Int | OK! | OK! |
+----------+------+-------+

Variable References
-------------------

@@ -991,6 +959,7 @@ On<label name>:
These special labels are used with Mob scripts mostly, and script commands
that requires you to point/link a command to a mob or another NPC, giving a label
name to start from. The label name can be any of your liking, but must be
started with "On".

Example:

@@ -2167,7 +2136,7 @@ example:

setarray @array[0],200,200,200;
setarray @array[1],300,150;

will produce:

@array[0]=200
@@ -2200,7 +2169,7 @@ some cases invaluable.
setarray @array[0], 100, 200, 300, 400, 500, 600;
// So we have made @array[]
copyarray @array2[0],@array[2],2;

// Now, @array2[0] will be equal to @array[2] (300) and
// @array2[1] will be equal to @array[3].

@@ -2274,9 +2243,9 @@ Whatever it returns is determined by type.

*getarraysize(<array name>)

This function returns the number of values that are contained inside the
specified array. Notice that zeros and empty strings at the end of this array
are not counted towards this number.
This function returns highest index of the array that is filled.
Notice that zeros and empty strings at the end of this array are not
counted towards this number.

For example:

@@ -2287,8 +2256,8 @@ This will make @arraysize == 6. But if you try this:

setarray @array[0], 100, 200, 300, 400, 500, 600, 0;
set @arraysize,getarraysize(@array);
@arraysize will still equal 6, even though you've set 7 values.

@arraysize will still equal 6, even though you've set 7 values.

---------------------------------------

@@ -55,7 +55,7 @@ function Chk;
mes "You've started a mission";
mes "on another character.";
if (!@hm_char_del_check) { // check for deleted character
query_sql("SELECT 1 FROM `global_reg_value` WHERE `str` = 'Mission0' AND `char_id` IN(SELECT `char_id` FROM `char` WHERE `account_id` = " + getcharid(3) + ")", .@i);
query_sql("SELECT 1 FROM `char_reg_num` WHERE `key` = 'Mission0' AND `char_id` IN(SELECT `char_id` FROM `char` WHERE `account_id` = " + getcharid(3) + ")", .@i);
if (!.@i) {
next;
mes "[Hunting Missions]";
@@ -146,7 +146,7 @@ function Chk;
case 6:
mes "[Hunting Missions]";
mes "The top hunters are:";
query_sql("SELECT char_id AS id, (SELECT `name` FROM `char` WHERE char_id = id),`value` FROM `global_reg_value` WHERE str = 'Mission_Total' ORDER BY CAST(`value` AS SIGNED) DESC LIMIT 5", .@id, .@name$, .@val);
query_sql("SELECT char_id AS id, (SELECT `name` FROM `char` WHERE char_id = id),`value` FROM `char_reg_num` WHERE `key` = 'Mission_Total' ORDER BY CAST(`value` AS SIGNED) DESC LIMIT 5", .@id, .@name$, .@val);
for (.@i = 0; .@i < 5; .@i++)
mes " [Rank " + (.@i+1) + "] " + ((.@name$[.@i] == "") ? "^777777none" : "^0055FF" + .@name$[.@i]+"^000000 : ^FF0000" + .@val[.@i] + " pt.") + "^000000";
close;
@@ -207,9 +207,9 @@ Mission_Status:
#Mission_Delay = gettimetick(2) + (.Delay * 3600);
Mission_Total++;
if (Mission_Total == 1)
query_sql("INSERT INTO `global_reg_value` (`char_id`,`str`,`value`,`type`,`account_id`) VALUES (" + getcharid(0) + ",'Mission_Total','1',3,0)");
query_sql("INSERT INTO `char_reg_num` (`char_id`,`key`,`index`,`value`) VALUES (" + getcharid(0) + ",'Mission_Total','0',1)");
else
query_sql("UPDATE `global_reg_value` SET `value` = " + Mission_Total + " WHERE char_id = " + getcharid(0) + " AND `str` = 'Mission_Total'");
query_sql("UPDATE `char_reg_num` SET `value` = " + Mission_Total + " WHERE `char_id` = " + getcharid(0) + " AND `key` = 'Mission_Total'");
close;

Mission_Info:
@@ -1,3 +1,28 @@
--
-- Table structure for table `acc_reg_num`
--

CREATE TABLE IF NOT EXISTS `acc_reg_num` (
`account_id` int(11) unsigned NOT NULL default '0',
`key` varchar(32) binary NOT NULL default '',
`index` int(11) unsigned NOT NULL default '0',
`value` int(11) NOT NULL default '0',
PRIMARY KEY (`account_id`,`key`,`index`),
KEY `account_id` (`account_id`)
) ENGINE=MyISAM;

--
-- Table structure for table `acc_reg_str`
--

CREATE TABLE IF NOT EXISTS `acc_reg_str` (
`account_id` int(11) unsigned NOT NULL default '0',
`key` varchar(32) binary NOT NULL default '',
`index` int(11) unsigned NOT NULL default '0',
`value` varchar(254) NOT NULL default '0',
PRIMARY KEY (`account_id`,`key`,`index`),
KEY `account_id` (`account_id`)
) ENGINE=MyISAM;

--
-- Table structure for table `skillcooldown`
@@ -135,6 +160,32 @@ CREATE TABLE IF NOT EXISTS `char` (
KEY `online` (`online`)
) ENGINE=MyISAM AUTO_INCREMENT=150000;

--
-- Table structure for table `char_reg_num`
--

CREATE TABLE IF NOT EXISTS `char_reg_num` (
`char_id` int(11) unsigned NOT NULL default '0',
`key` varchar(32) binary NOT NULL default '',
`index` int(11) unsigned NOT NULL default '0',
`value` int(11) NOT NULL default '0',
PRIMARY KEY (`char_id`,`key`,`index`),
KEY `char_id` (`char_id`)
) ENGINE=MyISAM;

--
-- Table structure for table `char_reg_str`
--

CREATE TABLE IF NOT EXISTS `char_reg_str` (
`char_id` int(11) unsigned NOT NULL default '0',
`key` varchar(32) binary NOT NULL default '',
`index` int(11) unsigned NOT NULL default '0',
`value` varchar(254) NOT NULL default '0',
PRIMARY KEY (`char_id`,`key`,`index`),
KEY `char_id` (`char_id`)
) ENGINE=MyISAM;

--
-- Table structure for table `charlog`
--
@@ -205,16 +256,28 @@ CREATE TABLE IF NOT EXISTS `hotkey` (
) ENGINE=MyISAM;

--
-- Table structure for table `global_reg_value`
-- Table structure for table `global_acc_reg_num`
--

CREATE TABLE IF NOT EXISTS `global_reg_value` (
`char_id` int(11) unsigned NOT NULL default '0',
`str` varchar(255) NOT NULL default '',
`value` varchar(255) NOT NULL default '0',
`type` tinyint(1) NOT NULL default '3',
CREATE TABLE IF NOT EXISTS `global_acc_reg_num` (
`account_id` int(11) unsigned NOT NULL default '0',
`key` varchar(32) binary NOT NULL default '',
`index` int(11) unsigned NOT NULL default '0',
`value` int(11) NOT NULL default '0',
PRIMARY KEY (`account_id`,`key`,`index`),
KEY `account_id` (`account_id`)
) ENGINE=MyISAM;

--
-- Table structure for table `global_acc_reg_str`
--

CREATE TABLE IF NOT EXISTS `global_acc_reg_str` (
`account_id` int(11) unsigned NOT NULL default '0',
PRIMARY KEY (`char_id`,`str`,`account_id`),
`key` varchar(32) binary NOT NULL default '',
`index` int(11) unsigned NOT NULL default '0',
`value` varchar(254) NOT NULL default '0',
PRIMARY KEY (`account_id`,`key`,`index`),
KEY `account_id` (`account_id`)
) ENGINE=MyISAM;

@@ -480,11 +543,10 @@ INSERT INTO `login` (`account_id`, `userid`, `user_pass`, `sex`, `email`) VALUES
--

CREATE TABLE IF NOT EXISTS `mapreg` (
`varname` varchar(32) NOT NULL,
`varname` varchar(32) binary NOT NULL,
`index` int(11) unsigned NOT NULL default '0',
`value` varchar(255) NOT NULL,
KEY `varname` (`varname`),
KEY `index` (`index`)
PRIMARY KEY (`varname`,`index`)
) ENGINE=MyISAM;

--
@@ -0,0 +1,66 @@
ALTER TABLE `mapreg` ADD PRIMARY KEY (`varname`, `index`);
ALTER TABLE `mapreg` DROP INDEX `varname`;
ALTER TABLE `mapreg` DROP INDEX `index`;
ALTER TABLE `mapreg` MODIFY `varname` varchar(32) binary NOT NULL;

CREATE TABLE IF NOT EXISTS `acc_reg_num` (
`account_id` int(11) unsigned NOT NULL default '0',
`key` varchar(32) binary NOT NULL default '',
`index` int(11) unsigned NOT NULL default '0',
`value` int(11) NOT NULL default '0',
PRIMARY KEY (`account_id`,`key`,`index`),
KEY `account_id` (`account_id`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `acc_reg_str` (
`account_id` int(11) unsigned NOT NULL default '0',
`key` varchar(32) binary NOT NULL default '',
`index` int(11) unsigned NOT NULL default '0',
`value` varchar(254) NOT NULL default '0',
PRIMARY KEY (`account_id`,`key`,`index`),
KEY `account_id` (`account_id`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `char_reg_num` (
`char_id` int(11) unsigned NOT NULL default '0',
`key` varchar(32) binary NOT NULL default '',
`index` int(11) unsigned NOT NULL default '0',
`value` int(11) NOT NULL default '0',
PRIMARY KEY (`char_id`,`key`,`index`),
KEY `char_id` (`char_id`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `char_reg_str` (
`char_id` int(11) unsigned NOT NULL default '0',
`key` varchar(32) binary NOT NULL default '',
`index` int(11) unsigned NOT NULL default '0',
`value` varchar(254) NOT NULL default '0',
PRIMARY KEY (`char_id`,`key`,`index`),
KEY `char_id` (`char_id`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `global_acc_reg_num` (
`account_id` int(11) unsigned NOT NULL default '0',
`key` varchar(32) binary NOT NULL default '',
`index` int(11) unsigned NOT NULL default '0',
`value` int(11) NOT NULL default '0',
PRIMARY KEY (`account_id`,`key`,`index`),
KEY `account_id` (`account_id`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `global_acc_reg_str` (
`account_id` int(11) unsigned NOT NULL default '0',
`key` varchar(32) binary NOT NULL default '',
`index` int(11) unsigned NOT NULL default '0',
`value` varchar(254) NOT NULL default '0',
PRIMARY KEY (`account_id`,`key`,`index`),
KEY `account_id` (`account_id`)
) ENGINE=MyISAM;

INSERT INTO `acc_reg_num` (`account_id`, `key`, `index`, `value`) SELECT `account_id`, `str`, 0, `value` FROM `global_reg_value` WHERE `type` = 2 AND `str` NOT LIKE '%$';
INSERT INTO `acc_reg_str` (`account_id`, `key`, `index`, `value`) SELECT `account_id`, `str`, 0, `value` FROM `global_reg_value` WHERE `type` = 2 AND `str` LIKE '%$';
INSERT INTO `char_reg_num` (`char_id`, `key`, `index`, `value`) SELECT `char_id`, `str`, 0, `value` FROM `global_reg_value` WHERE `type` = 3 AND `str` NOT LIKE '%$';
INSERT INTO `char_reg_str` (`char_id`, `key`, `index`, `value`) SELECT `char_id`, `str`, 0, `value` FROM `global_reg_value` WHERE `type` = 3 AND `str` LIKE '%$';
INSERT INTO `global_acc_reg_num` (`account_id`, `key`, `index`, `value`) SELECT `account_id`, `str`, 0, `value` FROM `global_reg_value` WHERE `type` = 1 AND `str` NOT LIKE '%$';
INSERT INTO `global_acc_reg_str` (`account_id`, `key`, `index`, `value`) SELECT `account_id`, `str`, 0, `value` FROM `global_reg_value` WHERE `type` = 1 AND `str` LIKE '%$';
# DROP TABLE `global_reg_value`;

3 comments on commit 6295c77

@tmav94
Copy link

@tmav94 tmav94 commented on 6295c77 Sep 2, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many of my scriptsis not working after this update...This is a Example

new_1-1,45,113,4 script Guarda#Tuvok1 105,{
if (countitem(24366) == 0 ) {
getitem 24366,1;
}
query_sql( "SELECT pacess FROM login WHERE account_id = '"+escape_sql( getcharid(3) )+"'",.@return);
if (.@return == 0) {
query_sql("UPDATE login SET pacess = 1 WHERE account_id = '"+escape_sql( getcharid(3) )+"'");
mes "[Game Master]";
mes "Aqui está seu Box de Boas Vindas.";
mes "Tenha um bom jogo!";
getitem 24359,1;
close;
}
else {
mes "[Game Master]";
mes "Você já recebeu sua recompensa...";
close;
end;
}
end;
OnInit:
waitingroom "Retirar Prêmio",0;
end;
}

@edit
Vote4Points
PvP
Query_sqls

evertying is not working...

@edit 2

Sorry, this update will broke many things avaliable to "old servers"...Switching to stable...

@aleos89
Copy link
Contributor Author

@aleos89 aleos89 commented on 6295c77 Sep 2, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ebaefc1.

@hnomkeng
Copy link

@hnomkeng hnomkeng commented on 6295c77 Oct 6, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

untitled-2

Please sign in to comment.