• 0
cumbe11

Add item in all accounts.

Question

I would like a npc or a way even if it is through phpAdmin adding an item in the storage of all accounts registered on my server all of a time.

Share this post


Link to post
Share on other sites

Recommended Posts

  • 0
On 4/13/2013 at 4:34 AM, Capuche said:
prontera,155,170,5	script	add storage	87,{
	if( getgmlevel() < 98 ) end;
	mes "You can add an item in all inventory.";
	mes "(ID reins: ^ff000012622^000000)";
	next;
	if( select( "Add an item ID", "Leave" ) -1 ) close;
	input .@item_id;
	if( getiteminfo( .@item_id,0 ) == -1 ) {
		mes "Unknown item id.";
		close;
	}
// online
	set .@item_name$, getitemname( .@item_id );
	set .@gm_name$, strcharinfo(0);
	do {
		set .@size, query_sql( "SELECT `account_id` from `char` where `online` = '1' order by `account_id` desc limit "+ ( .@loop *128 ) +", 128", .@account_id );
		for( set .@i, 0; .@i < .@size; set .@i, .@i +1 ) {
			getitem .@item_id, 1, .@account_id[.@i];
			message rid2name( .@account_id[.@i] ), "You get an "+ .@item_name$ +" from "+ .@gm_name$ +".";
		}
		set .@loop, .@loop +1;
	}
	while( .@size );
// offline
	query_sql "INSERT INTO `global_reg_value` (`char_id`, `str`, `value`, `type`, `account_id`) select '0', '#item_inventory_gift', '"+ .@item_id +"', '2', `char`.`account_id` "+
			"from `char` where `char`.`online` = '0' on duplicate key update `global_reg_value`.`value` = '"+ .@item_id +"'";
	close;
OnPCLoginEvent:
	if( #item_inventory_gift ) {
		getitem #item_inventory_gift, 1;
		message strcharinfo(0), "You get an "+ getitemname( #item_inventory_gift ) +" from a gm.";
		set #item_inventory_gift, 0;
	}
	end;
}

 

Players online get an item in their inventory.

Others players get the item when they log in.

 

please make to sent item to all user offline too

this is only sent to user online 

 

thank you

Share this post


Link to post
Share on other sites
  • 0
7 hours ago, ittiphol said:

this is only sent to user online 

 

On 4/12/2013 at 11:34 PM, Capuche said:

Others players get the item when they log in.

/hmm

 

Maybe the query of this script need to be updated depending of your server but it will be your homework.

Share this post


Link to post
Share on other sites
  • 0
5 hours ago, Capuche said:

 

/hmm

 

Maybe the query of this script need to be updated depending of your server but it will be your homework.

i try it's not work for me

just sent only user online

you can edit this script?

Share this post


Link to post
Share on other sites

What item will you insert on the storage?

Share this post


Link to post
Share on other sites

It'll be more easier to have the items "INSERTED" on every account's storage by making a database-side query  /no1

 

Here's the query, for adding the Halter Lead (Item #12622) on all storages of players. the database name is 'ragnarok' for me.

 

 

INSERT INTO `ragnarok`.`storage` (`id`, `account_id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `card0`, `card1`, `card2`, `card3`, `expire_time`, `unique_id`) SELECT  NULL, `login`.`account_id`, '12622', '1', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0' FROM `ragnarok`.`login` WHERE `account_id` > 1;

 
Hope it helps!  /ok
Edited by paopao

Share this post


Link to post
Share on other sites

I want to send an item with zero weight for the storage of all registered accounts at once that the id is 32002

paopao, that example you posted is an npc or command to execute in phpAdmin?

 

 

 

if it helps I have this script that checks the amount of existing equipment throughout the seridor, on all accounts, if you want a add an item in the storage of all accounts.

 

prontera,168,179,5    script    Registros ragnarok    757,{
mes "Enter the ID of the item which you want to know the amount on the server at the time.";
input [email protected]_id;
if( getitemname( [email protected]_id ) != "null" ){

    if( [email protected]_id ){
        for( set [email protected],0; [email protected] < .sql_size; set [email protected],[email protected] + 1 ){
            query_sql( "SELECT SUM(`amount`) FROM `"+.sql_table$[[email protected]]+"` WHERE `nameid`='"[email protected]_id+"'",[email protected] );
            query_sql( "SELECT COUNT(`card0`) FROM `"+.sql_table$[[email protected]]+"` WHERE `card0`='"[email protected]_id+"'",[email protected] );
            query_sql( "SELECT COUNT(`card1`) FROM `"+.sql_table$[[email protected]]+"` WHERE `card1`='"[email protected]_id+"'",[email protected] );
            query_sql( "SELECT COUNT(`card2`) FROM `"+.sql_table$[[email protected]]+"` WHERE `card2`='"[email protected]_id+"'",[email protected] );
            query_sql( "SELECT COUNT(`card3`) FROM `"+.sql_table$[[email protected]]+"` WHERE `card3`='"[email protected]_id+"'",[email protected] );
            set [email protected],[email protected] + ( [email protected] + [email protected] + [email protected] + [email protected] + [email protected] );
        }
            
        mes "Encontrado "[email protected]+" x "+getitemname( [email protected]_id );
    }
}else{
    mes "Item ID invalid";
}
close;

OnInit:
setarray .sql_table$[0],"inventory","cart_inventory","guild_storage","storage","mail";
set .sql_size,getarraysize( .sql_table$ );
end;
}
Edited by cumbe11

Share this post


Link to post
Share on other sites

I want to send an item with zero weight for the storage of all registered accounts at once that the id is 32002

paopao, that example you posted is an npc or command to execute in phpAdmin?

 

Yes, the script I posted is the query which you can directly input on phpMyAdmin. That script can be modified with little changes (just for syntax) if it's going to be placed on an NPC script with the query_sql(); function.

 

For the zero weight of the item, it should be edited on the item_db.txt/item_db2.txt files.  /no1

 

ID,DBName,ScreenName,Type,Price,Sell,Weight,ATK,DEF,Range,Slot,Job,Upper,Gender,Loc,wLV,eLV,

Refineable,View,{Script},{OnEquip_Script},{OnUnequip_Script}

Edited by paopao

Share this post


Link to post
Share on other sites

Would like to edit this script to check it instead of the quantity of an item on the server, he added an item in storage for everyone at once?

 

 

 

 

prontera,168,179,5    script    Registros ragnarok    757,{
mes "Enter the ID of the item which you want to know the amount on the server at the time.";
input [email protected]_id;
if( getitemname( [email protected]_id ) != "null" ){

    if( [email protected]_id ){
        for( set [email protected],0; [email protected] < .sql_size; set [email protected],[email protected] + 1 ){
            query_sql( "SELECT SUM(`amount`) FROM `"+.sql_table$[[email protected]]+"` WHERE `nameid`='"[email protected]_id+"'",[email protected] );
            query_sql( "SELECT COUNT(`card0`) FROM `"+.sql_table$[[email protected]]+"` WHERE `card0`='"[email protected]_id+"'",[email protected] );
            query_sql( "SELECT COUNT(`card1`) FROM `"+.sql_table$[[email protected]]+"` WHERE `card1`='"[email protected]_id+"'",[email protected] );
            query_sql( "SELECT COUNT(`card2`) FROM `"+.sql_table$[[email protected]]+"` WHERE `card2`='"[email protected]_id+"'",[email protected] );
            query_sql( "SELECT COUNT(`card3`) FROM `"+.sql_table$[[email protected]]+"` WHERE `card3`='"[email protected]_id+"'",[email protected] );
            set [email protected],[email protected] + ( [email protected] + [email protected] + [email protected] + [email protected] + [email protected] );
        }
            
        mes "Encontrado "[email protected]+" x "+getitemname( [email protected]_id );
    }
}else{
    mes "Item ID invalid";
}
close;

OnInit:
setarray .sql_table$[0],"inventory","cart_inventory","guild_storage","storage","mail";
set .sql_size,getarraysize( .sql_table$ );
end;
}
Edited by cumbe11

Share this post


Link to post
Share on other sites


prontera,155,170,5 script add storage 87,{

if( getgmlevel() < 98 ) end;

mes "You can add an item in all account storage.";

mes "Note: if one storage is full, the storage database will contain an extra line for this storage.";

mes "(ID reins: ^ff000012622^000000)";

next;

if( select( "Add an item ID", "Leave" ) -1 ) close;

input [email protected]_id;

if( getiteminfo( [email protected]_id,0 ) == -1 ) {

mes "Unknown item id.";

close;

}

query_sql "INSERT INTO `storage` (`id`, `account_id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `card0`, `card1`, `card2`, `card3`, `expire_time`, `unique_id`) "+

"SELECT NULL, `login`.`account_id`, '"+ [email protected]_id +"', '1', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0' FROM `login` WHERE `account_id` > 1";

mes "Item add. Players must relog to see the item in storage.";

close;

}

  • Upvote 1

