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 243 44 45338 339 Next To the start

old Re: Lua Scripts/Questions/Help

LilCoder
BANNED Off Offline

Quote
GlockPwner has written
Hello again... Here is my function and it doesn't work. Error is "attempting to call a nil value"

1
2
3
4
5
6
addhook("use","test2")
function test2(x,y)
if (x==80) and (y==32) then
print("abcdefg")
end
end
Help. Please!


try this:

1
2
3
4
5
6
addhook("use", "test2")
function test2(id, event, data, x, y)
if(  x==80 and y==32) then
	msg("abcdefg")
end
end

old Help

Banana-Phone
User Off Offline

Quote
MMmm... How can i make a classmenu for terrorists and a different classmenu for counterterrorists in the same map?

old Re: Lua Scripts/Questions/Help

LilCoder
BANNED Off Offline

Quote
From the top of my head!

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
67
68
69
70
71
my = {}

function initArray(m)
      local array = {}
      for i = 1, m do
           array[i]=0
      end
      return array
 end
 
my.players = initArray(32)

function my.classT(id)
    menu(id, "Terrorist Classes!, Killer | weapon, Noob | lol")
end

function my.classCT(id)
    menu(id, "CT Classes!, Police, cop, soldier")
end

addhook("team","my.team")
function my.team(id, team, look)	
    if (team==1) then
           my.classT(id)
           
    elseif (team==2) then
           my.classCT(id)
           
    end 
end

addhook("menu", "my.menu")
function my.menu(id, title, button)
    if(title == "Terrorist Classes!") then
        if(button <= 4  and button >=0) then
            my.players[id] = button
            if (player(id,"health")>0) then
                  parse("killplayer "..id)
           end             
        end
    
    
    elseif(title == "CT Classes!") then
        if(button <=4 and button >=0) then--number of entries in the menu
            my.players[id] = button
            if (player(id,"health")>0) then
                  parse("killplayer "..id)
           end
        end
    end            
end


addhook("spawn","my.spawn")
function my.spawn(id)
    if(player(id,"team")==1) then --terror
        if(my.players[id]==1) then --killer
            parse ("setmaxhealth "..id.." 150")
            return "";
        elseif(my.players[id]==2) then
            return "";
        end
    elseif(player(id,"team")==2) then
        if(my.players[id]==1) then --Police
            parse ("setmaxhealth "..id.." 100")
            return "25";
        elseif(my.players[id]==2) then
            return "81,24";
        end
    end
end

old Re: Lua Scripts/Questions/Help

playa slaya
COMMUNITY BANNED Off Offline

Quote
1
2
lim = 'mp_building_limit "%s" 1000'
parse (lim:format("Gate Field"))
[/quote]

ok i got it to work i forgot the extra ')' at the end

old Re: Lua Scripts/Questions/Help

ohaz
User Off Offline

Quote
@Banana-Phone:
Rotating after each round? :
1
2
3
4
5
6
7
8
9
10
11
12
13
addhook("endround", "rotateround")
function rotateround()
for i=1,32,1 do
	if player(i,"exists") then
		if player(i, "team") = 1 then --don't know exactly about this number, perhaps you have to write a 2 here and a 1 down there
			parse("makect "..i)
		end
		if player(i,"team") = 2 then
			parse("maket "..i)
		end
	end
end
end

old Re: Lua Scripts/Questions/Help

LilCoder
BANNED Off Offline

Quote
TheKilledDeath has written
@Banana-Phone:
Rotating after each round? :
1
2
3
4
5
6
7
8
9
10
11
12
13
addhook("endround", "rotateround")
function rotateround()
for i=1,32,1 do
	if player(i,"exists") then
		if player(i, "team") = 1 then --don't know exactly about this number, perhaps you have to write a 2 here and a 1 down there
			parse("makect "..i)
		end
		if player(i,"team") = 2 then
			parse("maket "..i)
		end
	end
end
end


Lol Epic Fail!
1
2
3
4
5
if( player(i, "team") ==2)  then
	parse("maket "..i)
elseif( player(i, "team")==1) then
	parse("makect "..i)
end

old Re: Lua Scripts/Questions/Help

ohaz
User Off Offline

Quote
LilCoder has written
TheKilledDeath has written
...


Lol Epic Fail!
1
2
3
4
5
if( player(i, "team") ==2)  then
	parse("maket "..i)
elseif( player(i, "team")==1) then
	parse("makect "..i)
end
Lol shit, you're right I'm too much into Delphi Pascal atm

old Re: Lua Scripts/Questions/Help

LilCoder
BANNED Off Offline

Quote
saladface27 has written
can you write lua code statements (eg xyz=10) into a map/mapfile?


Yes, it's called a lua map.

You should name your script the same as your map.

For example, if you have a map called de_dust.map, then you should put a lua file called de_dust.lua (inside cs2d/maps folder) and it will execute the de_dust.lua whenever you start the map de_dust.

old Re: Lua Scripts/Questions/Help

playa slaya
COMMUNITY BANNED Off Offline

Quote
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
To the start Previous 1 243 44 45338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview