daim 5 Posted September 4, 2014 Hi there, i would like to add this to hercules. Unfortunetly there so much error appear. Please helpme @item patch Index: atcommand.c===================================================================--- atcommand.c (revision 14843)+++ atcommand.c (working copy)@@ -1576,6 +1576,7 @@{ char item_name[100]; int number = 0, item_id, flag;+ int itemid, level; //To Check the item_deny from sql [Vengence] struct item item_tmp; struct item_data *item_data; int get_count, i;@@ -1602,6 +1603,27 @@ } item_id = item_data->nameid;+ //To Check the item_deny from sql [Vengence]+ if(SQL_ERROR == Sql_Query(mmysql_handle, "SELECT * FROM `item_deny` WHERE `itemid` = '%d'",item_id))+ {+ Sql_ShowDebug(mmysql_handle);+ }+ else+ {+ while( SQL_SUCCESS == Sql_NextRow(mmysql_handle) )+ {+ char *data;+ Sql_GetData(mmysql_handle, 0, &data, NULL);+ itemid = atoi(data);+ Sql_GetData(mmysql_handle, 1, &data, NULL);+ level = atoi(data);+ }+ }+ if (item_id == itemid && pc_isGM(sd) < level) {+ clif_displaymessage(sd->fd, "You are restricted from creating this item.");+ return -1;+ }+ get_count = number; //Check if it's stackable. if (!itemdb_isstackable2(item_data)) could anyone make fix for this? Quote Share this post Link to post Share on other sites
0 AnnieRuru 957 Posted September 4, 2014 (edited) src/map/atcommand.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)diff --git a/src/map/atcommand.c b/src/map/atcommand.cindex b5e8fa7..ff35309 100644--- a/src/map/atcommand.c+++ b/src/map/atcommand.c@@ -1171,6 +1171,21 @@ static inline const char* atcommand_help_string(AtCommandInfo *info) { } item_id = item_data->nameid;++ if ( SQL->Query( map->mysql_handle, "select level from item_deny where itemid = %d", item_data->nameid ) == SQL_ERROR )+ Sql_ShowDebug( map->mysql_handle );+ else if ( SQL->NextRow( map->mysql_handle ) == SQL_SUCCESS ) {+ char *data;+ int16 level;+ if ( SQL->GetData( map->mysql_handle, 0, &data, NULL ) == SQL_SUCCESS ) {+ level = atoi(data);+ if ( pc_get_group_level(sd) < level ) {+ clif->message( fd, "You are restricted from creating this item." );+ return false;+ }+ }+ SQL->FreeResult( map->mysql_handle );+ }+ get_count = number; //Check if it's stackable. if (!itemdb->isstackable2(item_data)) {are you sure you want to access to sql every time a GM item ?I think I can code something like @reloaditemdeny so it'll catch the data Edited September 12, 2014 by AnnieRuru Quote Share this post Link to post Share on other sites
0 evilpuncker 503 Posted September 4, 2014 isn't easier to bind the atcommand to a script? Quote Share this post Link to post Share on other sites
0 AnnieRuru 957 Posted September 5, 2014 (edited) isn't easier to bind the atcommand to a script?I thought of that before and I already knew a bugso now I show you - script sdjfhksdj -1,{OnInit: bindatcmd "item", strnpcinfo(0)+"::Onaaa"; bindatcmd "itemabount", strnpcinfo(0)+"::Onaaa"; end;Onaaa: if ( !.@atcmd_numparameters ) { atcommand .@atcmd_command$; end; } explode .@command$, .@atcmd_command$ +" "+ implode( .@atcmd_parameters$, " " ), " "; if ( !sscanf( .@atcmd_command$, "@%s", .@command$ ) ) sscanf .@atcmd_command$, "#%s", .@command$; query_sql "select level from item_deny where itemid = "+ .@command$[1], .@level; if ( getgmlevel() < .@level ) { message strcharinfo(0), "You are restricted from creating this item."; // <-- this part end; } atcommand "@"+ .@command$ +" "+ implode( .@atcmd_parameters$, " " ); end;}when you want to display a message for #char command, bindatcmd will behave weirdly if you code atcommand entirely in the source like post#2, sd->fd will display the restriction message on the person who type the command if you script this entirely as a npc script like this post, *message script command will send the restriction message to the target character that is because bindatcmd will make the command execute entirely on the target character as if the target were typing the command don't get it ? I used AnnieRuru character trying to send a red pot to EnnyRuru I tried "#item ennyruru 501 1" in post#2, it display the restriction message on AnnieRuru in this post, it display the restriction message on EnnyRuru the GM might be wondering why the command doesn't work, and then the target character gets spam by this irrelevant messages I've always use bindatcmd because its easy, yeah true, but when certain ones has to execute by char command as well, have to code in the source Edited September 5, 2014 by AnnieRuru Quote Share this post Link to post Share on other sites
0 daim 5 Posted September 6, 2014 src/map/atcommand.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)diff --git a/src/map/atcommand.c b/src/map/atcommand.cindex b5e8fa7..ff35309 100644--- a/src/map/atcommand.c+++ b/src/map/atcommand.c@@ -1171,6 +1171,21 @@ static inline const char* atcommand_help_string(AtCommandInfo *info) { } item_id = item_data->nameid;++ if ( SQL->Query( map->mysql_handle, "select level from item_deny where itemid = %d", item_data->nameid ) == SQL_ERROR )+ Sql_ShowDebug( map->mysql_handle );+ else if ( SQL->NextRow( map->mysql_handle ) == SQL_SUCCESS ) {+ char *data;+ int16 level;+ if ( SQL->GetData( map->mysql_handle, 0, &data, NULL ) == SQL_SUCCESS ) {+ level = atoi(data);+ if ( pc_get_group_level(sd) < level ) {+ clif->message( fd, "You are restricted from creating this item." );+ return false;+ }+ }+ }+ get_count = number; //Check if it's stackable. if (!itemdb->isstackable2(item_data)) {are you sure you want to access to sql every time a GM item ?I think I can code something like @reloaditemdeny so it'll catch the data Hi annie, thanks for your support. Is there any problem if we use e sql access every time we issue @item command? Quote Share this post Link to post Share on other sites
0 AnnieRuru 957 Posted September 12, 2014 daim, on 07 Sept 2014 - 00:54, said: Is there any problem if we use e sql access every time we issue @item command? maybe ...accessing sql takes time ... if you execute a long query, then it might lag your server well ... in this case, where it only retrieve a single line, it seems fast enough I think so shouldn't be a problem ... for some reason after I made maintenance mode plugin, this one seems ... too easy create table item_deny ( itemid smallint(6) primary key, `level` tinyint(4) ) engine = innodb; http://upaste.me/34c789 let me test what happen if do this as plugin ... I got a feeling that @item will be execute twice Quote Share this post Link to post Share on other sites
0 daim 5 Posted September 12, 2014 daim, on 07 Sept 2014 - 00:54, said: Is there any problem if we use e sql access every time we issue @item command? maybe ...accessing sql takes time ... if you execute a long query, then it might lag your server well ... in this case, where it only retrieve a single line, it seems fast enough I think so shouldn't be a problem ... for some reason after I made maintenance mode plugin, this one seems ... too easy create table item_deny (itemid smallint(6) primary key,`level` tinyint(4)) engine = innodb; http://upaste.me/34c789 let me test what happen if do this as plugin ... I got a feeling that @item will be execute twice I think mod the @item command is enough, and also this command needs to be implimented to other @item commands, such as @produe and @bounditem Quote Share this post Link to post Share on other sites
0 AnnieRuru 957 Posted September 12, 2014 the plugin actually works it overwrite the default atcommand I think mod the @item command is enough, and also this command needs to be implimented to other @item commands, such as @produe and @bounditemthanks for the reminder, the plugin file is getting big http://upaste.me/1a2f73 Quote Share this post Link to post Share on other sites
0 Cydh 9 Posted September 12, 2014 (edited) just a little improvement if u want (I ever made this for my own server) instead of loading item each command being used, always accessing MySQL, just load it once and reloaded by @reloaditemdb. use item flag to mark it as "this item cannot be @item/@refine/@etc etc by group level/id below `this`" EDIT: attaching file item_restriction.diff Edited September 12, 2014 by Cydh 1 AnnieRuru reacted to this Quote Share this post Link to post Share on other sites
0 AnnieRuru 957 Posted September 13, 2014 http://upaste.me/0eba84 ahahaha ~ use a little bit of trick, I wonder how much RAM usage if declare a big array ? Quote Share this post Link to post Share on other sites
Hi there,
i would like to add this to hercules. Unfortunetly there so much error appear. Please helpme
@item patch
could anyone make fix for this?
Share this post
Link to post
Share on other sites