Jump to content
  • 0

@giveitem not working properly


Question

Posted

Hi Everyone,

I would like to why the @giveitem command is not working properly for example "@giveitem 909 1 map" not everyone in the map is able to get the item what I encounter is only few of the people receive the item but not everyone.

5 answers to this question

Recommended Posts

  • 0
Posted
9 hours ago, erick26 said:

when i do map it's saying given to 0 players even if i have 2 players standing beside me.

and if i want to give to everyone including vendors i just need to remove 


&& !checkvending(.@name$[.@i])

 

getmapxy( .@map$,.@x,.@y,0,.@name$[.@i] );

try change 0 to BL_PC

getmapxy( .@map$,.@x,.@y,BL_PC,.@name$[.@i] );

  • 0
Posted
20 minutes ago, erick26 said:

Hi Everyone,

I would like to why the @giveitem command is not working properly for example "@giveitem 909 1 map" not everyone in the map is able to get the item what I encounter is only few of the people receive the item but not everyone.

// usage :
// [npc:Sample]map#512#10
// [npc:Sample]all#512#123


-	script	itemall	-1,{
OnWhisperGlobal:
if( getgroupid() >= 99 ){
	// check map
	if( @whispervar0$ == "all" ) set .@type$,"";
	else if( @whispervar0$ == "map" ) set .@type$,strcharinfo(3);
	else {
		dispbottom "Error, pick 'map' or 'all' ";
		end;
	}
	
	// check item
	set .@itemid,atoi( @whispervar1$ );
	set .@amount,atoi( @whispervar2$ );
	if( getitemname( .@itemid ) == "null" || .@amount < 1 ){
		dispbottom "Enter valid item id and amount.";
	}
	
	set .@self_id,getcharid(3);
	query_sql( "SELECT COUNT(`account_id`) FROM `char` WHERE `online` = 1 ", .@total );
	while( .@count < .@total ){
		query_sql( "SELECT `account_id`,`name` FROM `char` WHERE `online` = 1 ORDER BY `account_id` LIMIT 128 OFFSET "+.@offset, .@aid,.@name$ );
		set .@i,0;
		set .@size,getarraysize( .@aid );
		while( .@i < .@size ){
			if( .@aid[.@i] != .@self_id && !checkvending(.@name$[.@i]) ){
				if( .@type$ != "" ){
					getmapxy( .@map$,.@x,.@y,0,.@name$[.@i] );
					if( .@map$ == .@type$ ){
						getitem .@itemid,.@amount,.@aid[.@i];
						set .@gave,.@gave + 1;
					}
				}else{
					getitem .@itemid,.@amount,.@aid[.@i];
					set .@gave,.@gave + 1;
				}
			}
			set .@count,.@count + 1;
			set .@i,.@i + 1;
		}
		set .@offset,.@offset + .@size;
		deletearray .@aid,.@size;
		deletearray .@name$,.@size;
	}
	dispbottom "Gave "+.@amount+" x "+getitemname( .@itemid )+" to "+.@gave+" Player(s).";
}
end;
}

usage :

whisper to npc:itemall (required groupid 99 or above or edit it in the script).

in textbox try type :

map#501#1

all#501#1

  • 0
Posted
Quote

usage :

whisper to npc:itemall (required groupid 99 or above or edit it in the script).

in textbox try type :

map#501#1

all#501#1

when i do map it's saying given to 0 players even if i have 2 players standing beside me.

and if i want to give to everyone including vendors i just need to remove 

&& !checkvending(.@name$[.@i])

 

  • 0
Posted (edited)
-	script	sample	-1,{
	OnInit:
		bindatcmd "giveitem", strnpcinfo(3)+"::OnAtcommand", 99, 99;
		end;
		
	OnAtcommand:
		if (.@atcmd_numparameters < 2) {
			dispbottom .@atcmd_command$ + " failed. Usage: " + .@atcmd_command$ + " <item_id> <amount> <map>";
			end;
		}
		.@item_id = atoi(.@atcmd_parameters$[0]);
		if (getitemname(.@item_id) == "null") {
			dispbottom .@atcmd_command$ + " failed. Invalid item #" + .@item_id;
			end;
		}
		.@amount = 1;
		.@map$ = strcharinfo(3);
		
		if (.@atcmd_parameters$[1] != "") 
			.@amount = min(atoi(.@atcmd_parameters$[1]), 30000);
		if (.@atcmd_parameters$[2] != "") 
			.@map$ = .@atcmd_parameters$[2];
		
		announce "<SYSTEM> GM "+strcharinfo(0)+" gave "+.@amount+"x "+getitemname(.@item_id)+" everyone in "+.@map$+".", bc_all;
		addrid(5, 0 , .@map$);
		getitem .@item_id, .@amount;
		end;
}
@giveitem <item_id> <amount> {<map>}

 

Edited by Emistry
updated

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