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 2290 291 292338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Yasday
User Off Offline

Quote
Nelight has written
addhook("minute","msjes")
function msjes()

This is for 60 secound.
How to make more then 60 secound?


1
2
3
4
5
6
7
8
9
10
dd = 0

addhook("minute","msjes")
function msjes()
	dd = dd + 1
	if dd == 30 then
		dd = 0
		.....
	end
end

old Re: Lua Scripts/Questions/Help

The Camo
User Off Offline

Quote
Can anyone solve the problem? It gives error at "elseif".

It should do: when level is bigger then others in the team, send message like: player is commander in t/ct team.

I tried editing it so many times, with so many combinations so I got lost in all of this, I can bet that whole script is wrong now.

addhook("team","team")
function team(id,team)
     for id = 1,32 do
          if player(id,"team") == 1 and player(id,level[id]) == math.max(level[id]) then
               if (player(id,"exists")) then
                    msg("©255075000"..player(id,"name").." has became Commander in "..player(id,"team").." team!")
                    msg2(id,"©000255000 You are now Commander of "..player(id,"team").." team!@C")          
               end
          end
     elseif player(id,"team") == 2 and player(id,level[id]) == math.max(level[id]) then
          if (player(id,"exists")) then
               msg("©255075000"..player(id,"name").." has became Commander in "..player(id,"team").." team!")
               msg2(id,"©000255000 You are now Commander of "..player(id,"team").." team!@C")          
          end
     end
end

Can someone Correct it?
Thanks

old Re: Lua Scripts/Questions/Help

TDShuft
User Off Offline

Quote
Starkkz has written
Snake_Eater has written
yes and... can you help me?

I need a table in a table is it right because it will show up error

1
2
tbl = {{1}}
print (tbl[1[1]])

help pls


That's easy.
1
2
tbl = {{1}}
print(tbl[1][1])

You tried to get a value from a table using another table value.

wow i can use table to make a item list but would be hard anyway
i will make 23 items :S

@Nexmann lol like in wwf gaming ? if is it do this :
1
2
3
4
5
6
7
restart=0
addhook("ms100","restart")
function restart()
if restart=0 then
timer(35900,"parse","restart 1",1)
end
end
edited 1×, last 25.10.10 11:26:50 pm

old Re: Lua Scripts/Questions/Help

Chex
User Off Offline

Quote
I have a question too. Am I doing anything wrong here?
1
2
3
4
function kamikaze
player(id,"value")
	parse("explosion "value[11]" "value[12]" 200 100 "..id)
parse("bind F kamikaze")
I did my research in info.txt, but I don't know if it returns player value as a table.
I guessed it did.
And I think my binding code is erroneous.

old Re: Lua Scripts/Questions/Help

TDShuft
User Off Offline

Quote
Arcas has written
I have a question too. Am I doing anything wrong here?
1
2
3
4
function kamikaze
player(id,"value")
	parse("explosion "value[11]" "value[12]" 200 100 "..id)
parse("bind F kamikaze")
I did my research in info.txt, but I don't know if it returns player value as a table.
I guessed it did.
And I think my binding code is erroneous.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
addhook("serveraction","serveraction")
function serveraction(id,action)
if action==3 then
if player(id,"health")~=0 then
kamikaze(id)
end
end
end
function kamikazing(id)
timer(1000,"parse","sv_msg2 "..id.." 3@C")
timer(2000,"parse","sv_msg2 "..id.." 2@C")
timer(3000,"parse","sv_msg2 "..id.." 1@C")
end
function kamikaze(id)
if player(id,"exists") then
timer(4000,"parse","explosion "..player(id,"x").." "..player(id,"y").." 375 531 "..id,1)
parse("speedmod "..id.." "..player(id,"speedmod")+7)
kamikazing(id)
end
end
you cant bind for players , just they can bind for their selfes
so i made kamikaze in "F4" ok
oh and this will make the kamikaze in 4 secs
edited 1×, last 26.10.10 12:09:44 am

old Re: Lua Scripts/Questions/Help

Chex
User Off Offline

Quote
I see now.
With player I can use those values by typing in the name of the value.
I think I'm starting to understand LUA.

old Re: Lua Scripts/Questions/Help

TDShuft
User Off Offline

Quote
@The Camo:
addhook("team","team")
function team(id,team)
for id = 1,32 do
if player(id,"team") == 1 and player(id,level[id]) == math.max(level[id]) then
if (player(id,"exists")) then
msg("©255075000"..player(id,"name").." has became Commander in "..player(id,"team").." team!")
msg2(id,"©000255000 You are now Commander of "..player(id,"team").." team!@C")
end
end -- <<<<< error , if you want to use else if remove this..
elseif player(id,"team") == 2 and player(id,level[id]) == math.max(level[id]) then
if (player(id,"exists")) then
msg("©255075000"..player(id,"name").." has became Commander in "..player(id,"team").." team!")
msg2(id,"©000255000 You are now Commander of "..player(id,"team").." team!@C")
end
end
end

old Re: Lua Scripts/Questions/Help

The Camo
User Off Offline

Quote
TDShuft has written
@The Camo:
addhook("team","team")
function team(id,team)
for id = 1,32 do
if player(id,"team") == 1 and player(id,level[id]) == math.max(level[id]) then
if (player(id,"exists")) then
msg("©255075000"..player(id,"name").." has became Commander in "..player(id,"team").." team!")
msg2(id,"©000255000 You are now Commander of "..player(id,"team").." team!@C")
end
end -- <<<<< error , if you want to use else if remove this..
elseif player(id,"team") == 2 and player(id,level[id]) == math.max(level[id]) then
if (player(id,"exists")) then
msg("©255075000"..player(id,"name").." has became Commander in "..player(id,"team").." team!")
msg2(id,"©000255000 You are now Commander of "..player(id,"team").." team!@C")
end
end
end


It gives eof error after it, I didn't even make it to be functional, I mean:
player(id,"team") == 1 and player(id,level[id]) == math.max(level[id])

That should be If player is team 1 and his level is bigger then others in the same team, he should get to be commander.

that elseif is connected to "for id = 1,32 do" so it gets error eof if I remove it or wouldn't do what its supposed.

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
@TSShuft

You messed up the amount of ends you had, and the elseif connected to for which does not work.

btw you want this function on teamchange, imagine if you had server start and everyone chose a team o-o
the for variable would lag you much?

use this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook("team","team")
function team(id,team)
	for id = 1,32 do
		if player(id,"team") == 1 and player(id,level[id]) == math.max(level[id]) then
		if (player(id,"exists")) then
			msg("©255075000"..player(id,"name").." is now the Commander in "..player(id,"team").." team!")
			msg2(id,"©000255000 You are now Commander of "..player(id,"team").." team!@C") 
		end
		elseif player(id,"team") == 2 and player(id,level[id]) == math.max(level[id]) then
		if (player(id,"exists")) then
			msg("©255075000"..player(id,"name").." is now the Commander in "..player(id,"team").." team!")
			msg2(id,"©000255000 You are now Commander of "..player(id,"team").." team!@C") 
		end
		end
	end
end

old Re: Lua Scripts/Questions/Help

Blacko
User Off Offline

Quote
Hello !
> I need your help, i don't know if it's possible but I want a script who restart my server every 30min ... It's possible ??... I hope you answer me ! Thanks you !

old Re: Lua Scripts/Questions/Help

EngiN33R
Moderator Off Offline

Quote
@iDios
Try this:
1
2
3
4
5
6
7
addhook("minute","restart")
function restart()
	minutes=minutes+1
	if (minutes==30) then
	minutes=0
	parse("restart")
end

Now my question, how do I multiply damage dealt from a weapon for a separate player, e.g. player ID 1 deals 2x damage, but player ID 2 deals 4x damage?

@The Camo
I would do it like that, check if the script works...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook("team","team")
function team(id,team)
for players = 1,32 do
if player(id,"team") == 1 and player(id,level[id]) == math.max(level[player(0,"team1")[players]]) then
if (player(id,"exists")) then
msg("©255075000"..player(id,"name").." has became Commander in "..player(id,"team").." team!")
msg2(id,"©000255000 You are now Commander of "..player(id,"team").." team!@C") 
end
elseif player(id,"team") == 2 and player(id,level[id]) == math.max(level[player(0,"team2")[players]]) then
if (player(id,"exists")) then
msg("©255075000"..player(id,"name").." has became Commander in "..player(id,"team").." team!")
msg2(id,"©000255000 You are now Commander of "..player(id,"team").." team!@C") 
end
end
end
end

FYI, if you add a "team" hook, then it will show this message and do all the stuff only when the player changes his team.

old Re: Lua Scripts/Questions/Help

Jaso
BANNED Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
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")
          parse("sv_sound 'sfx/sound.wav'")
dynwall=1
end
end
end

This script doesnt work i tried it many times so dont tell me that it works.
Let me explain the situation i got a dynwall in my map and this script let me do if i say hello hi or Hi or Hia then it has to go away and dont come back when you try it again and it plays a sound so i named the dynwall in the room the same name as the name of the object so called dynwall then you the script does a trigger called dynwall but it doesnt work at all so some help would be nice!

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
jaso55 has written
1
2
3
4
5
6
7
8
9
10
11
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")
          parse("sv_sound 'sfx/sound.wav'")
dynwall=1
end
end
end

This script doesnt work i tried it many times so dont tell me that it works.
Let me explain the situation i got a dynwall in my map and this script let me do if i say hello hi or Hi or Hia then it has to go away and dont come back when you try it again and it plays a sound so i named the dynwall in the room the same name as the name of the object so called dynwall then you the script does a trigger called dynwall but it doesnt work at all so some help would be nice!


Maybe try setting the function's name different from the entity's name?
Somehow I feel like that could effect it for some weird reason.

old Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Quote
how do I make hudtxt follow the players? like AllyMod by mat5b, I already his code it's too ... you know, hard to understand

old Re: Lua Scripts/Questions/Help

EngiN33R
Moderator Off Offline

Quote
@iDios

1
2
3
4
5
6
7
8
9
minute=0
addhook("minute","restart")
function restart()
minute=minute+1
if (minute==30) then
	parse("restart")
	minute=0
end
end
NOW after a small fix it should work.

@Admir
You just have to calculate the position of a player on another player's HUD. It is possible using a formula which IS COPYRIGHTED BY mat5b as he said in the script, so just find your formula to calculate the position. Good luck.

old Re: Lua Scripts/Questions/Help

Jaso
BANNED Off Offline

Quote
@CmDark
Can you give me an example of how this code could be. Because i try to edit it but...
edited 1×, last 26.10.10 11:22:50 am
To the start Previous 1 2290 291 292338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview