Could someone do this code for me?
when pressing button = 1 random player of the terrorist team in pos x and y.(svmsg; Jason is here!)
I tried to do it by myself but I lost my time.
Thanks for the help in advance
Scripts
Button = setpos
Button = setpos
1

addhook("usebutton","usebutton_hook")
function usebutton_hook(id,x,y)
if (x==20)and(y==3) then
parse("setpos "..id.." 12 9")
msg(player(id,"name").." IS THERE!")
end
end
princeofpersia: He wants one random terrorist and probably one that is in a certain area. I didn't really catch the second part of what he wants.
cs2d_is_a_Gem has written
Yates: sorry i see this now
teleported={}
addhook("join","join_hook")
addhook("usebutton","usebutton_hook")
function join_hook(id)
teleported[id]=false
end
function usebutton_hook(id,x,y)
if (x==20)and(y==3) then
randome={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}
local target=randome[math.random(1,#randome)]
if player(target,"exists") then
if teleported[target]==false then
parse("setpos "..target.." 12 9")
teleported[target]=true
msg(player(target,"name").." IS THERE!")
else
usebutton_hook(id,20,3)
end
else
usebutton_hook(id,20,3)
end
end
end
Yates: im not pro scripter
but this can be a good script with some changes
randome={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}
math.random(1,32)
Yates, Why do not you help with the lua problem instead of writing so much shit? i do not see you being helpful writing just shit here.
cs2d_is_a_Gem, good luck with what you're looking for!
prochazka: Oh the irony in your post just made my day.
princeofpersia: You still need to check whether the player is a terrorist, is alive, reset your teleportedvariable, make sure this function doesn't trigger a C stack overflow (because it will) and I definitely don't advise triggering a function that belongs to a hook. Separate your code.
Thanks for the help guys.
@
Yates: you're right in the comment that you added. Solution?
where is @
Cure Pikachu: when you need it?
I hope someone fixes the @
princeofpersia: code so they can put Jason online again.
Only players alive at that moment, the dead must be dead!

target_x = 12
target_y = 9
addhook("usebutton","usebutton_hook")
function usebutton_hook(id,x,y)
	if (x==20) and (y==3) then
		-- Random living terrorist
		local t = player(0,"team1living")
		local target = t[math.random(1,#t)]
		-- I just realised the given numbers are tile positions...
		parse("setpos "..target.." "..target_x*32+16.." "..target_y*32+16)
		msg(player(target,"name").." IS THERE!")
	end
end
Thanks, right on the spot! 5/5
1
