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 2276 277 278338 339 Next To the start

old Re: Lua Scripts/Questions/Help

244453211332112
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
addhook("hit","healgun")
function healgun(id)
if level[id] == 4 then
local x, y
x = player( id, "x")
y = player( id, "y")
           parse('effect "fire" ' ..x.. ' ' ..y.. ' 1 1 0 0 0')
           parse("sethealth "..id.." "..(player(id,"health")-7))
end
end

u must write: if level[id] == 4 then
not: if level[id] >= 4 then

old Re: Lua Scripts/Questions/Help

head600
BANNED Off Offline

Quote
if i make if level[id] == 4 then
only work on 4level not 5-6-7.....

if i make if level[id] >= 4 then

work on 5-6-7.....

-.-"

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Try this:
1
2
3
4
5
6
7
8
9
addhook("hit","healgun")
function healgun(id,src,wp)
	if level[src] >= 4 then
		local x = player( id, "x")
		local y = player( id, "y")
		parse('effect "fire" ' ..x.. ' ' ..y.. ' 1 1 0 0 0')
		parse("sethealth "..id.." "..(player(id,"health")-7))
	end
end
Tell me if you get any console errors.

old Re: Lua Scripts/Questions/Help

244453211332112
User Off Offline

Quote
Hi what it is meaning this:
Quote
sys/lua/rp.lua:1116 nesting of [[...]] is deprecated near '['


by this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
addhook([[use]],[[carmod_use]])
function carmod_use(id,event,data,x,y)
	if event == 0 then
		if pic[id] == 0 then
			if player(id,[[tilex]])==car_tx[id] and player(id,[[tiley]])==car_ty[id] then
				freeimage(car_img_pos[id])
				pl_speed[id]=player(id,[[speedmod]])
				car_img[id]=image([[gfx\car_img.bmp]],1,1,200+id) -- 423 Coloque onde esta o img do carro
				parse([[speedmod ]]..id..[[ -100]])
				pic[id]=1
			end
		elseif pic[id]==1 then
			freeimage(car_img[id])
			parse([[speedmod ]]..id..[[ ]]..pl_speed[id])
			car_tx[currentcar[id]]=player(id,[[tilex]])
			car_ty[currentcar[id]]=player(id,[[tiley]])
			car_img_pos[id]=image([[gfx\car_img.bmp],1,1,1) -- 423 Coloque onde esta o img do carro
			imagepos(car_img_pos[id],player(id,[[x]]),player(id,[[y]]),player(id,[[rot]]))
			pic[id]=0
		end
	end
end



1116 is: imagepos(car_img_pos[id],player(id,[[x]]),player(id,[[y]]),player(id,[[rot]]))

old Re: Lua Scripts/Questions/Help

maPmaKer
User Off Offline

Quote
1. Well hello. I would like to know if there can be possible to make a lua where to say:

If map is de_dust then apply following settings:
sv_maxplayers 32
mp_building_limit Turret 10
trigger (an entity)

and then in the same lua

If map is de_dust2 then apply following settings:
sv_maxplayers 30

etc.

2. Is there a way to add colors to UTSFX when it says "Players sheds first blood" or another message? I tryed to add but it's not working

Any help for those both problems of mine?

old Re: Lua Scripts/Questions/Help

Twisted
User Off Offline

Quote
Is there anyway to keep the normal money full while using this lua? So i can use build stuff still? It's a custom money thingy by weiwen.

Edit: Or better yet, a way to build stuff without money?

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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
local dir = "sys/lua/saves/"
PLAYERS = {}

function addmoney(id, amount)
     if PLAYERS[id].money + amount >= 0 then
          parse(string.format("setmoney %i 0", id))
          PLAYERS[id].money = PLAYERS[id].money + amount
          parse(string.format("hudtxt2 %i 49 \"©255100100Money : %i\" 0 100", id, PLAYERS[id].money))
          return true
     end
     return false
end

function getmoney(id)
     return PLAYERS[id].money
end

addhook("join", "RPjoin")
function RPjoin(id)
     local playerfile = io.open(dir..player(id,"usgn")..".txt","r")
     if playerfile then
          PLAYERS[id] = {}
          for v in playerfile:lines() do
               local find = v:find"="
               key = v:sub(1,find-1)
               key = tonumber(key) or key
               val = v:sub(find+1)
               val = tonumber(val) or val
               PLAYERS[id][key] = val
          end
          playerfile:close()
     else
          PLAYERS[id] = {
               money = 0,
          }
     end
end

addhook("second", "RPsecond")
function RPsecond()
     for _, id in ipairs(player(0, "table")) do
          parse(string.format("setmoney %i 0", id))
          if PLAYERS[id] then
               parse(string.format("hudtxt2 %i 49 \"Money : %i\" 0 0", id, PLAYERS[id].money))
          end
     end
end

addhook("leave", "RPleave")
function RPleave(id)
     if PLAYERS[id] and player(id,"usgn") ~= 0 then
          local playerfile = io.open(dir .. player(id,"usgn") .. ".txt","w+") or io.tmpfile()
          local text = ""
          for i, v in pairs(PLAYERS[id]) do
               text = text .. i .. "=" .. tostring(v) .. "\n"
          end
          text = text:sub(1,-2)
          playerfile:write(text)
          playerfile:close()
     end
     PLAYERS[id] = nil
end

addhook("collect", "RPcollect")
function RPcollect(id,iid,type,ain,a,mode)
     if type == 66 then
          addmoney(id, 100)
     elseif type == 67 then
          addmoney(id, 1000)
     elseif type == 68 then
          addmoney(id, 10000)
     end
end

addhook("menu", "RPmenu")
function RPmenu(id, title, button)
     if title == "Drop Money" then
          if button == 0 then
               return
          end
          menu(id, "Drop Money,10,500,1000,5000,10000,50000,100000")
          if button == 1 then
               if addmoney(id, -100) then
                    parse(string.format("spawnitem 66 %i %i", player(id, "tilex"), player(id, "tiley")))
               end
          elseif button == 2 then
               if addmoney(id, -500) then
                    local spawn = string.format("spawnitem 66 %i %i", player(id, "tilex"), player(id, "tiley"))
                    for i = 1, 5 do
                         parse(spawn)
                    end
               end
          elseif button == 3 then
               if addmoney(id, -1000) then
                    parse(string.format("spawnitem 67 %i %i", player(id, "tilex"), player(id, "tiley")))
               end
          elseif button == 4 then
               if addmoney(id, -5000) then
                    local spawn = string.format("spawnitem 67 %i %i", player(id, "tilex"), player(id, "tiley"))
                    for i = 1, 5 do
                         parse(spawn)
                    end
               end
          elseif button == 5 then
               if addmoney(id, -10000) then
                    parse(string.format("spawnitem 68 %i %i", player(id, "tilex"), player(id, "tiley")))
               end
          elseif button == 6 then
               if addmoney(id, -50000) then
                    local spawn = string.format("spawnitem 68 %i %i", player(id, "tilex"), player(id, "tiley"))
                    for i = 1, 5 do
                         parse(spawn)
                    end
               end
          elseif button == 7 then
               if addmoney(id, -100000) then
                    local spawn = string.format("spawnitem 68 %i %i", player(id, "tilex"), player(id, "tiley"))
                    for i = 1, 10 do
                         parse(spawn)
                    end
               end
          end
     end
end

addhook("serveraction", "RPserveraction")
function RPserveraction(id,action)
     if action == 2 then
          menu(id, "Drop Money,10,500,1000,5000,10000,50000,100000")
     end
end

addhook("movetile", "RPmovetile")
function RPmovetile(id,x,y)
     if PLAYERS[id].x and PLAYERS[id].y and entity(x, y, "typename") ~= "Info_T" and entity(x, y, "typename") ~= "Info_CT" then
          PLAYERS[id].x, PLAYERS[id].y = x, y
     end
end

addhook("spawn", "RPspawn")
function RPspawn(id)
     if PLAYERS[id].x and PLAYERS[id].y then
          parse(string.format("setpos %i %i %i", id, PLAYERS[id].x*32+16, PLAYERS[id].y*32+16))
     end
     return ""
end

addhook("die", "RPdie")
function RPdie(victim,killer,weapon,x,y)
     PLAYERS[victim].x, PLAYERS[victim].y = nil, nil
end

old Re: Lua Scripts/Questions/Help

RAVENOUS
BANNED Off Offline

Quote
maPmaKer has written
1. Well hello. I would like to know if there can be possible to make a lua where to say:

If map is de_dust then apply following settings:
sv_maxplayers 32
mp_building_limit Turret 10
trigger (an entity)

and then in the same lua

If map is de_dust2 then apply following settings:
sv_maxplayers 30

etc.

2. Is there a way to add colors to UTSFX when it says "Players sheds first blood" or another message? I tryed to add but it's not working

Any help for those both problems of mine?


1st: Possible with parsing commands,
1
parse("equip 1 83")

2nd: Possible with © ( Alt+8888 ) and the RGBs behind.
©255000000 = RED
©000255000 = GREEN
©000000255 = BLUE

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
@Nexmann:
Look at lines 1115 - 1116

1
2
car_img_pos[id]=image([[gfx\car_img.bmp],1,1,1) -- 423 Coloque onde esta o img do carro
               imagepos(car_img_pos[id],player(id,[[x]]),player(id,[[y]]),player(id,[[rot]]))

In line 1115, you did not close the string [[gfx\car_img.bmp]

So the entire string is actually

1
gfx\car_img.bmp],1,1,1) -- 423 Coloque onde esta o img do carro\n               imagepos(car_img_pos[id],player(id,[[x

You can see how this might cause quite a bit of trouble... To fix this issue, simply add in another ] to line 1115

1
[[gfx\car_img.bmp]]

Also, whenever possible, never use \ to denote directories as Lua evaluates \ as a control character. Use / instead. Hence replace all instances of \ with /.

old Re: Lua Scripts/Questions/Help

244453211332112
User Off Offline

Quote
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
parse("msg Hello and Welcome at my Server")
            parse("equip "1" 1")
            parse("equip "1" 2")
            parse("equip "1" 3")
            parse("equip "1" 4")
            parse("equip "1" 5")
            parse("equip "1" 6")
            parse("equip "1" 7")
            parse("equip "1" 8")
            parse("equip "1" 9")
            parse("equip "1" 10")
            parse("equip "1" 11")
            parse("equip "1" 12")
            parse("equip "1" 13")
            parse("equip "1" 14")
            parse("equip "1" 15")
            parse("equip "1" 16")
            parse("equip "1" 17")
            parse("equip "1" 18")
            parse("equip "1" 19")
            parse("equip "1" 20")
            parse("equip "1" 21")
            parse("equip "1" 22")
            parse("equip "1" 23")
            parse("equip "1" 24")
            parse("equip "1" 25")
            parse("equip "1" 26")
            parse("equip "1" 27")
            parse("equip "1" 28")
            parse("equip "1" 29")
            parse("equip "1" 30")
end

what is false at this?

old Re: Lua Scripts/Questions/Help

maPmaKer
User Off Offline

Quote
Skipper has written
maPmaKer has written
1. Well hello. I would like to know if there can be possible to make a lua where to say:

If map is de_dust then apply following settings:
sv_maxplayers 32
mp_building_limit Turret 10
trigger (an entity)

and then in the same lua

If map is de_dust2 then apply following settings:
sv_maxplayers 30

etc.

2. Is there a way to add colors to UTSFX when it says "Players sheds first blood" or another message? I tryed to add but it's not working

Any help for those both problems of mine?


1st: Possible with parsing commands,
1
parse("equip 1 83")

2nd: Possible with © ( Alt+8888 ) and the RGBs behind.
©255000000 = RED
©000255000 = GREEN
©000000255 = BLUE


2nd: I know how to add colors but I don't know whr to put the code of them. I mean if I put near "player" it doesn't working or something like that.

1st: I know parsing but I need to apply them for separate maps.

old Re: Lua Scripts/Questions/Help

244453211332112
User Off Offline

Quote
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
parse("msg Hello and Welcome at my Server")
            parse("equip 1 1")
            parse("equip 1 2")
            parse("equip 1 3")
            parse("equip 1 4")
            parse("equip 1 5")
            parse("equip 1 6")
            parse("equip 1 7")
            parse("equip 1 8")
            parse("equip 1 9")
            parse("equip 1 10")
            parse("equip 1 11")
            parse("equip 1 12")
            parse("equip 1 13")
            parse("equip 1 14")
            parse("equip 1 15")
            parse("equip 1 16")
            parse("equip 1 17")
            parse("equip 1 18")
            parse("equip 1 19")
            parse("equip 1 20")
            parse("equip 1 21")
            parse("equip 1 22")
            parse("equip 1 23")
            parse("equip 1 24")
            parse("equip 1 25")
            parse("equip 1 26")
            parse("equip 1 27")
            parse("equip 1 28")
            parse("equip 1 29")
            parse("equip 1 30")
end


what is false at this?

old Anti-MapSteal

hyh2
COMMUNITY BANNED Off Offline

Quote
Hello.

Can anyone code me little code?

Here's example how it need to work:

If ADMIN USGN id isint 123456 then
loop to center "MAP IS STOLED FROM HYH2!"


Ohh, and knockback too.
Make me that too if you're not lazy.
And if this works, i'll MAYBE give carmod script, remember MAYBE.

old Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Quote
RyceR has written
RyceR has written
Give me poison script with 5% chance, plz.

Please give me that script


WAAAH POSION? ARE YOU F*CKING CRAZY!!! XDDDDD
Btw, what you mean with poison tell us more
To the start Previous 1 2276 277 278338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview