Jump to content
  • 0

Random Item Drop


jigsgfx

Question


  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.00
  • Content Count:  83
  • Reputation:   0
  • Joined:  06/02/12
  • Last Seen:  

Hi, can you guys help me with a script that can drop a list of items like 5 to 10 item id once you talk to npc it will drop randomly the list of items & with specific quantity to a specific map ?

example list of items, 10x poring card, 5x apple, 2x fluff and so on.. upto 10 items or more if possible and it will drop randomly on where the map is set.

hoping the this is possible..

thanks in advance to those who will help me with this.. /no1

Link to comment
Share on other sites

7 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  94
  • Topics Per Day:  0.02
  • Content Count:  2192
  • Reputation:   252
  • Joined:  11/11/11
  • Last Seen:  

This is almost similar to what you want... except, you seem to want it to 'drop' as opposed to given. =/
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

I think he means makeitem

-	script	kfksdhfksjdfhs	-1,{
OnInit:
bindatcmd "dropevent", strnpcinfo(0) +"::Onaaa", 60,100;
end;
Onaaa:
while (1) {
	mes "main menu";
	next;
	.@menu$ = "";
	for ( .@i = 0; .@i < .count; .@i++ ) {
		.@menu$ = .@menu$ + .amount[.@i] +"x "+ getitemname( .item[.@i] ) +":";
	}
	.@menu$ = .@menu$ + "Add:Choose map:Start Event";
	.@s = select( .@menu$ ) -1;
	if ( .@s <= .count ) {
		mes "input itemID - 0 to remove";
		if ( input ( .@tmp, 0, 32767 ) )
			mes "invalid range";
		else if ( !.@tmp && .@s != .count ) {
			deletearray .item[.@s], 1;
			deletearray .amount[.@s], 1;
			.count--;
		}	
		else if ( getitemname( .@tmp ) == "null" )
			mes "invalid item ID";
		else {
			mes "input amount";
			if ( input( .@tmp2, 1, 30000 ) )
				mes "invalid range";
			else {
				.item[.@s] = .@tmp;
				.amount[.@s] = .@tmp2;
				.count++;
			}
		}
		next;
	}
	else if ( .@s == .count +1 ) {
		mes "input a valid map name";
		if ( input( .@tmp$, 4,12 ) )
			mes "invalid range";
		else if ( getmapusers( .@tmp$ ) == -1 )
			mes "invalid map name";
		else
			.map$ = .@tmp$;
	}
	else
		break;
}
mes "done";
announce strcharinfo(0) +" has generously dropping items in map "+ .map$, 0;
freeloop 1;
for ( .@i = 0; .@i < .count; .@i++ ) {
	while ( checkcell( .map$, .@x = rand(450), .@y = rand(450), cell_chknopass ) );
	makeitem .item[.@i], .amount[.@i], .map$, .@x, .@y;
}
close;
}

simple script, really

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.00
  • Content Count:  83
  • Reputation:   0
  • Joined:  06/02/12
  • Last Seen:  

This is almost similar to what you want... except, you seem to want it to 'drop' as opposed to given. =/

thanks dude but that thing gives item to players i need a script that will drop an item on a specific map randomly

I think he means makeitem

-	script	kfksdhfksjdfhs	-1,{
OnInit:
bindatcmd "dropevent", strnpcinfo(0) +"::Onaaa", 60,100;
end;
Onaaa:
while (1) {
	mes "main menu";
	next;
	.@menu$ = "";
	for ( .@i = 0; .@i < .count; .@i++ ) {
		.@menu$ = .@menu$ + .amount[.@i] +"x "+ getitemname( .item[.@i] ) +":";
	}
	.@menu$ = .@menu$ + "Add:Choose map:Start Event";
	.@s = select( .@menu$ ) -1;
	if ( .@s <= .count ) {
		mes "input itemID - 0 to remove";
		if ( input ( .@tmp, 0, 32767 ) )
			mes "invalid range";
		else if ( !.@tmp && .@s != .count ) {
			deletearray .item[.@s], 1;
			deletearray .amount[.@s], 1;
			.count--;
		}	
		else if ( getitemname( .@tmp ) == "null" )
			mes "invalid item ID";
		else {
			mes "input amount";
			if ( input( .@tmp2, 1, 30000 ) )
				mes "invalid range";
			else {
				.item[.@s] = .@tmp;
				.amount[.@s] = .@tmp2;
				.count++;
			}
		}
		next;
	}
	else if ( .@s == .count +1 ) {
		mes "input a valid map name";
		if ( input( .@tmp$, 4,12 ) )
			mes "invalid range";
		else if ( getmapusers( .@tmp$ ) == -1 )
			mes "invalid map name";
		else
			.map$ = .@tmp$;
	}
	else
		break;
}
mes "done";
announce strcharinfo(0) +" has generously dropping items in map "+ .map$, 0;
freeloop 1;
for ( .@i = 0; .@i < .count; .@i++ ) {
	while ( checkcell( .map$, .@x = rand(450), .@y = rand(450), cell_chknopass ) );
	makeitem .item[.@i], .amount[.@i], .map$, .@x, .@y;
}
close;
}

simple script, really

thanks alot Annie ill try this out /no1

hmm.. not sure Annie but when i start the event and after the announce "has generously dropping items in map" there's no item dropping from nowhere.. and also when i check the console, there's no error found i currently set the map to poring_w01

Edited by jigsgfx
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

I think I didn't do enough protection

-	script	kfksdhfksjdfhs	-1,{
OnInit:
bindatcmd "dropevent", strnpcinfo(0) +"::Onaaa", 60,100;
end;
OnPCLogoutEvent:
if ( .using == getcharid(3) )
	.using = 0;
end;
Onaaa:
if ( .using ) {
	dispbottom rid2name( .using ) +" is using this feature";
	end;
}
.using = getcharid(3);
addtimer 1000, strnpcinfo(0) +"::OnPCLogoutEvent";
while (1) {
	mes "main menu";
	mes "map -> "+( ( getstrlen( .map$ ) )? .map$ : "<none>" );
	if ( .count )
		mes .count +" items will be dropped";
	next;
	.@menu$ = "";
	for ( .@i = 0; .@i < .count; .@i++ )
		.@menu$ = .@menu$ + .amount[.@i] +"x "+ getitemname( .item[.@i] ) +":";
	.@menu$ = .@menu$ + "Add:Choose map - "+ ( ( getstrlen( .map$ ) )? .map$ : "<none>" ) +":Start Event";
	.@s = select( .@menu$ ) -1;
	if ( .@s <= .count ) {
		mes "input itemID - 0 to remove";
		if ( input ( .@tmp, 0, 32767 ) )
			mes "invalid range";
		else if ( !.@tmp && .@s != .count ) {
			deletearray .item[.@s], 1;
			deletearray .amount[.@s], 1;
			.count--;
		}	
		else if ( getitemname( .@tmp ) == "null" )
			mes "invalid item ID";
		else {
			mes "input amount";
			if ( input( .@tmp2, 1, 30000 ) )
				mes "invalid range";
			else {
				.item[.@s] = .@tmp;
				.amount[.@s] = .@tmp2;
				if ( .@s == .count )
					.count++;
			}
		}
	}
	else if ( .@s == .count +1 ) {
		mes "input a valid map name";
		if ( input( .@tmp$, 4,12 ) )
			mes "invalid range";
		else if ( getmapusers( .@tmp$ ) == -1 )
			mes "invalid map name";
		else
			.map$ = .@tmp$;
	}
	else {
		if ( !getstrlen( .map$ ) || !.count )
			mes "incomplete setup";
		else
			break;
	}
	next;
}
mes "done";
announce strcharinfo(0) +" has generously dropping items in map "+ .map$, 0;
freeloop 1;
for ( .@i = 0; .@i < .count; .@i++ ) {
	while ( checkcell( .map$, .@x = rand(450), .@y = rand(450), cell_chknopass ) );
	makeitem .item[.@i], .amount[.@i], .map$, .@x, .@y;
}
close;
}

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.00
  • Content Count:  83
  • Reputation:   0
  • Joined:  06/02/12
  • Last Seen:  

I think I didn't do enough protection

-	script	kfksdhfksjdfhs	-1,{
OnInit:
bindatcmd "dropevent", strnpcinfo(0) +"::Onaaa", 60,100;
end;
OnPCLogoutEvent:
if ( .using == getcharid(3) )
	.using = 0;
end;
Onaaa:
if ( .using ) {
	dispbottom rid2name( .using ) +" is using this feature";
	end;
}
.using = getcharid(3);
addtimer 1000, strnpcinfo(0) +"::OnPCLogoutEvent";
while (1) {
	mes "main menu";
	mes "map -> "+( ( getstrlen( .map$ ) )? .map$ : "<none>" );
	if ( .count )
		mes .count +" items will be dropped";
	next;
	.@menu$ = "";
	for ( .@i = 0; .@i < .count; .@i++ )
		.@menu$ = .@menu$ + .amount[.@i] +"x "+ getitemname( .item[.@i] ) +":";
	.@menu$ = .@menu$ + "Add:Choose map - "+ ( ( getstrlen( .map$ ) )? .map$ : "<none>" ) +":Start Event";
	.@s = select( .@menu$ ) -1;
	if ( .@s <= .count ) {
		mes "input itemID - 0 to remove";
		if ( input ( .@tmp, 0, 32767 ) )
			mes "invalid range";
		else if ( !.@tmp && .@s != .count ) {
			deletearray .item[.@s], 1;
			deletearray .amount[.@s], 1;
			.count--;
		}	
		else if ( getitemname( .@tmp ) == "null" )
			mes "invalid item ID";
		else {
			mes "input amount";
			if ( input( .@tmp2, 1, 30000 ) )
				mes "invalid range";
			else {
				.item[.@s] = .@tmp;
				.amount[.@s] = .@tmp2;
				if ( .@s == .count )
					.count++;
			}
		}
	}
	else if ( .@s == .count +1 ) {
		mes "input a valid map name";
		if ( input( .@tmp$, 4,12 ) )
			mes "invalid range";
		else if ( getmapusers( .@tmp$ ) == -1 )
			mes "invalid map name";
		else
			.map$ = .@tmp$;
	}
	else {
		if ( !getstrlen( .map$ ) || !.count )
			mes "incomplete setup";
		else
			break;
	}
	next;
}
mes "done";
announce strcharinfo(0) +" has generously dropping items in map "+ .map$, 0;
freeloop 1;
for ( .@i = 0; .@i < .count; .@i++ ) {
	while ( checkcell( .map$, .@x = rand(450), .@y = rand(450), cell_chknopass ) );
	makeitem .item[.@i], .amount[.@i], .map$, .@x, .@y;
}
close;
}

thanks again i'll try this out.. /no1

its working now thanks alot Annie /no1

sorry about this Annie, but when i transfer it to my Live Server its not working not sure but i think its because we are using latest version on our Test Server and we are currently using modified trunk16084 on our Live Server, is it ok if we change this to NPC type? not using command?

thanks again Annie

Sorry forgot to input the Error


