Jump to content
  • 0
daim

@item item_deny

Question

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?

Share this post


Link to post
Share on other sites

9 answers to this question

Recommended Posts

  • 0

 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 by AnnieRuru

Share this post


Link to post
Share on other sites
  • 0

isn't easier to bind the atcommand to a script?

I thought of that before and I already knew a bug

so 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 by AnnieRuru

Share this post


Link to post
Share on other sites
  • 0

 

 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?

Share this post


Link to post
Share on other sites
  • 0

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

Share this post


Link to post
Share on other sites
  • 0

 

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

Share this post


Link to post
Share on other sites
  • 0

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 @bounditem

thanks for the reminder, the plugin file is getting big

 

http://upaste.me/1a2f73

Share this post


Link to post
Share on other sites
  • 0

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 by Cydh

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.