Forum

> > CS2D > General > Lua Scripts for CS2D
Forums overviewCS2D overviewGeneral overviewLog in to reply

English Lua Scripts for CS2D

134 replies
Page
To the start Previous 1 2 3 4 5 6 7 Next To the start

Poll Poll

What do you think about Lua support in CS2D?

Only registered users are allowed to vote
Awesome!
85.88% (225)
Sounds good.
7.25% (19)
Bad idea. I hate Lua!
3.44% (9)
I have no idea.
3.44% (9)
262 votes cast

old Re: Lua Scripts for CS2D

DC
Admin On Online

Quote
you can refill the weapon but there is no way to set the actual amount of ammo.
you can remove and give weapons to the player whenever you want and you can set his health and armor whenever you want. its also possible to kill him, change the position, change the team etc.

you can override the standard functions only in some cases. for example team selection, buying or collecting stuff. this is done by returning the value 1 in the hooked Lua function. it then skips the standard cs2d function completely.
so you can make it impossible to switch the team or you can write a script which makes it impossible for a player to collect a certain item.


@chuico123:
• gun game
• classes were players have different weapons/armor on spawn
• a skill/level system
• a bet system
• custom voting system
• weapons for free system
• teleport stuff
• and much more.
edited 1×, last 01.03.09 09:05:09 pm

old Re: Lua Scripts for CS2D

Tehmasta
User Off Offline

Quote
TMK, did you test the bet system? According to DC's post in the german section which lists the commands, msgtoplayer is msg2; player_give_money isn't a command.
Btw, where did you get the values for the endround types?

old Re: Lua Scripts for CS2D

ohaz
User Off Offline

Quote
mrc has written
what is bet system?

should be, that you can bet which team wins if you are dead.
If you win, you get money back, if you lose, your money is gone!

old Re: Lua Scripts for CS2D

lusi
COMMUNITY BANNED Off Offline

Quote
in cs1.6 i see when i write thetime cs1.6 writting the time.this is good idea to have clock.

old Re: Lua Scripts for CS2D

Zune5
COMMUNITY BANNED Off Offline

Quote
lusi has written
I play on you sever's TMK.how you make this gun mode,rpg mode?


It's closed source
It's written in Python.
However, it will be possible wit Lua...hopefully.

@lusiagain: thetime is also in TMK's code. It's disabled though.

old Re: Lua Scripts for CS2D

mrc1
COMMUNITY BANNED Off Offline

Quote
TheKilledDeath has written
mrc has written
what is bet system?

should be, that you can bet which team wins if you are dead.
If you win, you get money back, if you lose, your money is gone!

oh ok, this exist in 1.6 too...
but it happens when remains 1on1...
then you decide who you want to bet...
then you can increase your bet, bet all cash you have,
or just not bet...

old Re: Lua Scripts for CS2D

Kiffer-Opa
User Off Offline

Quote
To stop rumors about TMK's bet system, I'll try to explain it in detail (I read the code):
• You can bet your money when you're dead on one of the teams (who wins?)
• however this only makes sense if the game is somewhat round-based
• If your bet is wrong, the wager is gone
• The cash you can win is calculated so (players count at the point where you bet):
1
wager*living Players of team your didn't bet for / living players of the team you'd bet for
plus, you get the wager back
So that means if the bet team has less players you can win much cash and if it has more players you can win less money.

Example: If CTs have 5 and Ts 2 players left and you bet $1000 for Ts, then you can win $1000*5/2 = $2500 plus you get your wager of $1000 back, when the Terroritsts win.

However I don't get it who really needs a bet system in CS2D. Why do you must combine gameplay-relevant money with totally non-gameplay-relevant bets.
"I have better guns than you because I just won a bet"; how embarrassing, most cash from a bet, not from kills
edited 1×, last 02.03.09 07:44:31 pm

old Re: Lua Scripts for CS2D

Zune5
COMMUNITY BANNED Off Offline

Quote
Kiffer, why do we need Construction in CS2D. Why?
Why did DC add this? ik, who knows?
We need it because it's fun. Plus, this isn't going to be added into Max, but through Lua scripting. So that question you asked was a bit pointless.

And I believe, the correct grammar for your code would be this

1
wager*A player has left the team you did bet for.

old Re: Lua Scripts for CS2D

Kiffer-Opa
User Off Offline

Quote
Zune5 has written
Kiffer, why do we need Construction in CS2D. Why?

Because it's fun.
But there is a difference between bets and Construction. Construction is a complete game. Bet system is just a script and not a complete game.

Money for winning bets troubles the balancing, especially for the Standard mode.

I think that money is for buying or building or something else in the game-world, you can win some by owning the enemy (destroy his buildings, rescure hostages, etc.) in the game-world.
So raising money for winning a bet does not only fit into gameplay, it is quite unfair to those who raise their money with their skills.

Yes, I said it, I think it is unfair because this thing actually does only make sense on round-based games like for CS-style maps like de_dust.
As said, it would be pretty dumb and unfair to be able to buy good weapons just because you won a bet, not because you are a good player.

The bet system itself is then okay when it doesn't annoy other players too much and when it doesn't affect gameplay of the round-based part of CS2D unless you want to make your own casino mod.

old Re: Lua Scripts for CS2D

Zune5
COMMUNITY BANNED Off Offline

Quote
And who said you had to implement it into Standard mode? Remember Lua is just a add-onto a game.

old Re: Lua Scripts for CS2D

Tehmasta
User Off Offline

Quote
he said you needed standard mode for the bet system, i read through the code and itll only give you money on round end, and you can only bet when dead. In construction, DM and team DM, there is no endround, and in zombies your never dead, so only standard would work correctly

edit: i was bored so i made an admin login system that restricts what commands they have access to:
http://www.mediafire.com/download.php?mtgzjayai2g

I'm assuming hook_parse is called when someone types something in the console and it takes the player and the text as parameters. Hey, DC could you test it to see if it works?
edited 2×, last 02.03.09 11:37:42 pm

old Re: Lua Scripts for CS2D

Zune5
COMMUNITY BANNED Off Offline

Quote
And so? Not everyone will be adding this because they have the same opinions as Kiffer. So, I don't think you have much to worry about anyways.

old Re: Lua Scripts for CS2D

Lee
Moderator Off Offline

Quote
I did a bit of a rewrite for your code so it'll be easier to add new commands, comments are in the code, I haven't tested it out yet so you may need a bit of adjustments before you can get it to work but it's a basic idea. Also, the parse hook is non-existent since the console parse is client side only.
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
function switch(t)
	t.case = function (self,x)
		local f=self[x] or self.default
		if f then
			if type(f)=="function" then
				f(self)
			else
				error("case "..tostring(x).." not a function")
			end
		end
	end
  	return t
end

function tableToString(t, n)
	local s = ""
	if (n == nil) then n = 1 end
	while (n <= #t) do
		s = s + t[n] + " "
	end
	return s
end

if (string.lower(string.sub(t, 1, 5)) == "admin") then
	-- Get the substring from position 11 to the end
	t = string.sub(t, 6)

	-- Dec and init of local variables
	local cmd = {}
	local users = {}

	--Iterates through t and adds each word into the table cmd
	for word in string.gmatch(t, "%a+") do
		table.insert(cmd, word)
	end

	--Command Type + pop top element
	local typ = string.lower(cmd[1])
	table.remove(cmd, 1)

	--This probably go in the init block instead of here.
	for line in io.lines("Admins.cfg") do
		local tempUser = {}
		for word in string.gmatch(line, "%a+") do
			table.insert(tempUser, word)
		end
		users[tempUser[1]] = {password=tempUser[2], priviledge = tempUser[3]}
	end
	
	if (typ == "login") then
		username = cmd[2]
		password = cmd[3]
		if (users[username]) then
			--Here, admin_check will return nil if user id is not in the list				if (users[username].password == password) then
				admin_check[p] = users[username].priviledge
			else
				msg2(p, "Wrong Password")
			end
		else
			msg2(p, "No User with that Username")
		end
	elseif (admin_check[p]) then
		local priviledge = admin_check[p]
		
		command = tableToString(cmd)
		
		--Do the rest of the stuff, you can dec a variable as a fn and store it.
		action = switch {
		["slap"] = function () msg2(p, "This is the slap command") end,
		default = function() msg2(p, "Command Does Not exist") end,
		}
		action:case(typ)

	else
		msg2(p, "No admin priviledges")
	end

end
To the start Previous 1 2 3 4 5 6 7 Next To the start
Log in to replyGeneral overviewCS2D overviewForums overview