Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Scripts/Questions/Help

6,770 replies
Page
To the start Previous 1 244 45 46338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Banana-Phone
User Off Offline

Quote
i have a little problem...
wheres the problem?


sample.classes.words = {"!stealth"}
addhook("say","sample.classes.say")
function sample.classes.say(p,t)
     t=string.lower(t)
     for i = 1,#sample.classes.words do
          if (string.find(t,sample.classes.words[i])~=nil) then
               if (sample.classes.class[id]==2) then
                    parse("speedmod "..p.." -2")
                    parse("setarmor "..p.." 206")
                    return 1
               end
          end
     end
end
sample.classes.words2 = {"!nostealth"}
addhook("say","sample.classes.say2")
function sample.classes.say2(p,t)
     t=string.lower(t)
     for i = 1,#sample.classes.words2 do
          if (string.find(t,sample.classes.words2[i])~=nil) then
               if (sample.classes.class[id]==2) then
                    parse("speedmod "..p.." 0")
                    parse("setarmor "..p.." 0")
                    return 1
               end
          end
     end
end

old Re: Lua Scripts/Questions/Help

LilCoder
BANNED Off Offline

Quote
playa slaya has written
hey,im having trouble with this i need it to equip a snowball
if that player got hit by a snowball but only one snowball.

addhook("hit","Snowball_equip")
function Snowball_equip(id,source,weapon,equip)
if(weapon == 75) then
parse ("equip "..id.." "..player(id,"weapon") 75)
return 1
end
end


the normal function is: equip id weaponid

1
2
3
4
5
6
7
addhook("hit","Snowball_equip") 
function Snowball_equip(id,source,weapon,equip) 
if(weapon == 75) then 
	parse ("equip "..id.." 75") 
        return 1
end
end

Banana-Phone has written
i have a little problem...
wheres the problem?


remove: "if (sample.classes.class[id]==2) then" and "end"
id is not defined in this function...
or use: "if(sample.classes.class[p]==2) then".... instead of the above.

old Re: Lua Scripts/Questions/Help

LilCoder
BANNED Off Offline

Quote
Banana-Phone has written
ohhh thanks

How can I make a script where pressing any key makes an action?


currently, the keys that can make an action are the use key ( e) :


addhook("use", "my_use")
function my_use(id, event, data, x, y)
     --action
end

and serveraction1,2,3 (F2, F3, F4 by default)
addhook("serveraction","my_serveraction")
function my_serveraction(id, action)
     --action
end

old Re: Lua Scripts/Questions/Help

saladface27
User Off Offline

Quote
when i disable teamchange it disables parsing "maket 1" etc.

is there any way to disable teamchanging from the teamchange menu but not disabling the parsing commands?

old instant tripple turrets**need help**

younes
COMMUNITY BANNED Off Offline

Quote
Vibhor has written
I found that kind of script somewhere
i dont remember
It really exists........ Yes really
i want that good script so badly


i was asking for help and for that its bin more than a month som ppl helped but there ideas didnt work could anyone help me with it now???
nedd help with this:
younes has written
what wups suggested(didnt work)
1
2
3
4
5
6
7
8
9
addhook("build","no_site")
function no_site(id)
	return 1
end

addhook("build","no_sitenow")
function no_sitenow(id,type,x,y)
	parse("spawnobject "..type.." "..x.." "..y.." 90 1 "..player(id,"team").." "..id)
end
what i tryde:(didn work)
1
2
3
4
5
6
7
8
9
addhook("build","no_upgrade")
function no_upgrade(id)
	return 1
end

addhook("build","no_upgradenow")
function no_sitenow(id,type,x,y)
	parse("spawnobject "..type.." "..x.." "..y.." 90 1 "..player(id,"team").." "..id)
end
all i did was changing the
1
no_site
bye
1
no_upgrade
and it dosnt work

and maybe it exist but i didnt find it

old player location finder??

Toa Hero 92
User Off Offline

Quote
Hi, I need a script to find a players location. More specifically I want to be able to type something like this in to the console (if i have the rcon or am admin/server) :

find <player id>


and the output would be (in a sv_msg2 to the player who typed it) Player <id> is at <x> <y>.

Please and thank you for your help.

old Re: Lua Scripts/Questions/Help

younes
COMMUNITY BANNED Off Offline

Quote
Toa Hero 92 has written
Hi, I need a script to find a players location. More specifically I want to be able to type something like this in to the console (if i have the rcon or am admin/server) :

find <player id>


and the output would be (in a sv_msg2 to the player who typed it) Player <id> is at <x> <y>.

Please and thank you for your help.

thats more kind of like a hack...

old replie to prev

Toa Hero 92
User Off Offline

Quote
it is not a hack if server or admin and i still need this



Hi, I need a script to find a players location. More specifically I want to be able to type something like this in to the console (if i have the rcon or am admin/server) :

find <player id>


and the output would be (in a sv_msg2 to the player who typed it) Player <id> is at <x> <y>.

Please and thank you for your help.

if you send a completed code pls private message me it
edited 1×, last 26.08.09 11:43:27 pm

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
Toa Hero 92 has written
find <player id>


and the output would be (in a sv_msg2 to the player who typed it) Player <id> is at <x> <y>.


It's included in AMX2D as the @getpos and @gettile command

@getpos <ID>
@gettile <ID>

You can use this directly by downloading amx2d (http://download.amx2d.co.cc) or view the code for the @getpos command at

http://github.com/leegao/AMX-Mod-2D/blob/9ccb32e5320e37f091d7814147b862ba14a82e47/core/basic.lua#L111

old thank you, but...

Toa Hero 92
User Off Offline

Quote
Thank you, but i would perfer it if was just a lua script and not a complete modification

old Re: Lua Scripts/Questions/Help

LilCoder
BANNED Off Offline

Quote
Ported it...

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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
--Toa:
--string library by leegao
function string.trim(t)
	t = string.split(t)
	s = ""
	if not t then return end
	for i, v in ipairs(t) do
		s = s.." "..v
	end
	s = string.sub(s, 2)
	return s
end

function string.split(t, b)
	local cmd = {}
	local match = "[^%s]+"
	if b then
		match = "%w+"
	end
	if type(b) == "string" then match = "[^"..b.."]+" end
	if not t then return invalid() end
	for word in string.gmatch(t, match) do
		table.insert(cmd, word)
	end
	return cmd
end

function string.qsplit(t)
	local tab = string.split(t, '"')
	if #tab == 1 then
		return string.split(tab[1])
	end
	local ret = {}
	for i, v in ipairs(tab) do
		if i%2 == 0 then
			table.insert(ret, v)
		else
			v = string.split(v)
			for _i, _v in ipairs(v) do
				table.insert(ret, _v)
			end
		end
	end
	return ret
end



addhook("say","my_say")
function my_say(id, msg)
	text = string.trim(msg)
	text = string.qsplit(text)
	local cmd = text[1]

	if(cmd =="!find") then
		local i = tonumber(text[2])
		msg2(id, string.format("%s is located at (%s, %s)", player(i, "name"), math.ceil(player(i, "x")), math.ceil(player(i, "y"))))
		return 1;
	end

	if(cmd == "!findtile") then
		local i = tonumber(text[2])
		msg2(id, string.format("%s is located at tiles: (%s, %s)", player(i, "name"), player(i, "tilex"), player(i, "tiley")))
		return 1;
	end		
end

[quote = "saladface27"]

when i disable teamchange it disables parsing "maket 1" etc.

is there any way to disable teamchanging from the teamchange menu but not disabling the parsing commands?
[/quote]

no
edited 1×, last 27.08.09 10:40:46 am

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
Vectar666 has written
Is there a command to set return values in lua?


Via overloading the function - yes, this is efficient for writing abstract enhancements to Lua

old my previous post

Toa Hero 92
User Off Offline

Quote
Thanks Lil, i guess that will work, but, isn't as uncomplicated as i would have liked it, but i like that you did it for me so thank you, very much.


And does anyone have tutorials for lua scripting to cs2d?
To the start Previous 1 244 45 46338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview