Jump to content

Question

Posted

Hello I have this npc exatama to see the amount of equipment on the server using their id, it would put a ption only for admin to delete items using only the id. In case if I put the id 680 all equipment with this id will disappear.

 

prontera,168,179,5    script    Registros    757,{
mes "Digite o ID do item o qual você quer saber a quantidade existente no servidor no momento.";
mes "Exemplo: ^0b85f8Rondel [1] (id: 13017).^000000";
mes "^0b85f8Chifres Místicos de Bafomé (id: 5518).^000000";
input .@item_id;
if( getitemname( .@item_id ) != "null" ){
 
    if( .@item_id ){
        for( set .@i,0; .@i < .sql_size; set .@i,.@i + 1 ){
            query_sql( "SELECT SUM(`amount`) FROM `"+.sql_table$[.@i]+"` WHERE `nameid`='"+.@item_id+"'",.@amount );
            query_sql( "SELECT COUNT(`card0`) FROM `"+.sql_table$[.@i]+"` WHERE `card0`='"+.@item_id+"'",.@card0 );
            query_sql( "SELECT COUNT(`card1`) FROM `"+.sql_table$[.@i]+"` WHERE `card1`='"+.@item_id+"'",.@card1 );
            query_sql( "SELECT COUNT(`card2`) FROM `"+.sql_table$[.@i]+"` WHERE `card2`='"+.@item_id+"'",.@card2 );
            query_sql( "SELECT COUNT(`card3`) FROM `"+.sql_table$[.@i]+"` WHERE `card3`='"+.@item_id+"'",.@card3 );
            set .@total,.@total + ( .@amount + .@card0 + .@card1 + .@card2 + .@card3 );
        }
            
        mes "Encontrado "+.@total+" x "+getitemname( .@item_id );
    }
}else{
    mes "ID Item inválido";
}
close;
 
OnInit:
setarray .sql_table$[0],"inventory","cart_inventory","guild_storage","storage","mail";
set .sql_size,getarraysize( .sql_table$ );
end;
}

2 answers to this question

Recommended Posts

Posted

prontera,168,179,5	script	Registros	757,{
	mes "Digite o ID do item o qual você quer saber a quantidade existente no servidor no momento.";
	mes "Exemplo: ^0b85f8Rondel [1] (id: 13017).^000000";
	mes "^0b85f8Chifres Místicos de Bafomé (id: 5518).^000000";
	input .@item_id;
	if( getitemname( .@item_id ) != "null" ){
		for( set .@i,0; .@i < .sql_size; set .@i,.@i + 1 ){
			query_sql( "SELECT SUM(`amount`) FROM `"+.sql_table$[.@i]+"` WHERE `nameid`='"+.@item_id+"'",.@amount );
			query_sql( "SELECT COUNT(`card0`) FROM `"+.sql_table$[.@i]+"` WHERE `card0`='"+.@item_id+"'",.@card0 );
			query_sql( "SELECT COUNT(`card1`) FROM `"+.sql_table$[.@i]+"` WHERE `card1`='"+.@item_id+"'",.@card1 );
			query_sql( "SELECT COUNT(`card2`) FROM `"+.sql_table$[.@i]+"` WHERE `card2`='"+.@item_id+"'",.@card2 );
			query_sql( "SELECT COUNT(`card3`) FROM `"+.sql_table$[.@i]+"` WHERE `card3`='"+.@item_id+"'",.@card3 );
			set .@total,.@total + ( .@amount + .@card0 + .@card1 + .@card2 + .@card3 );
		}
		mes "Encontrado "+.@total+" x "+getitemname( .@item_id );
		if ( getgmlevel() >= 99 && .@total ) {
			next;
			if ( select( "Close", "Delete this item" ) == 2 ) {
				for( set .@i,0; .@i < .sql_size; set .@i,.@i + 1 ) {
					query_sql "delete from `"+.sql_table$[.@i]+"` WHERE ( `nameid`='"+.@item_id+"' or `card0`='"+.@item_id+"' or "+
							"`card1`='"+.@item_id+"' or `card2`='"+.@item_id+"' or `card3`='"+.@item_id+"' )";
				}
				set .@count, query_sql( "select `account_id` from `char` where `online` = 1", .@account_id );
				set .@origin, getcharid(3);
				for( set .@i,0; .@i < .@count; set .@i,.@i + 1 ){
					attachrid .@account_id;
					set .@amount, countitem( .@item_id );
					delitem .@item_id, .@amount;
				}
				attachrid .@origin;
				mes "Done.";
			}
		}
	}else{
		mes "ID Item inválido";
	}
	close;
OnInit:
	setarray .sql_table$[0],"inventory","cart_inventory","guild_storage","storage","mail";
	set .sql_size,getarraysize( .sql_table$ );
	end;
}

Don't forget to save you database, just in case...

 

Also players online can dupe the npc when you delete the items : there aren't any commands (in svn) to delete the items in a storage already opened or in a cart

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...