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
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
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
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)
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.
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