Is There A Script For Random Player To Get Max Level (X Amount Of Players Online) menu

User Tag List

Results 1 to 4 of 4
  1. #1
    jakeyup's Avatar Member
    Reputation
    4
    Join Date
    Dec 2012
    Posts
    87
    Thanks G/R
    2/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is There A Script For Random Player To Get Max Level (X Amount Of Players Online)

    I remember joining a server long long ago when there was like 100+ people online at once
    1 random lucky winner gets max level instantly and it would congratulate them ect ect

    is there a script out there to get for that? or did they make it themselfs?

    Is There A Script For Random Player To Get Max Level (X Amount Of Players Online)
  2. #2
    stoneharry's Avatar Moderator Harry


    Reputation
    1618
    Join Date
    Sep 2007
    Posts
    4,564
    Thanks G/R
    151/150
    Trade Feedback
    0 (0%)
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    It would be pretty simple.

    Psuedocode:

    Code:
    local MAX_LEVEL = 80
    
    function RewardRandomPlayer()
    	for _,v in pairs(GetOnlinePlayers()) do
    		if v and v:GetLevel() < MAX_LEVEL and math.random(1, 1000) == 1 then -- 1/1000 chance, this is not good random number generation
    			v:SetLevel(MAX_LEVEL)
    			v:SendChatMessageToPlayer(v, "You have won some random thing that gives you max level. Enjoy.")
    			break -- only possible to reward 1 player per function call, this exits the for loop
    		end
    	end
    end
    Update function calls to one valid with your Lua engine if you are using one ( Eluna API ).

    Same logic applies to C++.

    Call function every X seconds.

    If you want to reward a player always:

    Code:
    local MAX_LEVEL = 80
    
    function RewardRandomPlayer()
    	local plrs = GetOnlinePlayers()
    	if #plrs > 0 then
    		local rewarded = false
    		local tries = 0
    		local maxTries = 10
    		while not rewarded do
    			for _,v in pairs(plrs) do
    				if v and v:GetLevel() < MAX_LEVEL and math.random(1, 1000) == 1 then -- 1/1000 chance, this is not good random number generation
    					v:SetLevel(MAX_LEVEL)
    					v:SendChatMessageToPlayer(v, "You have won some random thing that gives you max level. Enjoy.")
    					rewarded = true -- exit while loop
    					break -- only possible to reward 1 player per function call, this exits the for loop
    				end
    			end
    			tries = tries + 1
    			if tries > maxTries then
    				break -- exit loop if failed to reward a player after maxLoops
    			end
    		end
    	end
    end
    Although this is hacky. Better yet:

    Code:
    local MAX_LEVEL = 80
    
    function RewardRandomPlayer()
    	local plrs = GetOnlinePlayers()
    	if #plrs > 0 then
    		local rewarded = false
    		local tries = 0
    		local maxTries = 10
    		while not rewarded do
    			local v = plrs[math.random(1, #plrs)] -- get a random player from the plr table
    			if v and v:GetLevel() < MAX_LEVEL then
    				v:SetLevel(MAX_LEVEL)
    				v:SendChatMessageToPlayer(v, "You have won some random thing that gives you max level. Enjoy.")
    				rewarded = true -- exit while loop
    				break -- only possible to reward 1 player per function call, this exits the for loop
    			end
    			tries = tries + 1
    			if tries > maxTries then
    				break -- exit loop if failed to reward a player after maxLoops
    			end
    		end
    	end
    end
    You could touch it up for your needs.
    Last edited by stoneharry; 09-20-2018 at 02:41 PM.

  3. Thanks jakeyup (1 members gave Thanks to stoneharry for this useful post)
  4. #3
    jakeyup's Avatar Member
    Reputation
    4
    Join Date
    Dec 2012
    Posts
    87
    Thanks G/R
    2/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by stoneharry View Post
    It would be pretty simple.

    Psuedocode:

    Code:
    local MAX_LEVEL = 80
    
    function RewardRandomPlayer()
    	for _,v in pairs(GetOnlinePlayers()) do
    		if v and v:GetLevel() < MAX_LEVEL and math.random(1, 1000) == 1 then -- 1/1000 chance, this is not good random number generation
    			v:SetLevel(MAX_LEVEL)
    			v:SendChatMessageToPlayer(v, "You have won some random thing that gives you max level. Enjoy.")
    			break -- only possible to reward 1 player per function call, this exits the for loop
    		end
    	end
    end
    Update function calls to one valid with your Lua engine if you are using one ( Eluna API ).

    Same logic applies to C++.

    Call function every X seconds.

    If you want to reward a player always:

    Code:
    local MAX_LEVEL = 80
    
    function RewardRandomPlayer()
    	local plrs = GetOnlinePlayers()
    	if #plrs > 0 then
    		local rewarded = false
    		local tries = 0
    		local maxTries = 10
    		while not rewarded do
    			for _,v in pairs(plrs) do
    				if v and v:GetLevel() < MAX_LEVEL and math.random(1, 1000) == 1 then -- 1/1000 chance, this is not good random number generation
    					v:SetLevel(MAX_LEVEL)
    					v:SendChatMessageToPlayer(v, "You have won some random thing that gives you max level. Enjoy.")
    					rewarded = true -- exit while loop
    					break -- only possible to reward 1 player per function call, this exits the for loop
    				end
    			end
    			tries = tries + 1
    			if tries > maxTries then
    				break -- exit loop if failed to reward a player after maxLoops
    			end
    		end
    	end
    end
    Although this is hacky. Better yet:

    Code:
    local MAX_LEVEL = 80
    
    function RewardRandomPlayer()
    	local plrs = GetOnlinePlayers()
    	if #plrs > 0 then
    		local rewarded = false
    		local tries = 0
    		local maxTries = 10
    		while not rewarded do
    			local v = plrs[math.random(1, #plrs)] -- get a random player from the plr table
    			if v and v:GetLevel() < MAX_LEVEL then
    				v:SetLevel(MAX_LEVEL)
    				v:SendChatMessageToPlayer(v, "You have won some random thing that gives you max level. Enjoy.")
    				rewarded = true -- exit while loop
    				break -- only possible to reward 1 player per function call, this exits the for loop
    			end
    			tries = tries + 1
    			if tries > maxTries then
    				break -- exit loop if failed to reward a player after maxLoops
    			end
    		end
    	end
    end
    You could touch it up for your needs.

    holy cow. you are literally a god im surprised no one said google. com or whatever or give me bs answers.
    we need more people like you in the community <3
    much love dude

  5. #4
    stoneharry's Avatar Moderator Harry


    Reputation
    1618
    Join Date
    Sep 2007
    Posts
    4,564
    Thanks G/R
    151/150
    Trade Feedback
    0 (0%)
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by jakeyup View Post
    holy cow. you are literally a god im surprised no one said google. com or whatever or give me bs answers.
    we need more people like you in the community <3
    much love dude
    It only takes a couple of minutes to offer some pointers. Glad to help.

    The code could be improved - I only wrote it quickly to show the basic concepts. For example, if there are a lot of max level players online it becomes less likely for a player to get rewarded. Instead you could remove all max level players from the players table before getting a random player from the table.

Similar Threads

  1. is there some scripts i can get to make escorts work?
    By arklanbk in forum WoW EMU Questions & Requests
    Replies: 1
    Last Post: 12-11-2013, 03:45 AM
  2. Is there any way for me to...
    By jdismeuc in forum Community Chat
    Replies: 1
    Last Post: 05-15-2008, 06:01 PM
  3. Is there a modeleditfix for 2.3
    By Thexmage in forum WoW ME Questions and Requests
    Replies: 50
    Last Post: 11-17-2007, 05:51 PM
  4. Is there a M2 and a BLP to edit pets?
    By sudnrage111 in forum World of Warcraft General
    Replies: 1
    Last Post: 08-15-2006, 03:57 PM
All times are GMT -5. The time now is 04:13 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search