Jump to content
  • 0

Giving an item to every person on an instance map.


Question

Posted

I was using this bit of code in a mob label to reward everyone who completes an instance event. But the items are never given, I think it doesn't recognize the instance map.

OnEndInstance:
set .@a$, has_instance("1@event");
set .@i, 2000000;
while ( .@i < 2010000 ) {
 if ( .@i % 500 == 0 ) sleep 20; // prevent infinite loop
  if ( attachrid(.@i) ) {
   if( strcharinfo(3) == ".@a$" ) getitem 20951,10;
  }
 set .@i, .@i +1;
}
warp "Save",0,0;
sleep2 1;
instance_destroy(instance_id(1));
end;

It's supposed to give 10 of an item to everyone who's in an instance generated earlier by the same NPC. But I'm not sure why it won't give any items out.

2 answers to this question

Recommended Posts

Posted

Does it enter the label "OnEndInstance" at all?

If it does, check if .@a$ is set to an empty string or the map name.

The script or player might not be attached to an instance, in that case you could save the instance ID and supply to the script command.

*has_instance("<map name>"{,<instance id>});

If you want an alternative to scanning all the IDs to check who is on the map, you can try to:

*instance_warpall "<map name>",<x>,<y>{,<instance id>};

And have a reward NPC they can talk to, or activate an OnTouch on arrival.

Posted

Why you do this:

if( strcharinfo(3) == ".@a$" 

?

This sould be strcharinfo(3) == .@a$ ? Because comparing the string ".@a$" doesn't make sense at all.

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