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 2285 286 287338 339 Next To the start

old Re: Lua Scripts/Questions/Help

TDShuft
User Off Offline

Quote
Lee has written
TDShuft has written
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")
?

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
TDShuft has written
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.

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
TDShuft has written
but cant you see it with player(id,"speedmod")
?


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

old Re: Lua Scripts/Questions/Help

TDShuft
User Off Offline

Quote
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

old Re: Lua Scripts/Questions/Help

Snake_Eater
User Off Offline

Quote
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

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
Snake_Eater has written
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

More >


Snake_Eater has written
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

More >

old badword=mute

Sudden Death
User Off Offline

Quote
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 >

old Re: Lua Scripts/Questions/Help

TDShuft
User Off Offline

Quote
jaso55 has written
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 ?

old Hey Lua Need

11Razor11
User Off Offline

Quote
My Need

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

old Re: Lua Scripts/Questions/Help

Jaso
BANNED Off Offline

Quote
@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

old Re: Lua Scripts/Questions/Help

TDShuft
User Off Offline

Quote
jaso55 has written
@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

old Re: Lua Scripts/Questions/Help

Fehu
User Off Offline

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

old Re: Lua Scripts/Questions/Help

TDShuft
User Off Offline

Quote
Fehuziom has written
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???

old Re: Lua Scripts/Questions/Help

Loooser
User Off Offline

Quote
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)
To the start Previous 1 2285 286 287338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview