1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
math.randomseed(os.time()) func() 	local rand = math.random(0,25) --generate number in range [0;25] 	if rand == 0 then --so chances will be 1/25 		--do stuff 	end end
Scripts
Lua Scripts/Questions/Helpmath.randomseed(os.time()) func() 	local rand = math.random(0,25) --generate number in range [0;25] 	if rand == 0 then --so chances will be 1/25 		--do stuff 	end end
math.random = (0, trigger("blabla"))
math.random = (0, ("trigger blabla"))
math.random = (0, 10) -- [i]// This will perform a random calculation between 0 and 10, as far as I know.[/i]
if khaleed==nil then khaleed={} end
khaleed.gl={}
khaleed.gh={}
addhook("always","khaleed.gl.always")
addhook("say","khaleed.gh.say")
--This function will save me some writing
--to get the team of a player
function p_team(id) return player(id,"team") end
function khaleed.gl.always()--Always hook has no parameters
	--Loop thru all the players in server
	for indx,id in ipairs(player(0,"table")) do
		if p_team(id)==2 then
			parse("sethealth "..id.." "..250);
			parse("setmaxhealth "..id.." "..250);
		end
	end
end
function khaleed.gh.say(id,txt)
	--Turn to lowercase so the cmd is case-unsensitive
	txt = txt:lower()
	if p_team(id)==2 then
		if txt=="god 0" then
			freehook("always","sample.gl.always");
			parse("killplayer "..id);
		elseif txt=="god 1" then
			addhook("always","sample.gl.always");
			parse("equip "..id.." "..83);
		end
	end
end
if khaleed==nil then khaleed={} end
khaleed.gl={}
khaleed.gh={}
addhook("always","khaleed.gl.always")
addhook("say","khaleed.gh.say")
--This function will save me some writing
--to get the team of a player
function p_team(id) return player(id,"team") end
function khaleed.gl.always()--Always hook has no parameters
	--Loop thru all the players in server
	for indx,id in player(0,"table") do
		if p_team(id)==2 then
			parse("sethealth "..id.." "..250);
			parse("setmaxhealth "..id.." "..250);
		end
	end
end
function khaleed.gh.say(p,txt)
	--Turn to lowercase so the cmd is case-unsensitive
	txt = txt:lower()
	if p_team(id)==2 then
		if txt=="god 0" then
			freehook("always","sample.gl.always");
			parse("killplayer "..id);
		elseif txt=="god 1" then
			addhook("always","sample.gl.always");
			parse("equip "..id.." "..83);
		end
	end
end
for indx,id in player(0,"table") do
for indx,id in ipairs(player(0,"table")) do
for indx,id in player(0,"table") do
for indx,id in ipairs(player(0,"table")) do
function khaleed.gh.say(p,txt) --Change that to function khaleed.gh.say(id,txt)
marks = {1,2,3,4,5,6}
mark_1 = marks[1]
mark_2 = marks[2]
mark_3 = marks[4]
mark_4 = marks[5]
mark_5 = marks[6]
for i = 1, #marks, 1 do mark_..i = marks[i] end
local i
local marks = {1,2,3,4,5,6}
for i = 1, #marks, 1 do
	_G["mark_"..i] = marks[i]
end
print(mark_1.." "..mark_2) --> "1 2"
function array(m)
local array = {}
for i = 1, m do
array[i]=0
end
return array
end
player_count=game('sv_maxplayers')
pl_god=array(player_count)
addhook("hit","_hit")
function _hit(p)
if pl_god[p] == 1 then return 1; end
end
addhook("say","_say")
function _say(p,t)
if (t=='god 1') then pl_god[p]=1 return 1; end
if (t=='god 0') then pl_god[p]=0 return 1; end
end
function khaleed.gh.say(p,txt) --Change that to function khaleed.gh.say(id,txt)
pm <ID> <MESSAGE>
addhook("startround","blablafunc")
function blablafunc(trigger)
blabla = math.random(0,1)
	parse ("trigger ..blabla")
end
addhook("startround","blablafunc")
function blablafunc(trigger)
blabla = math.random(0,1)
parse ("trigger "..blabla)
end
addhook("startround","blablafunc")
function blablafunc(trigger)
blabla = math.random(0,1)
parse ("trigger "..blabla)
end
addhook("say","pm")
function pm(id,txt)
	if(string.sub(txt,1,2)=="pm") then
		local spos=string.find(txt,"%s",4)
		local ^mid=tonumber(string.sub(txt,4,(spos-1)))
		local message=string.sub(txt,(spos+1),string.len(txt))
		msg2(id,"ARGS: "..mid..","..message)
	end
end
addhook("say","pm")
function pm(p, t)
	local cmd, i = {}
	for w in string.gmatch(t, "[^ ]+") do table.insert(cmd, w) end
	if (cmd[1] == "pm") then
		local p_ = tonumber(cmd[2])
		if p_ then
			for i = 1, 2 do table.remove(cmd,1) end
			msg2(p,"You sent message for "..player(p_,"name"))
			msg2(p_,table.concat(cmd, " ")..", by "..player(p,"name"))
		end
	end
end