Jump to content
  • 0

Run Script for everyone on Map


Moriarty

Question


  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  135
  • Reputation:   13
  • Joined:  06/20/12
  • Last Seen:  

I want to run a script for everyone in a map.

I need to check who has most item x to declare the winner of the event.

 

I saw addrid() but didn't understand how it works, and there is no examples.

I'm going to create a custom command to fill an array with everybody account id's and then run a for with attachrid. But I wan't to know if there is a way to do this with the current tools available for scripting.

Thanks.

 

PS: Don't give me alternate ways to accomplish what I want ( ex: put a NPC on map and make everybody click on it, or whatever ).

Link to comment
Share on other sites

4 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  265
  • Reputation:   95
  • Joined:  09/30/14
  • Last Seen:  

It's exactly that.

 

addrid(1,0);

 

What kind of event is it? I'll write up a simple example.

prontera,150,180,5	script	GIVEREWARD	-1,{
end;

OnWhisperGlobal:
	addrid(1,0);
	.count = 0;
	EventCount = countitem(512);
	if ( EventCount > .count ) { .count = EventCount; .winner$ = strcharinfo(0); .aid = getcharid(3); }
	initnpctimer;
	end;

OnTimer100:
	stopnpctimer;
	getitem 582,1,.aid;
	announce "The winner is "+.winner$+"!",bc_all,"0xffff00";
	end;
}

Probably not the cleanest method, but it does the job.

Edited by Nova
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  135
  • Reputation:   13
  • Joined:  06/20/12
  • Last Seen:  

I tested with addrid(1); and didn't work, I must have done something wrong in another part of code and didn't notice.

By the way, use atcommand to give itens? hahaha

Well, thanks a lot.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  265
  • Reputation:   95
  • Joined:  09/30/14
  • Last Seen:  

Rewrote it, check it out :]

The only detail is right now there's no function for draws, but I'm sure you can write that part out.

Right now, if a draw occurs, it'll give the reward at random to one of the two players with the most.

Edited by Nova
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  135
  • Reputation:   13
  • Joined:  06/20/12
  • Last Seen:  

There was no need, once you told that addrid did what I asked, the problem was solved haha

 

Thanks a lot, again :)

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