SphereCommunity
random 1 player in region - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: General Help (/Forum-General-Help)
+--- Thread: random 1 player in region (/Thread-random-1-player-in-region)

Pages: 1 2


random 1 player in region - Alias - 08-30-2012 08:46 PM

Hi Bye i have problem, how to choose 1 player random in region and give this funtion f_luckyplayer to player who was randomy choosed ?


RE: random 1 player in region - Skul - 08-31-2012 05:21 AM

Code:
[function luckyplayer]
region.allchars luckyplayer_choose_rnd

[function luckyplayer_choose_rnd]
if (<isplayer>)
  local.players += 1
  local.player.<dlocal.players>=<uid>
endif
if (<local.players>)
  local.player=<eval {1 <local.players>}>
  local.player=<local.player.<dlocal.player>>
  uid.<local.player>.f_luckyplayer //gives f_luckyplayer to random player.
endif
Add this code to your script and type .luckyplayer


RE: random 1 player in region - Alias - 08-31-2012 06:36 AM

Ok tyvm Smile


RE: random 1 player in region - Alias - 08-31-2012 07:35 PM

Now i test it, and it give's this funtion to all players in region ... Maybe becouse i am using it throw the stone ? Here how i did ...
[function f_start_round]
OBJ=04000ddfd
obj.timerf 5,f_luckyplayer


RE: random 1 player in region - Alias - 09-02-2012 05:02 AM

sorry for triple posting, but still need help with this funtion Confused


RE: random 1 player in region - Skul - 09-02-2012 05:03 AM

use:
Code:
obj.luckyplayer



RE: random 1 player in region - Alias - 09-02-2012 05:26 AM

Funtion it self give to all region players f_luckyplayer
Its not giving only 1 player Confused


RE: random 1 player in region - Alias - 09-02-2012 08:59 PM

Sorry for double post but i really need this funtion to work, to end my event ;S


RE: random 1 player in region - Ben - 09-02-2012 11:42 PM

The problem with the function is that it fires on every character in the region and it uses local variables to gather information... Skul, you should know better lol Tongue

This is untested and I'm sure it can be done in a better way, but I just wrote it on the fly hoping it solves your problem right away Smile

Code:
[function luckyplayer]
region.allclients luckyplayer_choose_rnd
if (<region.tag0.luckyplayers>)
  local.player=<eval {1 <region.tag0.luckyplayers>}>
  local.player=<region.tag0.luckyplayer.<dlocal.player>>
  uid.<local.player>.f_luckyplayer
endif
region.cleartags luckyplayers

[function luckyplayer_choose_rnd]
region.tag0.luckyplayers += 1
region.tag.luckyplayer.<dregion.tag0.luckyplayers>=<uid>



RE: random 1 player in region - Alias - 09-03-2012 01:17 AM

Tyvm Ben this is working perfecly Smile, and tyvm Skul you too Smile