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 2285 286 287338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

TDShuft
User Off Offline

Zitieren
Lee hat geschrieben
TDShuft hat geschrieben
can i make like if the player is stoped in hook second he gets +1 mp and if he walking he gets nothing


Yes and no. You will need to find the average velocity of the player and make sure that it's zero. This can be done quite easily:

1
2
3
4
5
6
7
8
9
10
11
12
13
pos = {}
addhook("second", "check_players_pos")
function check_players_pos()
	for _,id in player(0, "table") do
		if not pos[id] then pos[id] = {0,0} end
		local dx, dy = player(id,"x")-pos[id][0], player(id, "y")-pos[id][1]
		if dx == 0 and dy == 0 then 
			local health = "sethealth %s %s"
			parse(health:format(id, player(id, "health")+1))
		end
		pos[id][0], pos[id][1] = pos[id][0] + dx, pos[id][1] + dy
	end
end

but cant you see it with player(id,"speedmod")
?

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
TDShuft hat geschrieben
can i make like if the player is stoped in hook second he gets +1 mp and if he walking he gets nothing

Yes it's possible. Just use a timer. However, it might not be 100% accurate.

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
TDShuft hat geschrieben
but cant you see it with player(id,"speedmod")
?


There's a difference between average velocity and the ingame speed setting.

alt Re: Lua Scripts/Questions/Help

TDShuft
User Off Offline

Zitieren
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
addhook("move","pp")
function pp(id)
newx[id]=player(id,"x")
newy[id]=player(id,"y")
	if wkft[id]==0 then
		wkft[id]=1
		oldx[id]=player(id,"x")
		oldy[id]=player(id,"y")
	end
	if oldx[id]==newx[id] and oldy[id]==newy[id] and wkft[id]==1 then
		gh[id]=1
	else
		wkft[id]=0
	end
end
This Could Work Too.. I Think
gh[id] if 1 it will give 1 hp per sec

alt Re: Lua Scripts/Questions/Help

Snake_Eater
User Off Offline

Zitieren
Hi guys I have two questions

1.
Is there any math.function which returns the walking direction of a player like if a player goes left rad=270?

2.
I need help at this...

1
2
3
4
5
6
addhook ("say","lat")
function lat(p,t)
if (t == "[^","]+,[^","]+") then -- doesnt work
msg ("Works")
end
end

I want if somebody says :"(ONE OR MORE LETTERS UNEQUAL ",") (then a ",") (AND ONE OR MORE LETTERS UNEQUAL "," AGAIN)"


pls help

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
Snake_Eater hat geschrieben
1.
Is there any math.function which returns the walking direction of a player like if a player goes left rad=270?


That's not radians...

1
player(id, "rot") -- Returns the angle the player makes with the positive y-axis

Hence, if you're facing up, player(id, "rot") will return something close to 0.0, 90.0 if you're facing right, 180.0 if you're facing down, and -90.0 if you're facing left. (Note that everything within the second and third quadrant are negative. You can add 360 to the degrees and then take the modulus of the sum with 360 in order to normalize it).

1
(360+player(id, "rot"))%360

Mehr >


Snake_Eater hat geschrieben
1
2
3
4
5
6
addhook ("say","lat")
function lat(p,t)
if (t == "[^","]+,[^","]+") then -- doesnt work
msg ("Works")
end
end

I want if somebody says :"(ONE OR MORE LETTERS UNEQUAL ",") (then a ",") (AND ONE OR MORE LETTERS UNEQUAL "," AGAIN)"


1
2
3
4
5
6
7
8
function get_cmds(text)
	local _,last,match = text:find[["([^"]+)",?]]
	if match then 
		cmds = get_cmds(text:sub(last))
		return (match:match[[%s+,%s*]] and cmds) or {match, unpack(cmds)} 
	end
	return {}
end

Mehr >

alt badword=mute

Sudden Death
User Off Offline

Zitieren
I remake "badwords(sample) 1 word, and its show only message "You got muted" and next is spam "you are muted" but player can speak normal (i dont make the mute, i only got it from other) can somebody fix it : /
Spoiler >

alt Re: Lua Scripts/Questions/Help

TDShuft
User Off Offline

Zitieren
jaso55 hat geschrieben
I need this script:
When you say like hello then a dynwall goes away


1
2
3
4
5
6
addhook("say","dynwall")
function dynwall(id,txt)
	if txt=="hello" or txt=="Hello" or txt=="hi" or txt=="Hi" or txt=="Hia" or txt=="hia" then
		parse("trigger dynwall")
	end
end
this what you wanted or no ?

alt Hey Lua Need

11Razor11
User Off Offline

Zitieren
My Need

Teams
1:Terirst
2:Counter
3:Vip [USGN] info_vip helpme

alt Re: Lua Scripts/Questions/Help

Jaso
BANNED Off Offline

Zitieren
@TDShuft
Ok but now i want that you can use it once so if you say the word hi it goes open but after it the script disable it selfs

alt Re: Lua Scripts/Questions/Help

TDShuft
User Off Offline

Zitieren
jaso55 hat geschrieben
@TDShuft
Ok but now i want that you can use it once so if you say the word hi it goes open but after it the script disable it selfs

1
2
3
4
5
6
7
8
9
10
dynwall=0
addhook("say","dynwall")
function dynwall(id,txt)
	if dynwall==0 then
		if txt=="hello" or txt=="Hello" or txt=="hi" or txt=="Hi" or txt=="Hia" or txt=="hia" then
			parse("trigger dynwall")
			dynwall=1
		end
	end
end

alt Re: Lua Scripts/Questions/Help

Fehu
User Off Offline

Zitieren
Why this dont work ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
addhook("second","add_timer")
function add_timer(id)
    for id=1,32 do
        if start==1 then
            mr = math.random(1,4) 
            if mr == 1 then parse('trigger red') end;
            if mr == 2 then parse('trigger yellow') end;
            if mr == 3 then parse('trigger blue') end;
            if mr == 4 then parse('trigger green') end;
        end
    end
end

addhook("trigger","use")
function use(name)
    if(name=="start") then
        start=1
    end
end

addhook("startround","restart")
function restart(mode)
    start=0
end
This press red,yellow,blue,green button every second , i want random ONE button every sec ...

alt Re: Lua Scripts/Questions/Help

TDShuft
User Off Offline

Zitieren
Fehuziom hat geschrieben
Why this dont work ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
addhook("second","add_timer")
function add_timer(id)
    for id=1,32 do
        if start==1 then
            mr = math.random(1,4) 
            if mr == 1 then parse('trigger red') end;
            if mr == 2 then parse('trigger yellow') end;
            if mr == 3 then parse('trigger blue') end;
            if mr == 4 then parse('trigger green') end;
        end
    end
end

addhook("trigger","use")
function use(name)
    if(name=="start") then
        start=1
    end
end

addhook("startround","restart")
function restart(mode)
    start=0
end
This press red,yellow,blue,green button every second , i want random ONE button every sec ...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function add_timer(id)
    for id=1,32 do
        if start==1 then
            mr = math.random(1,4) 
            parse("trigger clr"..mr)
        end
    end
end

addhook("trigger","use")
function use(name)
    if(name=="start") then
        start=1
    end
end

addhook("startround","restart")
function restart(mode)
    start=0
end
put the name of the buttons clr1 for red clr2 for blue clr3 for yellow and clr4 for green
whatever
oh and : add_timer(id) why you put id if you using
for id=1,32 do o.O???

alt Re: Lua Scripts/Questions/Help

Loooser
User Off Offline

Zitieren
Can some one halp me with this
1
2
3
4
5
6
7
addhook("objectdamage","objectdamage")
function objectdamage(id,damage,player)
if player(player,"team")==object(id,"team") then
parse("killobject "..id)
parse("spawnobject "..object(id,"type").." "..(object(id,"tilex")+1).." "..object(id,"tiley").." 0 0 "..object(id,"team").." "..object(id,"player"))
end
end

thats what the consol sais
LUA ERROR: sys/lua/server.lua:3:attempt to call local 'player'(a number value)
Zum Anfang Vorherige 1 2285 286 287338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht