Forum

> > CS2D > Scripts > Target command ?
Forums overviewCS2D overview Scripts overviewLog in to reply

English Target command ?

4 replies
To the start Previous 1 Next To the start

old Target command ?

Rygna
User Off Offline

Quote
hello!
here is furty

• can you help me? , if target is exists in Lua scripts? , but how to make it ?

> This my broken lua scritps.
1
2
3
4
5
6
7
addhook("say","_say")
function _say(id,txt)
	if txt == "!slap" then
		parse("slap "..target)
		msg("©255255255Admin use command "..txt)
	end
end
But that scripts error? <

i just want target id , and how that work?,
if you can help me, pls Share or give me example OK?
btw.. , thanks..

old Re: Target command ?

VADemon
User Off Offline

Quote
Check existing scripts.

"Target exists"
1
if player(targetID, "exists") == true then
"Target iz alive"
1
if player(targetID, "health") ~= 0 then

You use the "target" variable in line 4, but you didn't define it. The only defined variables are "id" and "txt" because they're the input for the _say function in line 2.

old Re: Target command ?

_oops
User Off Offline

Quote
wrote this on mobile, so I'm not sure it has bug or not.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook("say","_say")
function _say(id,txt)
 if txt:sub(1,5) == "!slap" then         
 local target=txt:sub(7)
  if type(target)=="number" then
   if player(target,"exists")==true and player(target,"health")>0 then
   parse("slap "..target) 
   msg("©255255255Admin use command "..txt:sub(2,5)) 
   else
   msg2(id,"\169255000000ID : "..target.." does not exist or player is dead.")
   end
  else
  msg2(id,"\169255000000Numbers only!")
  end
 end
end

old Re: Target command ?

Talented Doge
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
prefix = "@"

addhook("say", "_say")

function _say(p, t)
	if t:sub(1,1) == prefix then
		if t:sub(2,5) == "slap" then
			local tgt = t:sub(7,8)
			if player(tgt, "exists") then parse ("slap "..tgt) else msg2 (p, "\169195195195Player with id "..tgt.." doesn't exist!") end
		end
	end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview