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 2110 111 112338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Deatherr
User Off Offline

Quote
Flacko has written
Try this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
addhook("say","sayz")
Wow i don't get it ... do i have to Edit it?

function sayz(id, text)
	local ptxt = toTable(text)
	if ptxt[1] == "$" and #ptxt == 3 then --Ok the format would be "$ PLAYER MONEY"
		local rcvp = tonumber(ptxt[2]) --Recieving player
		local rcvm = tonumber(ptxt[3]) --Money
		if player(rcvp,"exists") then --If the player exists
			if player(id,"money") >= rcvm then --and this dude has enough money
				if player(rcvp,"money") + rcvm <= 16000 then --check if we won't give him too much money (so we don't waste cash)
					parse("setmoney "..id.." "..player(id,"money")-rcvm)
					parse("setmoney "..rcvp.." "..player(rcvp,"money")+rcvm)
				elseif player(rcvp,"money") < 16000 then --Ok this guy would overpass $16000 with our donation so we deduct this
					rcvm = 16000 - player(rcvp,"money") --Here
					parse("setmoney "..id.." "..player(id,"money")-rcvm)
					parse("setmoney "..rcvp.." "..player(rcvp,"money")+rcvm)
				end
			end
		end
	end
end

Edit: Page 111 is mine too

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
I just made a easy Random Number Generator

1
2
3
4
5
6
function hook_second_test()
        limit = 1
        local rnum = math.random(limit + 999) - 1
	parse('hudtxt 0 "©000255000Random Number Generator:'..rnum..'" 125 100 1')
	end
addhook("second","hook_second_test")

using ms100 hook would be faster and more efficient though

old Re: Lua Scripts/Questions/Help

Zepolete
User Off Offline

Quote
when I was adding my script to server.lua and when I tryed to save it, it said please check whether if this file is opened in another program. cs2d was closed and I had no other programs running, (at least i think)

old Re: Lua Scripts/Questions/Help

- Dark Void -
User Off Offline

Quote
Starkkz has written
hmm ... And to create commands is similar?.
for example:

1
msg2 <color> <id> <txt> .

I need to understand that.


Try this it is not the best but...

Spoiler >

old Re: Lua Scripts/Questions/Help

Fehu
User Off Offline

Quote
Hi i need lua mod to HnS from cs 1.6... (I could to it myself , but im from poland )
CT:
> Freeze 10 sec

TT:
> HE Damage = Freeze (And CT must say !unfreeze or automatic unfreeze (5 sec))

Round:
> if CT win , changed team
> if TT win , no change team

(Round - Dont must if you hard...)

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
@Vibhor

I'm giving you basic idea, its not Lua script. (Will equip if you have less then 2 primary weapons) :
1
2
3
4
5
6
7
8
9
10
11
function hook = Walkover
	local p_weapons = playerweapons(id)
	local p_prim_weapons = 0
	For i = 1,#playerweapons(id) do
		<check if weapon id is primary> (primary IDs : 10 - 50)
		p_prim_weapons = p_prim_weapons + 1
	end
	if (p_prim_weapons < 2)
		equip with walkover weapon parameter
	end
end

old Re: Lua Scripts/Questions/Help

- Dark Void -
User Off Offline

Quote
why will this not work it works except it shows the text

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook("say","fs_say")
function fs_say(id,txt)
	local text = toTable(txt)
	if string.sub(txt,1,9) == "!register" then
		if text[2] ~= nil then
			if text[3] ~= nil then
				new_user(text[2],text[3],"User")
				local u = tostring(text[2])
				local pw = tostring(text[3])
				fs_msg2(id,color,"Log in as  User: '"..u.."' PW: '"..pw.."'")
				fs_msg2(id,color,"You are now a 'User' you can now use commands with #")
				return 1
			end
		end
	end
end

old Re: Lua Scripts/Questions/Help

Starkkz
Moderator Off Offline

Quote
- Dark Void - has written
Starkkz has written
hmm ... And to create commands is similar?.
for example:

1
msg2 <color> <id> <txt> .

I need to understand that.


Try this it is not the best but...

Spoiler >


emm.. i know this but.
I need the hook is "parse" to work on the console

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
I just upped meh Random Number Generator

I made it so that i could do a
Man Vs. Map script

where

spawns random items in map

and spawn random objects in map

every second or so

xdd

can someone explain how to check if there is a wall already in the tile so that it can skip that tile for items

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
Quote
[TILE]
- tile(x,y,"value")          Return a value of a tile:
                    frame, property, walkable, deadly,
                    wall, obstacle, entity

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
k thanks lee

lol

i just uploaded the video of my

Some shiet

but its like hella tiny cause i used fraps(30 seconds)

http://www.youtube.com/watch?v=zWAKDf33CX4

old Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Quote
CmDark has written
k thanks lee

lol

i just uploaded the video of my

Some shiet

but its like hella tiny cause i used fraps(30 seconds)

http://www.youtube.com/watch?v=zWAKDf33CX4


random number generator for?

old Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Quote
help

1
2
3
4
5
6
7
8
9
addhook("move","test_move")
function test_move(id,walk)
	if (walk == 0) then
		stamina[id]=stamina[id]+1
	elseif (walk == 1) then
		stamina[id]=stamina[id]-1
	end
test_updatehud(id)
end

I've try the code, but it doesn't work for me,
and yes, I got a table for stamina

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Hm.
Why doesn't it work? You don't get any error message or nothing happens?
How did you create that table?
Did you try printing the value?
1
2
3
4
5
6
7
8
9
10
addhook("move","test_move")
function test_move(id,walk)
     if (walk == 0) then
          stamina[id]=stamina[id]+1
     elseif (walk == 1) then
          stamina[id]=stamina[id]-1
     end
test_updatehud(id)
print(stamina[id]) --Check in console
end
edited 1×, last 07.12.09 01:37:56 pm

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
leegao has written
Quote
[TILE]
- tile(x,y,"value")          Return a value of a tile:
                    frame, property, walkable, deadly,
                    wall, obstacle, entity

tile(x,y,"wall") not working as all values not working on this function.

DC said he will fix this mess

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Fehuziom has written
Hi i need lua mod to HnS from cs 1.6... (I could to it myself , but im from poland )

You said you can make it yourself, there is no problems if you are poland.

However, it have not enough features to me for starting this "mod" .
To the start Previous 1 2110 111 112338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview