Forum

> > CS2D > Scripts > timer random menu
Forums overviewCS2D overview Scripts overviewLog in to reply

English timer random menu

4 replies
To the start Previous 1 Next To the start

old timer random menu

Kirito2K
User Off Offline

Quote
Hi all , i wanna help with my script , i started making it , and i wanna a timer , for 1 hour , and after 1 hour a menu will open to a random player , if he was afk , it will do a func auto , and if there isn't the player id who the script ٍspecified, the script will choose another one .

I hope u understand me .

old Re: timer random menu

Dousea
User Off Offline

Quote
EDIT:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
-- This function is to round number
function math.round(number)
	return math.ceil(number - .5)
end

-- This function is your auto function
function myautofunction()
	-- Your auto function code inside this function
end

-- This function is for your 1 hour timer
function myfunction()
	-- To choose random player from 1 to 32
	local chosen = math.random(1, 32)
	
	-- If the chosen player exists because not always all players exists
	if (player(chosen, "exists")) then
		-- Send your menu to the chosen player
		menu(chosen, "content-here") -- Change "content-here" to your menu content
		
		-- Save the chosen player's position for your AFK check
		local x, y = player(chosen, "x"), player(chosen, "y")
		-- Timer for your AFK check
		local afktimer = 15 -- Change 15 to your desired time in seconds
		
		-- This function is for your AFK check timer
		function afkcheck()
			-- If the chosen player's position still the same with the previous position
			-- It means the chosen player is AFK
			if (math.round(player(chosen, "x")) == math.round(x) and math.round(player(chosen, "y")) == math.round(y)) then
				-- Call your auto function that do certain stuff
				myautofunction()
			end
			
			-- Create timer again for your 1 hour check
			timer(3600000, "myfunction")
		end
		
		-- Create timer for your AFK check
		timer(afktimer * 1000, "afkcheck")
	-- If the chosen player doesn't exist
	else
		-- Call this function again to get existing player
		myfunction()
	end
end

-- Create timer for your 1 hour check
timer(3600000, "myfunction")
I tested the code and it works. Put your menu at line 19.
edited 1×, last 04.01.15 05:16:22 am

old Re: timer random menu

Bowlinghead
User Off Offline

Quote
What the...?
You said you have made some code and stuff and you are not able to copy& paste your code into the first function?
And what should he put in the menu? I mean... wasn´t it your idea of the menu?
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview