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

L3g3Nd
COMMUNITY BANNED Off Offline

Quote
Otservers have this lua configuration... its very cool
Cab be triggered by a simple text

old Re: Lua Scripts for CS2D

-Skull_
User Off Offline

Quote
DC, i can't wait for the next release can you tell what is the date about the release will be available

old Re: Lua Scripts for CS2D

ohaz
User Off Offline

Quote
chuico123 has written
-Skull_ has written
how can i edit those script?


wait until it releases it! probably there will be a "readme" file for further explanation about the scripting and also for help

EDIT: if it is possbile please make it! im sure it will be a great success! single-player mode is very expected, then is just up to us to make the maps and the scripting

ok now im going to prepare myself and im going to learn some Lua scripting

you just need to open the script.lua with your editor (like the windows one) and edit it. Just works, if you reallly HAVE the script, as client you won't get it, but i hope DC creates a LUA Scripts part for the upload section, so that you can share LUA scripts (and i'm already planning to do some!)

old Re: Lua Scripts for CS2D

-Skull_
User Off Offline

Quote
TheKilledDeath has written
chuico123 has written
-Skull_ has written
how can i edit those script?


wait until it releases it! probably there will be a "readme" file for further explanation about the scripting and also for help

EDIT: if it is possbile please make it! im sure it will be a great success! single-player mode is very expected, then is just up to us to make the maps and the scripting

ok now im going to prepare myself and im going to learn some Lua scripting

you just need to open the script.lua with your editor (like the windows one) and edit it. Just works, if you reallly HAVE the script, as client you won't get it, but i hope DC creates a LUA Scripts part for the upload section, so that you can share LUA scripts (and i'm already planning to do some!)


No Dude i mean how can i edit the Cs2D's Sys Folder..all the file inside

old Re: Lua Scripts for CS2D

DC
Admin Off Offline

Quote
lusi: No comment...

just added sv_sound scriptcommand (plays a soundfile) and a wrote a little Lua script for these stupid and annoying UT sounds (just as an example).
I also added the msg("YOURMESSAGE") Lua command which does the same as parse("sv_msg YOURMESSAGE")

the initial setup part is probably pretty stupid and can be realized much better (it creates tables with 32 entries - one for each player) but I was too lazy to find a better solution

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
--------------------------------------------------
-- UT+Quake Sounds Script by Unreal Software    --
-- 22.02.2009 - www.UnrealSoftware.de           --
-- Adds UT and Quake Sounds to your Server      --
--------------------------------------------------


-----------------------
-- INITIAL SETUP     --
-----------------------
uttimer = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
utlevel = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};


-----------------------
-- PREPARE TO FIGHT! --
-----------------------
function hook_startround()
	parse("sv_sound \"fun/prepare.wav\"");
end


-----------------------
-- KILL SOUNDS+MSGS  --
-----------------------
function hook_kill(killer,victim,weapon)
	if (os.clock()-uttimer[killer])>3 then
		utlevel[killer]=0;
	end
	level=utlevel[killer];
	level=level+1;
	utlevel[killer]=level;
	uttimer[killer]=os.clock();
	-- HUMILIATION? (KNIFEKILL)
	if (weapon==50) then
		-- HUMILIATION!
		parse("sv_sound \"fun/humiliation.wav\""); 
		msg (player(killer,"name").." humiliated "..player(victim,"name").."!");
	else
		-- REGULAR KILL
		if (level==1) then
			-- Single Kill! Nothing Special!
		elseif (level==2) then
			parse("sv_sound \"fun/doublekill.wav\""); 
			msg (player(killer,"name").." made a Doublekill!");
		elseif (level==3) then
			parse("sv_sound \"fun/multikill.wav\"");
			msg (player(killer,"name").." made a Multikill!");
		elseif (level==4) then
			parse("sv_sound \"fun/ultrakill.wav\"");
			msg (player(killer,"name").." made an ULTRAKILL!");
		elseif (level==5) then
			parse("sv_sound \"fun/monsterkill.wav\"");
			msg (player(killer,"name").." made a MO-O-O-O-ONSTERKILL-ILL-ILL!");
		else
			parse("sv_sound \"fun/unstoppable.wav\"");
			msg (player(killer,"name").." is UNSTOPPABLE! "..level.." KILLS!");
		end
	end
end

I also wrote some other little examples like an advertising scripts (sending a message each minute) or a script which gives you the time and date when saying "time" or "date". Or a list of idle players when you say "idlers".

All my scripts will be available as samples with the next release.

old Re: Lua Scripts for CS2D

Lee
Moderator Off Offline

Quote
on the setup, an alternative setup can look something like this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function initArray(m)
	local array = {}
	for i = 0, m do
		array[i] = 0
	end
	return array
end

function newIndice(array, m)
	
	if (table.getn(array) <= m+1) then
		for i = table.getn(array) -1, m do
			array[i] = 0
		end
	end
	return array
end

uttimer = initArray(maxplayers)
utlevel = initArray(maxplayers)

the problem with this in conventional languages is that if you change the maxplayers, the array would not scale, here, if you have a maxplayer changed, you can always rescale it (I presume in the rcon hook) with uttimer = rescale(uttimer, maxplayers)

also, we start the array off with the index of 0 to make sure that this will work with both types of servers (Dedis starts at 1, the in game server starts at 0 if I remember correctly)
edited 1×, last 22.02.09 05:34:57 pm

old Re: Lua Scripts for CS2D

DC
Admin Off Offline

Quote
thanks. I'll just inititale it with a loop because it looks better
rescaling is not necessary imho since there is the pretty low maximum of 32 players

the player ids start always at 1. 0 is not a valid player id.

old Re: Lua Scripts for CS2D

Lee
Moderator Off Offline

Quote
DC has written
thanks. I'll just inititale it with a loop because it looks better
rescaling is not necessary imho since there is the pretty low maximum of 32 players

the player ids start always at 1. 0 is not a valid player id.


that made things a lot easier, lua starts off the array with index 1 by default if you just use the array methods, in this case it would've made the rescale method (which I guess is not needed in most cases) a lot easier.

the newer version would just be

1
2
3
4
5
6
7
8
9
10
11
12
13
function initArray(i, m, array)
	if (array == nil) then array = {} end
	if (m == nil) then m = i; i = 1 end
	for i = i , m do
		if (array[i] == nil) then
			array[i] = 0
		end
	end
	return array
end

uttimer = initArray(1, 32,  {123, 34, 35, 45})
utlevel = initArray(32)

output - uttimer
1
123 34 35 45 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0


output - utlevel
1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

and the initArray fn would be re-usable.
edited 4×, last 22.02.09 06:21:55 pm

old Re: Lua Scripts for CS2D

Lee
Moderator Off Offline

Quote
btw, for the music files, do we need to "pre-cache" them onto the map or will they automatically be streamed to the client if he/she doesn't have it already

old Re: Lua Scripts for CS2D

DC
Admin Off Offline

Quote
there is no transfer planned for these files at the moment because in fact it is a pretty annoying and stupid thing...

so you either use existing sounds or you host maps which contain these sounds.

not sure if I'm going to add such a feature later or not.

old Re: Lua Scripts for CS2D

Tehmasta
User Off Offline

Quote
I'm looking foward for the new update but, I have a couple of questions for the scripting

Would you be able to display a message on one person's screen instead of everyone's? Such as, when someone enters a server it says welcome to that one person who enters instead of rewelcoming everyone and when you die it would say "You have been owned by playername" to the person who dies.

Would you be able to create a hook for console commands such as function hook_echo that checks for when someone says something like rcon teleport(player,x,y)

Will it be able to edit/create files of their own to store data, like a text file that stores every player's player id and number of kills and other stuff, so you don't lose it when they leave and reconnect.

Would you be able to create onscreen menus for players like the original cs deathmatch menu where you pick you guns.

old Re: Lua Scripts for CS2D

DC
Admin Off Offline

Quote
msg to special players only: yes √

hook for stuff sent with rcon: would be possible. probably yes √

Lua comes along with io functions for reading and writing data so it would be possible to save and load stuff I think. √

menus: uncertain. I can't confirm that but I'll probably try to implement something like that.

old Re: Lua Scripts for CS2D

Tehmasta
User Off Offline

Quote
Thanks for the quick reply
i have another quick question:
would it be possible to change to stats of a specific weapon or person when something is achieved. Like, when you reach 100 kills (recording with the text file mentioned above) your m4 shoots faster, is more accurate, does more damage, has more bullets in a clip, or you run faster or start with more hp.

old Re: Lua Scripts for CS2D

Lee
Moderator Off Offline

Quote
Tehmasta has written
Thanks for the quick reply
i have another quick question:
would it be possible to change to stats of a specific weapon or person when something is achieved. Like, when you reach 100 kills (recording with the text file mentioned above) your m4 shoots faster, is more accurate, does more damage, has more bullets in a clip, or you run faster or start with more hp.


should work, you can add a special cron function (through recursion) that checks special variables at specified intervals and if they meet a certain condition, calls the function that your looking for.
To the start Previous 1 2 3 4 5 6 7 Next To the start
Log in to replyGeneral overviewCS2D overviewForums overview