Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Lua Scripts/Questions/Help

6.770 Antworten
Seite
Zum Anfang Vorherige 1 211 12 13338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

KimKat
GAME BANNED Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

wups
User Off Offline

Zitieren
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?

alt Re: Lua Scripts/Questions/Help

MiroslavR
User Off Offline

Zitieren
vrkiller hat geschrieben
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!

alt Re: Lua Scripts/Questions/Help

vrkiller
User Off Offline

Zitieren
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?

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
vrkiller hat geschrieben
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.

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
vrkiller hat geschrieben
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

alt Re: Lua Scripts/Questions/Help

vrkiller
User Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
vrkiller hat geschrieben
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

alt Need some help pls.

Joni
User Off Offline

Zitieren
Can anyone tell me the command to type in the console to make an gun heal?PLS

alt Re: Lua Scripts/Questions/Help

Joni
User Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

TimeQuesT
User Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

DC
Admin Off Offline

Zitieren
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.

alt Re: Lua Scripts/Questions/Help

vrkiller
User Off Offline

Zitieren
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)

alt Re: Lua Scripts/Questions/Help

vrkiller
User Off Offline

Zitieren
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
Zum Anfang Vorherige 1 211 12 13338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht