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 211 12 13338 339 Next To the start

old Re: Lua Scripts/Questions/Help

KimKat
GAME BANNED Off Offline

Quote
How do I add sv_sound to this code? I want a sound to play whenever someone joins.
1
2
3
4
addhook("join","sample.ads.join") 
function sample.ads.join(p,t) 
     msg("©254144060>> "..player(p,"name").." is connecting...") 
end

old Re: Lua Scripts/Questions/Help

wups
User Off Offline

Quote
1
2
3
4
5
addhook("join","sample.ads.join")
function sample.ads.join(p,t)
msg("©254144060>> "..player(p,"name").." is connecting...")
parse("sv_sound \"fun/connected.wav\"")
end

To all or to the person?

old Re: Lua Scripts/Questions/Help

MiroslavR
User Off Offline

Quote
vrkiller has written
i can't find the function how to draw some text on the screen

There are several commands how to draw a text on the HUD:
hudtxt (draw for everyone)
hudtxt2 (draw just for specified person)

Command Parameters:
√ hudtxt text id, text string, x, y, align
√ hudtxt2 id (of person who will see that text), text id, text string, x, y, align

If you're working with LUA a script, simply parse that with parse() function!

old Re: Lua Scripts/Questions/Help

vrkiller
User Off Offline

Quote
1
2
3
4
5
6
7
if sample==nil then sample={} end
sample.ads={}

addhook("join","sample.ads.join") 
function sample.ads.join(p) 
msg2(p, "©102255102ID connecting >> "..player(p,"name").."...") 
end
why do this don't work?

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
vrkiller has written
i can't find the function how to draw some text on the screen

Like MiroslavR said. I will show completed script.

txt = ("©255200000Text")
x = 360; y = 420; tid = 4
parse('hudtxt2 '..id..' '..tid..' "'..txt..'" '..x.." "..y)

^ thats working. you just should use usefull hook.

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
vrkiller has written
i can't find the function how to draw some text on the screen


1
2
3
4
function hudtext2(id,tid,color,txt,x,y)
	toprint = ("©"..color.." "..txt)
	parse('hudtxt2 '..id..' '..tid..' "'..toprint..'" '..x.." "..y)
end

This function may be useful for you :).
The parameters it takes are (in order):
-Player ID
-Text's ID
-Color (String). Ie: "255000000"
-Text to show
-X position on screen
-Y position on screen

old Re: Lua Scripts/Questions/Help

vrkiller
User Off Offline

Quote
thank you i get that pard
but i still can't get a response in my problem

1
2
3
4
5
6
7
if sample==nil then sample={} end 
sample.ads={} 

addhook("join","sample.ads.join") 
function sample.ads.join(p) 
msg2(p, "©102255102ID connecting >> "..player(p,"name").."...") 
end

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
vrkiller has written
thank you i get that pard
but i still can't get a response in my problem

1
2
3
4
5
6
7
if sample==nil then sample={} end 
sample.ads={} 

addhook("join","sample.ads.join") 
function sample.ads.join(p) 
msg2(p, "©102255102ID connecting >> "..player(p,"name").."...") 
end


vrkiller, do you get any error?
If you don't, the problem may be that you aren't using the dedicated server. When you create a new game (From CS2D), your player joins the server before the hooks can be attached. So you could change that "msg2" for a simple "msg" and make some bots join the server to test the script

old Re: Lua Scripts/Questions/Help

Marko1692
User Off Offline

Quote
I looked the lua but i don't know how to use it.for this i search a command i tried with the command mp_wpndmg but it didn't take negative values

old Re: Lua Scripts/Questions/Help

TimeQuesT
User Off Offline

Quote
1
2
3
4
5
6
addhook ("hit","hitt")
function hitt (id,source,weapon,hpdmg,apdmg)
if (weapon==22) then
parse ("sethealth "..id.." "..(player(id,"health")+5))
end
end

that script makes that the p90 heals

old Re: Lua Scripts/Questions/Help

DC
Admin Off Offline

Quote
a player does not run a Lua script. the server is the only one who runs a lua script.

most hooks have an id parameter. this parameter contains the id of the involved player in most cases.

old Re: Lua Scripts/Questions/Help

vrkiller
User Off Offline

Quote
oh ok, i am a bit clomsy to english
can i then ask can i make the hook "join" and save the id as a variable and move it to my speedmod function, ( or i mean can variables be global? or does they only work in the current hook)

old Re: Lua Scripts/Questions/Help

vrkiller
User Off Offline

Quote
why do it not work for me

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
if sample==nil then sample={} end 
sample.ads={} 

addhook("join","sample.ads.join") 
function sample.ads.join(id,id) 
msg(" Connected to VrKillers server") 
end 

addhook("parse","sample.ads.parse") 
function sample.ads.parse(txt) 
  if(txt=="speedmodon") then
  parse("speedmod "..id.." 100")
  msg("DOOOMMMEdddd!")
  end

  if(txt=="speedmodoff") then
  parse("speedmod "..id.." 0")
  msg("DOOOMMMEdddd!")
  end

end
To the start Previous 1 211 12 13338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview