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 2112 113 114338 339 Next To the start

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function hook_second_godmod()
	local secondi = 0
	local minutei = 0
	local houri = 0
	local secondi = secondi + 1
	if secondi == 60 then
	local minutei = minutei + 1
	secondi = secondi - 60
	end
	if minutei == 60 then
	local houri = houri + 1
	minutei = minutei - 60
	end
	parse('hudtxt 6 "©025255025Time:'..houri..':'..minutei..':'..secondi..'" 200 150 1')
	parse('hudtxt 7 "Lua Time:'..os.clock()..'" 200 175 1')
end
addhook("second","hook_second_godmod")

Won't Update itself help please ~~
by itself i mean the hour minute second on hudtxt

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
When using hudtxt do it this way:
1
2
3
4
function hudtxt(tid,text,x,y,align)
	if not align then align = 1 end
	parse([[hudtxt ]]..tid..[[ "]]..text..[[" ]]..x..[[ ]]..y..[[ ]]..align)
end

It's irritating when you have to decode 8 quotes in the same line while you have to distinguish them between single or double quotes...
edited 1×, last 09.12.09 11:08:34 am

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
CmDark,
It wont update because those values are Locals
Also for time you could use os.time() function for current time.
By the way it's better when you use "x > 59 then", not "x = 60 then"

I haven't tested, but you should get what I mean.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
addhook("second","hook_second_godmod") 
[b]
secondi = 0
minutei = 0
houri = 0[/b]

function hook_second_godmod()
	secondi = secondi + 1
	if secondi [b]> 59[/b] then
		minutei = minutei + 1
		secondi [b]= 0[/b]
	end
	if minutei [b]> 59[/b] then
		houri = houri + 1
		minutei [b]= 0[/b]
	end
	parse('hudtxt 6 "©025255025Time:'..houri..':'..minutei..':'..secondi..'" 200 150 1')
	parse('hudtxt 7 "Lua Time:'..os.clock()..'" 200 175 1')
end

And yea, you also using hudtexts wrong way.

old Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Quote
Is there any to stop sound? if me press Stop button on
serveraction menu, then the song will stop, is that possible?

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
@Admirdee,
Only on Carnage Contest, in CS2D that's not possible.
There is no sound pan(),volume(),stopchanel() functions.

old Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Quote
Blazzingxx has written
@Admirdee,
Only on Carnage Contest, in CS2D that's not possible.
There is no sound pan(),volume(),stopchanel() functions.


owh, DC should add to CS2D also, not CC's only

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
@Admirde,
It's not so easy, because all CS2D sound system is much different from CC.
Probably he wont add these functions.

old Re: Lua Scripts/Questions/Help

Fehu
User Off Offline

Quote
I need help for my Diablo Script or Mod idk ...
In this script , is class necromante , and this class can revive teams with -25 hp , is possible make revive script ?

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Fehuziom has written
I need help for my Diablo Script or Mod idk ...
In this script , is class necromante , and this class can revive teams with -25 hp , is possible make revive script ?


It's possible to respawn players, but it would be useless in some game modes like team deathmatch

old Parse hook

NozliW
User Off Offline

Quote
parse hook is to create console commands, right ?
can anyone explain it a bit to me ? i don't understand it so much, also i've seen things like string.sub,tonumber,tostring string.split (which is a funtion) and other things, can someone explain me that too ? thanks , it'll be a lot of help

old Re: Lua Scripts/Questions/Help

- Dark Void -
User Off Offline

Quote
Well, let us say you want to create a command to set the money of a person using there id
1
2
3
4
5
6
7
8
9
10
11
12
13
[b]-- First create toTable,string.split ect. (we are using toTable)[/b]
function toTable(t,match)
     local cmd = {}
     if not match then
          match = "[^%s]+"
     else
          match = "[^"..match.."]+"
     end
     for word in string.gmatch(t, match) do
          table.insert(cmd, word)
     end
     return cmd
end

1
2
[b]-- create the hook[/b]
addhook("parse","my_first_cmd")

1
2
3
4
5
6
7
8
9
[b]-- create the function[/b]
function my_first_cmd(c)
      [b]I use [i]local[/i] because we can re-use the local[/b]
       local cmd = toTable(c) [b]Create a table for [i]c[/i][/b]
       if cmd[1] == "give" then [b]1 is the first non-spaced word[/b]
                parse("setmoney "..cmd[2].." "..cmd[3])
return 2 [b]return [i]2[/i] so we do not get error message[/b]
end
end

it is the same as the say command except different hook

sorry it is not tabbed


-WiLSoN- has written
which is a funtion?


I am not good at explaining so please bear with me

there all functions but string.split & toTable are a few of the ones that you have to make yourself(i.e. you create a function named <string.split,toTable, ect.>.)
string.sub(t,a,b)
it returns the length and characters in t from the range from a to b

tonumber(v)
returns true if v is a number and (I think) converts it to a number if it can

tostring(v)
same as tonumber except it may contain various types of characters
edited 1×, last 10.12.09 04:48:16 am

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
uhm thanks but could you explain that toTable function ?
also is it toTable the same as string.split ?
also can you explain me the other things i said ?
thanks, and np if you can't

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
-WiLSoN- has written
uhm thanks but could you explain that toTable function ?
also is it toTable the same as string.split ?
also can you explain me the other things i said ?
thanks, and np if you can't


toTable is the exact same function as string:split, the latter however reserves various OO characteristics. The simple usage of it is as follows

str = "!command arguments"
str = str:split()
cmd = str[1] -- cmd = "!command"
args = str[2] -- args = "arguments"

when I wrote the function, that was its primary duty, in order to replace string.sub which was highly inefficient as a parser.

Inside the function, split creates a regex match for words from the match parameter, and then uses string.gmatch to iterate over each, inserting the element into a cmd table, and then returning the whole table back to the caller.

old help

Prest1Ge
User Off Offline

Quote
Please say Where tutorial how to make LUA scripts ??

old Re: Lua Scripts/Questions/Help

Redefinder
User Off Offline

Quote
Admiree has written
username1212709 has written
Please say Where tutorial how to make LUA scripts ??



here by TKD click me! click ME!

good tutorial ,but why isn`t it finished?When I try to go to Making a little menu link it doesn`t open it
To the start Previous 1 2112 113 114338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview