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 2110 111 112338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

Deatherr
User Off Offline

Zitieren
Flacko hat geschrieben
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

alt Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

Zepolete
User Off Offline

Zitieren
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)

alt Re: Lua Scripts/Questions/Help

- Dark Void -
User Off Offline

Zitieren
Starkkz hat geschrieben
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 >

alt Re: Lua Scripts/Questions/Help

Fehu
User Off Offline

Zitieren
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...)

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

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

alt Re: Lua Scripts/Questions/Help

- Dark Void -
User Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

Starkkz
Moderator Off Offline

Zitieren
- Dark Void - hat geschrieben
Starkkz hat geschrieben
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

alt Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

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

alt Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Zitieren
CmDark hat geschrieben
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?

alt Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
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
1× editiert, zuletzt 07.12.09 13:37:56

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
leegao hat geschrieben
Zitat
[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

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
Fehuziom hat geschrieben
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" .
Zum Anfang Vorherige 1 2110 111 112338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht