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 2319 320 321338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Precel97
User Off Offline

Quote
Hi im newbie.
I copy script classes - in samples

But i want change him into naruto mod :

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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
--------------------------------------------------
-- Player Classes Script by Unreal Software     --
-- 28.02.2009 - www.UnrealSoftware.de           --
-- Adds Player Classes to your server           --
--------------------------------------------------

if sample==nil then sample={} end
sample.classes={}

-----------------------
-- INITIAL SETUP     --
-----------------------
function initArray(m)
	local array = {}
	for i = 1, m do
		array[i]=0
	end
	return array
end
sample.classes.class=initArray(32)
function sample.classes.classmenu(id)
	menu(id,"Select your Class,Naruto|Energy-Health,Sakura|Strenght,Sasuke|Arm-Defense,Kakashi|Flame Skills,Jiraya|Power,Shizune|Poi-Art Tech")	
end


-----------------------
-- TEAM -> CLASS     --
-----------------------
addhook("team","sample.classes.team")
function sample.classes.team(id,team)
	if (team>0) then
		sample.classes.classmenu(id)
	end
end


-----------------------
-- SERVERACTION      --
-----------------------
addhook("serveraction","sample.classes.serveraction")
function sample.classes.serveraction(id)
	sample.classes.classmenu(id)
end


-----------------------
-- CLASS SELECTION   --
-----------------------
addhook("menu","sample.classes.menu")
function sample.classes.menu(id,menu,sel)
	if (menu=="Select your Class") then
		if (sel>=0 and sel<=6) then
			sample.classes.class[id]=sel
			if (player(id,"health")>0) then
				parse("killplayer "..id)
			end
		end
	end
end


-----------------------
-- SPAWN             --
-----------------------
addhook("spawn","sample.classes.spawn")
function sample.classes.spawn(id)
	-- Naruto
	if (sample.classes.class[id]<=1) then
		parse ("setmaxhealth "..id.." 200")
		parse ("setarmor "..id.." 20")
		parse ("speedmod "..id.." 25")
		return "40,4,51";
	end
	-- Sakura
	if (sample.classes.class[id]==2) then
		parse ("setmaxhealth "..id.." 150")
		parse ("setarmor "..id.." 206")
		parse ("speedmod "..id.." 5")
		return "21,1";
	end
	-- Sasuke
	if (sample.classes.class[id]==3) then
		parse ("setmaxhealth "..id.." 150")
		parse ("setarmor "..id.." 300")
		return "10,2,74";
	end
	-- Kakashi
	if (sample.classes.class[id]==4) then
		parse ("setmaxhealth "..id.." 125")
		parse ("setarmor "..id.." 75")
		return "46,6,73";
	end
	-- Jiraya
	if (sample.classes.class[id]==5) then
		parse ("setmaxhealth "..id.." 75")
		parse ("setarmor "..id.." 0")
		parse ("speedmod "..id.." 15")
		return "5,69,54";
	end
	-- Shizune
	if (sample.classes.class[id]==6) then
		parse ("setmaxhealth "..id.." 75")
		parse ("setarmor "..id.." 25")
                parse ("equip "..id.." 72")
		return "35,3,53";
	end
end


-----------------------
-- NO BUYING         --
-----------------------
addhook("buy","sample.classes.buy")
function sample.classes.buy()
	return 1
end


-----------------------
-- NO COLLECTING     --
-----------------------
addhook("walkover","sample.classes.walkover")
function sample.classes.walkover(id,iid,type)
	if (type>=61 and type<=68) then
		return 0
	end
	return 1
end


-----------------------
-- NO DROPPING       --
-----------------------
addhook("drop","sample.classes.drop")
function sample.classes.drop()
	return 1
end


-----------------------
-- NO DEAD DROPPING  --
-----------------------
addhook("die","sample.classes.die")
function sample.classes.die()
	return 1
end


i want shizune class saying (ninja art poison fog)in msg box.
I only need this script
I do other things but i ask if i got problems plz help

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
Dark Byte has written
Is there a metatable field for assignment?


No, there is however a way to override the default global assignment behavior as

x = 3 is equivalent to _G.x = 3, hence:

1
setmetatable(_G, {__newindex=function(self,k,v) ... end})

There is also a way to override local assignment via a bytecode interpreter, this however requires overloading the function call behavior and is not recommended as the consequences may be unexpected if you do not implement the overload route correctly.

old Re: Lua Scripts/Questions/Help

Chex
User Off Offline

Quote
Again, is there a way to see which player is VIP in assassination game mode?

And... @precel

WHY THE @#!*% DOES JIRAIYA HAVE 75 HP?
He's supposed to be a strong, awesome dude.
Just kidding.

And what message box are you talking about? Do you want it to say that in your screen when you select her? When you hit someone? Explain.

If you meant on the menu, replace
1
2
3
function sample.classes.classmenu(id)
     menu(id,"Select your Class,Naruto|Energy-Health,Sakura|Strenght,Sasuke|Arm-Defense,Kakashi|Flame Skills,Jiraya|Power,Shizune|Poi-Art Tech")     
end
with
1
2
3
function sample.classes.classmenu(id)
     menu(id,"Select your Class,Naruto|Energy-Health,Sakura|Strenght,Sasuke|Arm-Defense,Kakashi|Flame Skills,Jiraya|Power,Shizune(Ninja Art Poison Fog)|Poi-Art Tech")     
end
edited 3×, last 29.11.10 02:01:45 am

old Re: Lua Scripts/Questions/Help

Precel97
User Off Offline

Quote
Thx And i Know That Jiraya Is Strong But Its Only Test Version i Do Other Things When i Will Know More About Scripting.

This First Option

But I Want : If Shizune Throw Granade She's saying ninja art ---- But if its impossible i can do this alone but i dont know how do a script - when hit she say this i know this thing but i dont know how do this In the script but if who get gas grenade - other class this class say this

I have once more problem i mean with menu like if u select shizune she was have own menu - when u click F3 There's Options for all characters

IMG:https://i56.tinypic.com/e9dzkk.jpg
This is menu its only sample

if u have naruto class and select (naruto power) - menu there are options - naruto power 1 , naruto power 2 its only sample names... and don't ask about what powers is have this options

If u select sakura and click on naruto powers option
There Are Say On Center of screen : You Can't Select this option.

But I Have with one thing - Chakra - Maximum chakra points is 100 when power is use chakra is down for example 10 but when kill chakra is recover by 10 points.

Maybe I Do theard about naruto but i got some ideas for powers like np rock lee - i add character later Open 5 gates and he's lost him 90 chakra and he fast and strong -
90 speed and kill all with knife - one hit

Sorry im poland and if i say some engilsh words incorrectly Im Sorry Thx If Who Help And Will take care of this
edited 1×, last 29.11.10 06:38:20 pm

old Re: Lua Scripts/Questions/Help

Infinite Rain
Reviewer Off Offline

Quote
Somebody can help me?
Dont has any errors but if afkprotection on he got demage always!
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
function array(m)
	local array = {}
	for i = 1, m do
		array[i] = 0
	end
return array
end

afkprotection=array(32)

for i = 1, 32 do
	afkprotection[i]=0
end

addhook("say","afk")
function afk(id,t)
	if t=="!afk" then
		if afkprotection[id]==0 then 
		parse("speedmod "..id.." -100")
		else
		afkprotection[id]=0
		parse("speedmod "..id.." 0")
		end
	end
end

addhook("hit","protecthit")
function protecthit(id,source)
	if afkprotection[id]==1 then
		msg2 (id,"That player has afk protection")
		return 1
	end
	if afkprotection[source]==1 then
		msg2 (id,"You are on afk protection! You cant attack another players!")
		return 1
	end
end

old Re: Lua Scripts/Questions/Help

Fehu
User Off Offline

Quote
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
function array(m)
     local array = {}
     for i = 1, m do
          array[i] = 0
     end
return array
end

afkprotection=array(32)

for i = 1, 32 do
     afkprotection[i]=0
end

addhook("say","afk")
function afk(id,t)
     if t=="!afk" then
          if afkprotection[id]==0 then
          	parse("speedmod "..id.." -100")
		afkprotection[id]=1
	elseif afkprotection[id]==1 then
		afkprotection[id]=0
          	parse("speedmod "..id.." 0")
          end
     end
end

addhook("hit","protecthit")
function protecthit(id,source)
     if afkprotection[id]==1 then
          msg2 (id,"That player has afk protection")
          return 1
     end
     if afkprotection[source]==1 then
          msg2 (id,"You are on afk protection! You cant attack another players!")
          return 1
     end

Fixed...
end

old Re: Lua Scripts/Questions/Help

wjcf1290
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
addhook("hit","protecthit")
function protecthit(id,source)
	if afkprotection[id]==1 then
		msg2 (id,"That player has afk protection")
		return 1
	end
	if afkprotection[source]==1 then
		msg2 (source,"You are on afk protection! You cant attack another players!")
		return 1
	end
end

old Re: Lua Scripts/Questions/Help

EngiN33R
Moderator Off Offline

Quote
Hello, I'm working on my Stargate mod, and I have some problems with say hook. Everything works perfectly, except console gives 6 (SIX FOR GOD'S SAKE) "LUA: attempt to call a nil value" every time someone says something. Wat's de matter? I checked everything, there aren't any possible nil values, I double-checked everything, still doesn't work.

Oh, by the way, in the start it was giving only 1 error, but later, when I was changing the function's name, it was giving +1 error every change.

@arcas
VIP's team will be 3.

old Re: Lua Scripts/Questions/Help

Infinite Rain
Reviewer Off Offline

Quote
Help pleeeaaassseee!
LUA ERROR at line 13 attempt to call global 'array' (a nil value)

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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
function array(m)
local array = {}
for i = 1, m do
array[i] = 0
end
return array
end

healer=array(32)
warrior=array(32)
builder=array(32)
scout=array(32)
defender=array(32)


for i = 1, 32 do
healer[i]=0
warrior[i]=0
builder[i]=0
scout[i]=0
defender[i]=0
end

--Class select

addhook("say","slctclass")
function slctclass(id,t)
	if t=="!healer" then
		healer[id]=2
		warrior[id]=0
		builder[id]=0
		scout[id]=0
		defender[id]=0
	end
	if t=="!warrior" then
		warrior[id]=2
		healer[id]=0
		builder[id]=0
		scout[id]=0
		defender[id]=0
	end
	if t=="!builder" then
		healer[id]=0
		warrior[id]=0
		scout[id]=0
		defender[id]=2
		builder[id]=0
	end
	if t=="!scout" then
		healer[id]=0
		warrior[id]=0
		builder[id]=0
		defender[id]=0
		scout[id]=2
	end
	if t=="!defender" then
		healer[id]=0
		warrior[id]=0
		builder[id]=0
		scout[id]=0
		defender[id]=2
	end
end

--Spawn variables check

addhook("spawn","spawnchk")
function spawnchk(id)
	if healer[id]==2 then
		healer[id]=1
	end
	if warrior[id]==2 then
		warrior[id]=1
	end
	if builder[id]==2 then
		builder[id]=1
	end
	if scout[id]==2 then
		scout[id]=1
	end
	if defender[id]==2 then
	defender[id]=1
	end
end

--Give weapons when spawn

addhook("spawn","spawngive")
function spawngive(id)
	if healer[id]==1 then
		parse("strip "..id.." 45")
		parse("strip "..id.." 82")
		parse("strip "..id.." 81")
		parse("strip "..id.." 3")
		parse("strip "..id.." 32")
		parse("strip "..id.." 51")
		parse("strip "..id.." 74")
		parse("strip "..id.." 41")
		parse("strip "..id.." 30")
		--AAAAAAAAAAAAAAAAAAAA--   ^
		--Erase When change class  ^
		parse("equip "..id.." 45")
		parse("strip "..id.." 2")
		parse("strip "..id.." 1")
		parse("setmaxhealth "..id.." 200")
		parse("speedmod "..id.." 20")
		parse("equip "..id.." 82")
	end
	if warrior[id]==1 then
		parse("strip "..id.." 45")
		parse("strip "..id.." 82")
		parse("strip "..id.." 81")
		parse("strip "..id.." 3")
		parse("strip "..id.." 32")
		parse("strip "..id.." 51")
		parse("strip "..id.." 74")
		parse("strip "..id.." 41")
		parse("strip "..id.." 30")
		--AAAAAAAAAAAAAAAAAAAA--   ^
		--Erase When change class  ^
		parse("equip "..id.." 81")
		parse("strip "..id.." 2")
		parse("strip "..id.." 1")
		parse("equip "..id.." 3")
		parse("equip "..id.." 32")
		parse("equip "..id.." 51")
		parse("speedmod "..id.." 0")
		parse("setmaxhealth "..id.." 120")
	end
	if builder[id]==1 then
		parse("strip "..id.." 45")
		parse("strip "..id.." 82")
		parse("strip "..id.." 81")
		parse("strip "..id.." 3")
		parse("strip "..id.." 32")
		parse("strip "..id.." 51")
		parse("strip "..id.." 74")
		parse("strip "..id.." 41")
		parse("strip "..id.." 30")
		--AAAAAAAAAAAAAAAAAAAA--   ^
		--Erase When change class  ^
		parse("speedmod "..id.." 0")
		parse("strip "..id.." 1")
		parse("strip "..id.." 2")
		parse("equip "..id.." 3")
		parse("equip "..id.." 74")
		parse("setmaxhealth "..id.." 150")
	end
	if scout[id]==1 then
		parse("strip "..id.." 45")
		parse("strip "..id.." 82")
		parse("strip "..id.." 81")
		parse("strip "..id.." 3")
		parse("strip "..id.." 32")
		parse("strip "..id.." 51")
		parse("strip "..id.." 74")
		parse("strip "..id.." 41")
		parse("strip "..id.." 30")
		--AAAAAAAAAAAAAAAAAAAA--   ^
		--Erase When change class  ^
		parse("strip "..id.." 1")
		parse("strip "..id.." 2")
		parse("speedmod "..id.." 50")
		parse("setmaxhealth "..id.." 90")
	end
	if defender[id]==1 then
		parse("strip "..id.." 45")
		parse("strip "..id.." 82")
		parse("strip "..id.." 81")
		parse("strip "..id.." 3")
		parse("strip "..id.." 32")
		parse("strip "..id.." 51")
		parse("strip "..id.." 74")
		parse("strip "..id.." 41")
		parse("strip "..id.." 30")
		--AAAAAAAAAAAAAAAAAAAA--   ^
		--Erase When change class  ^
		parse("strip "..id.." 1")
		parse("strip "..id.." 2")
		parse("equip "..id.." 41")
		parse("equip "..id.." 30")
		parse("setmaxhealth "..id.." 100")
		parse("speedmod "..id.." 10")
	end
end

------Edit classes skills
----healer

--heal when hit
addhook("hit","heal")
function heal(id)
	if healer[source]==1 then
		parse("sethealth "..id.." 100")
		return 1
	end
end

----scout

--Cant take a flag
addhook("flagtake","notake")
function notake(id)
	if scout[id]==1 then
		return 1
	end
end

--cant dominate
addhook("dominate","nodominate")
function nodominate(id)
	if scout[id]==1 then
		return 1
	end
end

old Re: Lua Scripts/Questions/Help

EngiN33R
Moderator Off Offline

Quote
Try this

More >

old Re: Lua Scripts/Questions/Help

archmage
User Off Offline

Quote
Use this
1
2
3
4
5
6
7
8
addhook("serveraction","sva");

function sva(id,a)
	if ( a == 1 ) then
		local x,y = player(id, "tilex"),player(id,"tiley");
		parse("spawnitem 64 "..x.." "..y..");
	end
end

Also I wrote this (it is for scripters)
More >


It permits strings to be used like this
1
2
3
4
5
6
7
8
s = -s	-- Reverse string ("hey" -> "yeh")
s = s + "something" -- When used with a number it is the byte code of it a string is just appended
s = s.."something" -- same as above
s = s-1 -- removes characters from the back of a string
s = s^"string" -- concatenates string, but it is upper case
s = s(2,5)	-- generate substring (0 is the beginning not 1)
s = s2*n -- appends s2 to s n times
s = s%n -- if n is 0 then the string is converted to lower case otherwise it is converted to upper case

Example
1
2
3
4
5
6
7
8
9
str = String.new("hello, world");
str = str%1; -- HELLO, WORLD
str = str-5; -- "HELLO, "
str = str ^ "lua user" -- HELLO, LUA USER
str = str%0 -- hello, lua user
str = str+32 -- append a whitespace
str = str*math.random(10,100) -- repeat str 10-100 times

print(str) -- prints str

old Re: Lua Scripts/Questions/Help

Kurumi
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
----------------------
-- COD HP SYSTEM SOUND --
----------------------------
addhook("hit","cod4.breathing")
  function cod4.hit(id,src,wpn,hpdmg)
     if player(id,"health")-hpdmg < 25 then
          msg2(id,"SOMETHING HERE")
     end
end

how to make play sound until it reaches more then 25hp (recover system)
edited 2×, last 02.12.10 02:06:27 pm

old Re: Lua Scripts/Questions/Help

RAVENOUS
BANNED Off Offline

Quote
GeNeSiS_MaSoN has written
1
2
3
4
5
6
7
8
9
----------------------
-- COD HP SYSTEM SOUND --
----------------------------
addhook("hit","cod4.breathing")
  function cod4.hit(id,src,wpn,hpdmg)
     if player(id,"health")-hpdmg < 25 then
          msg2(id,"SOMETHING HERE")
     end
end

how to make play sound until it reaches more then 25hp (recover system)


1
parse("sv_sound2 "..id.." [SOUNDFILENAME])

old Re: Lua Scripts/Questions/Help

Kurumi
User Off Offline

Quote
Tobey has written
GeNeSiS_MaSoN has written
1
2
3
4
5
6
7
8
9
----------------------
-- COD HP SYSTEM SOUND --
----------------------------
addhook("hit","cod4.breathing")
  function cod4.hit(id,src,wpn,hpdmg)
     if player(id,"health")-hpdmg < 25 then
          msg2(id,"SOMETHING HERE")
     end
end

how to make play sound until it reaches more then 25hp (recover system)


1
parse("sv_sound2 "..id.." [SOUNDFILENAME])


Thanks tobey but if this file is in the folder what i should do?

old Re: Lua Scripts/Questions/Help

RAVENOUS
BANNED Off Offline

Quote
GeNeSiS_MaSoN has written
Thanks tobey but if this file is in the folder what i should do?


you already have to go out from the folder where your CS2D.exe starts.

so if it's in sfx you need to do:
1
sfx/name.wav
No matter where it is.

old Re: Lua Scripts/Questions/Help

Kurumi
User Off Offline

Quote
Tobey has written
GeNeSiS_MaSoN has written
Thanks tobey but if this file is in the folder what i should do?


you already have to go out from the folder where your CS2D.exe starts.

so if it's in sfx you need to do:
1
sfx/name.wav
No matter where it is.


1.Only wave format is needed?
2. need Those "[]" symbols in sound name?
sorry bed english

old Re: Lua Scripts/Questions/Help

RAVENOUS
BANNED Off Offline

Quote
GeNeSiS_MaSoN has written
1.Only wave format is needed?
2. need Those "[]" symbols in sound name?
sorry bed english


1. No
2. No
To the start Previous 1 2319 320 321338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview