Jump to content
  • 0

Giving an item to every person on an instance map.


michaelsoftman

Question


  • Group:  Members
  • Topic Count:  48
  • Topics Per Day:  0.01
  • Content Count:  410
  • Reputation:   29
  • Joined:  04/04/12
  • Last Seen:  

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.

Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  130
  • Reputation:   43
  • Joined:  12/11/11
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  48
  • Reputation:   8
  • Joined:  01/09/12
  • Last Seen:  

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.

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