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 2125 126 127338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Yes, but that would be gay because those guns won't work
A fix to the *possible* problem would be:
Since the hit hook gets called before the real hit occurs, we will have to do the math with lua
1
2
3
4
5
6
addhook("hit","cod4.hit")
function cod4.hit(id,src,wpn,hpdmg)
	if player(id,"health")-hpdmg < 50 then
		msg2(id, "You are hurt, Get Cover!")
	end
end

old Re: Lua Scripts/Questions/Help

memo
COMMUNITY BANNED Off Offline

Quote
thanks leegao sorry ididn't see your post and thanks flako andlinuxGuy and thanks all i'll try your all post ,and by the
way i am not making a test it for my mod CoD - MW2D !

[EDIT] ok the hurt msg works thanks !
on my new mod on classes when i press 0-cancel on the classes menu i die i try to find the hook with the kill if player chose 0-cancel but i canot find it i just want when i press 0-cancel i just cancel ! lol
edited 1×, last 29.12.09 07:25:56 am

old Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Quote
Flacko has written
Ah, no, my fail
I thought you meant return 1.

Imagine "return 1"
Then you won't be killed with Laser nor RPG nor 2x AWP. It would be fair game if you ask me

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
uhh may be something like:
1
2
3
4
5
6
7
8
9
10
11
12
function array(m)
	local array = {}
	for i = 1, m do
		array[i]=0
	end
	return array
end
class[id] = array(32)
if (player(id,"bot")) then
	local rnd = math.random(1,X) -- X = total classes
	class[id] = rnd
end
just thought it could be something like this,i'm not sure it'll work

old Re: Lua Scripts/Questions/Help

Noxic
User Off Offline

Quote
Why doesn't this work?

Spoiler >


I get no error in my console. It just... doesn't work.

old Re: Lua Scripts/Questions/Help

Balto
User Off Offline

Quote
Hi, im want to know how change the teams names. Im working in a mod and i want to change that names for names of other counter-terrorist and terrorist forces.
Thanks and sorry for my english, is that isn&#180;t my native language.

old Re: Lua Scripts/Questions/Help

Balto
User Off Offline

Quote
Thanks, but... im a fuckin n00b in this issue.
Im put it in the "server.lua", i copy and past to see if it worked, no work. Im doing some wrong?
This is how i got it:
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
-------------------------------------------------------------------
-- This file is where your Lua server scripts go!                --
--                                                               --
-- There are some sample scripts availabe! Just remove the       --
-- comments ("--") in front of the dofile-lines to activate them!--
-- All samples are stored in subtables of the Lua table "sample" --
-- Do not use the "sample" table when writing own scripts!       --
--                                                               --
-- Enjoy! :D                                                     --
-------------------------------------------------------------------

-------------------------------------------------------------------
-- Mod: sample.ads                                               --
-- Just a welcome message + Advertising every minute             --
-- hooks: join, minute                                           --
-------------------------------------------------------------------
-- dofile("sys/lua/samples/advertise.lua")


-------------------------------------------------------------------
-- Mod: sample.badwords                                          --
-- A very simple badwords filter. Kicks players who use bad words--
-- hooks: say                                                    --
-------------------------------------------------------------------
-- dofile("sys/lua/samples/badwords.lua")


-------------------------------------------------------------------
-- Mod: sample.sayfuncs                                          --
-- Some additional say functions like date, time, idlers etc.    --
-- hooks: say                                                    --
-------------------------------------------------------------------
-- dofile("sys/lua/samples/sayfunctions.lua")


-------------------------------------------------------------------
-- Mod: sample.ut                                                --
-- Adds UT Sounds like Humiliation, Doublekill, Multikill, etc.  --
-- hooks: startround, kill                                       --
-------------------------------------------------------------------
-- dofile("sys/lua/samples/utsfx.lua")


-------------------------------------------------------------------
-- Mod: sample.console                                           --
-- Adds console commands "myserverinfo" and "healthlist"         --
-- hooks: parser                                                 --
-------------------------------------------------------------------
-- dofile("sys/lua/samples/console.lua")


-------------------------------------------------------------------
-- Mod: sample.regonly                                           --
-- Only registered players are allowed to join a team            --
-- hooks: team                                                   --
-------------------------------------------------------------------
-- dofile("sys/lua/samples/regonly.lua")


-------------------------------------------------------------------
-- Mod: sample.classes                                           --
-- Different player classes with different weapons               --
-- hooks: team,menu,spawn,buy,walkover,drop,die,serveraction     --
-------------------------------------------------------------------
-- dofile("sys/lua/samples/classes.lua")


-------------------------------------------------------------------
-- Mod: sample.fast                                              --
-- Make all players faster                                       --
-- hooks: spawn                                                  --
-------------------------------------------------------------------
-- dofile("sys/lua/samples/fastplayers.lua")


-------------------------------------------------------------------
-- Mod: sample.gg                                                --
-- Simple Gun Game Mod                                           --
-- hooks: startround,join,spawn,kill,buy,walkover,drop,die       --
-------------------------------------------------------------------
-- dofile("sys/lua/samples/gungame.lua")

-------------------------------------------------------------------
-- Mod: sample.glowing                                           --
-- Make all players glow using the Lua image commands            --
-- hooks: startround                                             --
-------------------------------------------------------------------
-- dofile("sys/lua/samples/glowingplayers.lua")


-------------------------------------------------------------------
addhook("join","j") 
function j(p) 
     parse("setname "..p.." " Something") 
end

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
just delete everything that's on your server.lua file,then paste the script.
with that script, the first player will be named "Something" but the 2nd player will be named "Something 2"
the 3rd "Something 3" and so on.

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
Balto has written
Yes, but what i want is that the team names change (DEVGRU, GIGN, SAS, ARTIC AVENGERS, ETC...)


It's not possible to physically change the text on the join menu.

old Re: Lua Scripts/Questions/Help

ohaz
User Off Offline

Quote
Deatherr has written
How do you make a random lua thing because for bots to choose random classes.....

-WiLSoN- has written
uhh may be something like:
1
2
3
4
5
6
7
8
9
10
11
12
function array(m)
	local array = {}
	for i = 1, m do
		array[i]=0
	end
	return array
end
class[id] = array(32)
if (player(id,"bot")) then
	local rnd = math.random(1,X) -- X = total classes
	class[id] = rnd
end
just thought it could be something like this,i'm not sure it'll work

nearly perfect, you just forgot math.randomseed().
1
2
3
4
5
6
7
8
9
10
11
12
13
function array(m)
	local array = {}
	for i = 1, m do
		array[i]=0
	end
	return array
end
class[id] = array(32)
if (player(id,"bot")) then
	[b]math.randomseed(os.time)[/b]
	local rnd = math.random(1,X) -- X = total classes
	class[id] = rnd
end

old Re: Lua Scripts/Questions/Help

Noxic
User Off Offline

Quote
@My Issue with the "break" hook;
Thing is, even if it's the wrong item, it should show the message. It doesn't.

Also, the usebutton hook doesn't seem to run when a non-admin player uses a button.

EDIT: On non-dedicated servers, ofcourse.
edited 1×, last 30.12.09 08:38:11 am

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
-WiLSoN- has written
it seems the command isn't working (i tried it on my server and it didn't work,tried with different items)

old Re: Lua Scripts/Questions/Help

YellowBanana
BANNED Off Offline

Quote
-WiLSoN- has written
-WiLSoN- has written
it seems the command isn't working (i tried it on my server and it didn't work,tried with different items)


Yeah use it in the spawn hook
1
2
3
4
5
6
7
8
9
10
math.randomseed(os.time)
class[id] = array(32)

addhook("spawn","my_spawn")
function my_spawn(id)
	if (player(id,"bot")) then     		
     		local rnd = math.random(1,X) -- X = total classes
     		class[id] = rnd
	end
end

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
You could use object(0,"table"), then iterate through that table and remove the objects that aren't breakables.
Then, when a player shoots, you iterate through the breakables table and check if one of the objects doesn't exist.
I think this could work because the attack hook gets called after a player shoots, but it may not work with some weapons like HE, RPG, snowball, etc.
But I'm not sure that breakables are objects in CS2D

Edit: No, they aren't
To the start Previous 1 2125 126 127338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview