Jump to content
  • 0

OnTimer ForEach Char in Area


roy_raider

Question


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  2
  • Reputation:   0
  • Joined:  12/19/13
  • Last Seen:  

Hi everyone.

 

I'm not enough experienced on rAthena Scripting And I'm stuck on something I wanna do.

 

I would like to have:

- an Npc Area (like 50x50)

- With globale and looping timer (like each 600s)

- Doing a function for EACH player in the area at the given moment.

 

So there is multiple problems I dont succeed to overcome.

First of all I dont want to do the same effect on all player in the area.

I dont want to do the effect after 600s when a player enter the zone (I want the all the effects to be at the same times and be independant of each player)

 

so in the perfect world

npc zone 50x50 {

 

OnTimerXX:

    Foreach players as player in area {

         dosomething random to player

    }

    initTimer again

 

}

 

Could you help me to figure this out ? :)

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

  • Group:  Developer
  • Topic Count:  48
  • Topics Per Day:  0.01
  • Content Count:  1443
  • Reputation:   344
  • Joined:  10/17/12
  • Last Seen:  

for the attaching of players use addrid(4,0,x1,y1,x2,y2)

-------------------------

*addrid(<type>{,<flag>{,<parameters>}});

This command will attach other RIDs to the current script without detaching the
invoking RID. It returns 1 if successful and 0 upon failure.

<type> determines what RIDs are attached:
 0: All players in the server.
 1: All players in the map of the invoking player, or the invoking NPC if no player is attached.
 2: Party members of a specified party ID.
    [ Parameters: <party id> ]
 3: Guild members of a specified guild ID.
    [ Parameters: <guild id> ]
 4: All players in a specified area of the map of the invoking player (or NPC).
    [ Parameters: <x0>,<y0>,<x1>,<y1> ]
 Account ID: If type is Account ID, attach the specified account ID.

<flag> can prevent certain players from being attached:
 0: Players are always attached. (default)
 1: Players currently running another script will not be attached.

---------------------------------------

as for the random effect do a
 

switch(rand(5)){
case 0:effect 1
case 1:effect 2
case 2:effect3
case 3:effect4
case 4:effect5
}

 just be sure to detatch players after every cycle

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  2
  • Reputation:   0
  • Joined:  12/19/13
  • Last Seen:  

First of all thank you for your answer,

 

I saw addrid, but it don't seems to work with my timer NPC...

I mean no player are attached to him. and it look like addrid not working if there is no player allready atached... :(

 

Do you have a way to do an "addrid" when no-one is already attached ?

Edited by roy_raider
Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  48
  • Topics Per Day:  0.01
  • Content Count:  1443
  • Reputation:   344
  • Joined:  10/17/12
  • Last Seen:  

addrid should work even if no players are already attached if you use properly, if for some reason its not id say use ontouch create an array then do a check if players in that array are in the range  and run the effect on all playere who meet range requirements then after event is over clear the array (this only works if its not  a constant ongoing thing, good for boss fight or minigame)

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