Share this post


Link to post
Share on other sites

It did not work nothing appears in Storage and not in the inventory, if I want the same item appears in the inventory, I explained badly.

 

 

I want to send the item will stay on the tab etc.

Edited by cumbe11

Share this post


Link to post
Share on other sites

You want to give an item to all online players directly in their inventory ?

  • Upvote 1

Share this post


Link to post
Share on other sites

That, plus not just on the players online but to all registered accounts in inventory if possible

Share this post


Link to post
Share on other sites

You want to give one item by account or one by character ?

  • Upvote 1

Share this post


Link to post
Share on other sites

per account. in that case would be the same storage.

Share this post


Link to post
Share on other sites
prontera,155,170,5	script	add storage	87,{
	if( getgmlevel() < 98 ) end;
	mes "You can add an item in all inventory.";
	mes "(ID reins: ^ff000012622^000000)";
	next;
	if( select( "Add an item ID", "Leave" ) -1 ) close;
	input [email protected]_id;
	if( getiteminfo( [email protected]_id,0 ) == -1 ) {
		mes "Unknown item id.";
		close;
	}
// online
	set [email protected]_name$, getitemname( [email protected]_id );
	set [email protected]_name$, strcharinfo(0);
	do {
		set [email protected], query_sql( "SELECT `account_id` from `char` where `online` = '1' order by `account_id` desc limit "+ ( [email protected] *128 ) +", 128", [email protected]_id );
		for( set [email protected], 0; [email protected] < [email protected]; set [email protected], [email protected] +1 ) {
			getitem [email protected]_id, 1, [email protected]_id[[email protected]];
			message rid2name( [email protected]_id[[email protected]] ), "You get an "+ [email protected]_name$ +" from "+ [email protected]_name$ +".";
		}
		set [email protected], [email protected] +1;
	}
	while( [email protected] );
// offline
	query_sql "INSERT INTO `global_reg_value` (`char_id`, `str`, `value`, `type`, `account_id`) select '0', '#item_inventory_gift', '"+ [email protected]_id +"', '2', `char`.`account_id` "+
			"from `char` where `char`.`online` = '0' on duplicate key update `global_reg_value`.`value` = '"+ [email protected]_id +"'";
	close;
OnPCLoginEvent:
	if( #item_inventory_gift ) {
		getitem #item_inventory_gift, 1;
		message strcharinfo(0), "You get an "+ getitemname( #item_inventory_gift ) +" from a gm.";
		set #item_inventory_gift, 0;
	}
	end;
}

 

Players online get an item in their inventory.

Others players get the item when they log in.

  • Upvote 1

Share this post


Link to post
Share on other sites

The NPC appears to click on it nothing happens.

Share this post


Link to post
Share on other sites

Previous post edit for eA

  • Upvote 1

Share this post


Link to post
Share on other sites

There are some minor errors, the script will be adding 146 items in each account instead of just one, and just who gets to be online, people who are off when logs get nothing.

Share this post


Link to post
Share on other sites

Haha! yeah I forgot to increment the loop when I modified the script for eA. I edited the script in the post above

  • Upvote 1

Share this post


Link to post
Share on other sites

i cant understand can u post it working pls

Check this post for the script

 

A GM can give an item for all players online and offline, offline players get the item once they log in

  • Upvote 1

Share this post


Link to post
Share on other sites

Nothing Happens after writing the item ID



Check this post for the script


i cant understand can u post it working

 

A GM can give an item for all players online and offline, offline players get the item once they log in

 

Nothing Happens after writing the item ID

Share this post


Link to post
Share on other sites

Check your mapserv and tell me if you have an error.

 

Do you use eA/rA ?

Share this post


Link to post
Share on other sites

am using something like mix between then o_o

for the STARTSERVER

Quz idk how to use the .sql



is there ready rATHENA

With STARTSERVER , logserv , map-server , char-serv

and that things?

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.   Paste as plain text instead

  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...