script error on npc/sro-scripts/dropper.txt line 3
parse_line: expect command, missing function name or calling undeclared function
 1 : {
 2 : OnInit:
*	3 :  'b'indatcmd "dropevent", strnpcinfo(0) +"::Onaaa", 99,100;
 4 :  end;
 5 : OnPCLogoutEvent:
 6 :  if ( .using == getcharid(3) )
 7 :  .using = 0;
 8 :  end;
(02/07/2013 08:31:55) [ Error ] : 
script error on npc/sro-scripts/dropper.txt line 3
parse_line: expect command, missing function name or calling undeclared function
 1 : {
 2 : OnInit:
*	3 :  'b'indatcmd "dropevent", strnpcinfo(0) +"::Onaaa", 60,100;
 4 :  end;
 5 : OnPCLogoutEvent:
 6 :  if ( .using == getcharid(3) )
 7 :  .using = 0;
 8 :  end;
(02/07/2013 08:56:45) [ Error ] : script:delitem: failed to delete 1 items (AID=2000938 item_id=6223).

Edited by jigsgfx
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

I usually don't support older revision, because some bugs always get fixed on latest SVN

-	script	dropevent	-1,{
OnPCLogoutEvent:
if ( .using == getcharid(3) )
	.using = 0;
end;
OnWhisperGlobal:
if ( .using ) {
	dispbottom rid2name( .using ) +" is using this feature";
	end;
}
.using = getcharid(3);
addtimer 1000, strnpcinfo(0) +"::OnPCLogoutEvent";
while (1) {
	mes "main menu";
	mes "map -> "+( ( getstrlen( .map$ ) )? .map$ : "<none>" );
	if ( .count )
		mes .count +" items will be dropped";
	next;
	.@menu$ = "";
	for ( .@i = 0; .@i < .count; .@i++ )
		.@menu$ = .@menu$ + .amount[.@i] +"x "+ getitemname( .item[.@i] ) +":";
	.@menu$ = .@menu$ + "Add:Choose map - "+ ( ( getstrlen( .map$ ) )? .map$ : "<none>" ) +":Start Event";
	.@s = select( .@menu$ ) -1;
	if ( .@s <= .count ) {
		mes "input itemID - 0 to remove";
		if ( input ( .@tmp, 0, 32767 ) )
			mes "invalid range";
		else if ( !.@tmp && .@s != .count ) {
			deletearray .item[.@s], 1;
			deletearray .amount[.@s], 1;
			.count--;
		}	
		else if ( getitemname( .@tmp ) == "null" )
			mes "invalid item ID";
		else {
			mes "input amount";
			if ( input( .@tmp2, 1, 30000 ) )
				mes "invalid range";
			else {
				.item[.@s] = .@tmp;
				.amount[.@s] = .@tmp2;
				if ( .@s == .count )
					.count++;
			}
		}
	}
	else if ( .@s == .count +1 ) {
		mes "input a valid map name";
		if ( input( .@tmp$, 4,12 ) )
			mes "invalid range";
		else if ( getmapusers( .@tmp$ ) == -1 )
			mes "invalid map name";
		else
			.map$ = .@tmp$;
	}
	else {
		if ( !getstrlen( .map$ ) || !.count )
			mes "incomplete setup";
		else
			break;
	}
	next;
}
mes "done";
announce strcharinfo(0) +" has generously dropping items in map "+ .map$, 0;
freeloop 1;
for ( .@i = 0; .@i < .count; .@i++ ) {
	while ( checkcell( .map$, .@x = rand(450), .@y = rand(450), cell_chknopass ) );
	makeitem .item[.@i], .amount[.@i], .map$, .@x, .@y;
}
close;
}

if this whisper system doesn't work, I couldn't able to help anymore

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.00
  • Content Count:  83
  • Reputation:   0
  • Joined:  06/02/12
  • Last Seen:  

I usually don't support older revision, because some bugs always get fixed on latest SVN

-	script	dropevent	-1,{
OnPCLogoutEvent:
if ( .using == getcharid(3) )
	.using = 0;
end;
OnWhisperGlobal:
if ( .using ) {
	dispbottom rid2name( .using ) +" is using this feature";
	end;
}
.using = getcharid(3);
addtimer 1000, strnpcinfo(0) +"::OnPCLogoutEvent";
while (1) {
	mes "main menu";
	mes "map -> "+( ( getstrlen( .map$ ) )? .map$ : "<none>" );
	if ( .count )
		mes .count +" items will be dropped";
	next;
	.@menu$ = "";
	for ( .@i = 0; .@i < .count; .@i++ )
		.@menu$ = .@menu$ + .amount[.@i] +"x "+ getitemname( .item[.@i] ) +":";
	.@menu$ = .@menu$ + "Add:Choose map - "+ ( ( getstrlen( .map$ ) )? .map$ : "<none>" ) +":Start Event";
	.@s = select( .@menu$ ) -1;
	if ( .@s <= .count ) {
		mes "input itemID - 0 to remove";
		if ( input ( .@tmp, 0, 32767 ) )
			mes "invalid range";
		else if ( !.@tmp && .@s != .count ) {
			deletearray .item[.@s], 1;
			deletearray .amount[.@s], 1;
			.count--;
		}	
		else if ( getitemname( .@tmp ) == "null" )
			mes "invalid item ID";
		else {
			mes "input amount";
			if ( input( .@tmp2, 1, 30000 ) )
				mes "invalid range";
			else {
				.item[.@s] = .@tmp;
				.amount[.@s] = .@tmp2;
				if ( .@s == .count )
					.count++;
			}
		}
	}
	else if ( .@s == .count +1 ) {
		mes "input a valid map name";
		if ( input( .@tmp$, 4,12 ) )
			mes "invalid range";
		else if ( getmapusers( .@tmp$ ) == -1 )
			mes "invalid map name";
		else
			.map$ = .@tmp$;
	}
	else {
		if ( !getstrlen( .map$ ) || !.count )
			mes "incomplete setup";
		else
			break;
	}
	next;
}
mes "done";
announce strcharinfo(0) +" has generously dropping items in map "+ .map$, 0;
freeloop 1;
for ( .@i = 0; .@i < .count; .@i++ ) {
	while ( checkcell( .map$, .@x = rand(450), .@y = rand(450), cell_chknopass ) );
	makeitem .item[.@i], .amount[.@i], .map$, .@x, .@y;
}
close;
}

if this whisper system doesn't work, I couldn't able to help anymore

thanks Annie np i undertand, i also tried to change it as npc instead of command but still its working on the latest version and not on my modified older version :) ill try this out.. /no1

Link to comment
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.

×
×
  • Create New...