Forum

> > CS2D > Scripts > Error lua script
Forums overviewCS2D overview Scripts overviewLog in to reply

English Error lua script

9 replies
To the start Previous 1 Next To the start

moved Error lua script

GamerX 17323
User Off Offline

Quote
My problem is that this error persists as to remove it? Moon following code:

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
dofile("sys/lua/safezone/config.cfg")

function inSafezone(id)
	local tilex = player(id,"tilex");
	local tiley = player(id,"tiley");
	for _, i in pairs(safezones) do
		if (tilex >= i[1][1] and tilex <= i[2][1]) and (tiley >= i[1][2] and tiley <= i[2][2]) then
			return true;
		end
	end
	return false;
end

addhook("hit", "onHit")
function onHit(id,pl)
	if inSafezone(id) then
		return 1;
	elseif inSafezone(pl) then
		return 1;
	end
end

addhook("movetile", "onMovetile")
function onMovetile(id,x,y)
	if inSafezone(id) then
		parse('hudtxt2 '..id..' 11 "©150255000Zona Segura" 320 200 1');
	elseif not inSafezone(id) then
		parse('hudtxt2 '..id..' 11 ""');
	end
end

IMG:https://i.imgur.com/riqVMIz.png

old Re: Error lua script

DC
Admin Off Offline

Quote
• The spoiler tag makes no sense here. You are not spoiling anything. Replaced with code tag!

• The :7 in the log means that the error is in line 7! Luckily we're using the code tag which shows line numbers...

So this must be the bad line:
1
if (tilex >= i[1][1] and tilex <= i[2][1]) and (tiley >= i[1][2] and tiley <= i[2][2]) then

tilex and tiley could be the boolean value false in case you are calling cs2d lua cmd player with the ID of a player which does not exist. So make sure that the player actually exists first:
1
if player(id,"exists") then

Alternatively there might be booleans in your i-Array. I don't know how you set it so you have to check that yourself.

old Re: Error lua script

DC
Admin Off Offline

Quote
It's obvious that you need help because you posted here. That's why I just tried to help you! I told you exactly what to do! It's not possible to help you even more unless you show how the safezones variable/table/array is set.

old Re: Error lua script

Raaj Nadar
User Off Offline

Quote
Table means something like this...
lol = {You,Me,all}
friends = {"TOM","Game"}

like this and it is use like this if you want to use TOM some where you use like this friends[1].

Hope you understand.
Not a script dont use it.

old Re: Error lua script

Joni And Friends
User Off Offline

Quote
@user GamerX 17323: Im not found the problem when i combine the table and your script code like this
More >

Maybe you are wrong in placing the code, check that!

old Re: Error lua script

GamerX 17323
User Off Offline

Quote
Here is my complete script:

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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
safezones = {
     {{2,1},{6,5}};
     {{9,1},{22,9}};
     {{5,245},{17,254}};
     {{39,80},{65,88}};
}

function inSafezone(id)
     local tilex = player(id,"tilex");
     local tiley = player(id,"tiley");
     for _, i in pairs(safezones) do
          if (tilex >= i[1][1] and tilex <= i[2][1]) and (tiley >= i[1][2] and tiley <= i[2][2]) then
               return true;
          end
     end
     return false;
end

addhook("hit", "onHit")
function onHit(id,pl)
     if inSafezone(id) then
          return 1;
     elseif inSafezone(pl) then
          return 1;
     end
end

addhook("movetile", "onMovetile")
function onMovetile(id,x,y)
     if inSafezone(id) then
          parse('hudtxt2 '..id..' 11 "©150255000Zona Segura" 320 200 1');
     elseif not inSafezone(id) then
          parse('hudtxt2 '..id..' 11 ""');
     end
end

min = 35
sec = 0
posX = 5 -- change to wherever you want in screen
posY = 420 -- same thing for Y axis value

addhook("second","whatever")
function whatever()
     sec = sec - 1;

     if sec <= 0 then
          sec = 59
          if min > 0 then
               min = min - 1
          elseif min == 0 then
               parse("restart")
               min = 35
          end
     end
     
     local sectemp = tostring(sec); --add zero if len < 2
     if (string.len(sectemp) < 2) then sectemp = ("0"..sectemp); end

     local mintemp = tostring(min); --add zero if len < 2
     if (string.len(mintemp) < 2) then mintemp = ("0"..mintemp); end


     parse("hudtxt 0 \"\169255255255Próximo Restart Em: "..mintemp..":"..sectemp.."\""..posX.." "..posY.." 0")
end

addhook("startround","alsowhatever")
function alsowhatever()
     min = 35
     sec = 0
end

function totable(t,match)
local cmd = {}
if not match then match = "[^%s]+" end
for word in string.gmatch(t, match) do
table.insert(cmd, word)
end
return cmd
end

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","say")
function say(id,txt)
local p = totable(txt)
local cmd = tostring(p[1])
local pl = tonumber(p[2])
if cmd== "!track" then
  msg2(id,"©999999999[==*Dados do jogador ©000255255 "..player(pl,"name").."©999999999*==]")
  msg2(id,"©000255000USGN: "..player(pl,"usgn").." ")
  msg2(id,"©000255000Port: "..player(pl,"port").." ")
  msg2(id,"©000255000IP: "..player(pl,"ip").." ")
  msg2(id,"©000255000Seu ping atual: "..player(pl,"ping").." ")
  msg ("©999999999[==*O Player ©000255255"..player(id,'name').."©999999999 está analisando alguém (!track)*==]")
 return 1
elseif cmd=="!rs" then
  parse ("setscore "..id.." 0")
  parse ("setdeaths "..id.." 0")
  msg2(id,"©999999999[==*Score ©255000000Resetado ©999999999Com Sucesso*==]")
  msg ("©999999999[==*O Player ©000255255"..player(id,'name').."©999999999 resetou seu score*==]")
 return 1
elseif cmd=="!info" then
  if _G["mtime1"]==nil then
  local tleft = game("mp_timelimit")
  local nmap = game("nextmap")
   msg2(id,"©999999999[==*Informações Do Servidor*==]")
   msg2(id,"©000255000Server Name: "..game("sv_name"))
   msg2(id,"©000255000Max Players: "..game("sv_maxplayers"))
   msg2(id,"©000255000Server Password: "..game("sv_password"))
   msg2(id,"©000255000Tempo Por Mapa: "..tleft.." ")
   msg2(id,"©000255000Mapa Atual: "..game("sv_map"))
   msg2(id,"©000255000Próximo Mapa: "..nmap.." ")
   msg ("©999999999[==*O Player ©000255255"..player(id,'name').."©999999999 está vendo as informações do server (!info)*==]")
   return 1
  end
end 
end

addhook("second","horario")
function horario()
parse('hudtxt tm "©250250250Horario : '..os.date("%c")..'" 250 50')
end

addhook("join","joinola") 
function joinola(id,txt) 
msg ("©999999999[==*Acaba De Entrar: ©000255255"..player(id,'name').." ©000255000[USGN:"..player(id,'usgn').."]-[IP:"..player(id,'ip').."]©999999999*==]")
msg2 (id,"©999999999[==*Bem Vindo ©000255000"..player(id,"name").." ©999999999Leia As Regras E Boa Sorte !*==]")
msg2 (id,"©999999999[==*©000255000Vagas de moderadores tecle F1©999999999*==]")
end

addhook("minute","help")
function help()
        msg("©999999999Por Favor leia as regras pressionando F1")
        msg("©999999999Comandos úteis: !rs !info e !track")
        msg("©999999999Mapa oficial: Construa Sua Casa.")
        msg("©999999999Servidor oficial MilitarGames !")
        msg("©000255000Vagas de moderadores")
	msg("©000255000Mais informações tecle F1")
end

addhook("kill","knife_kill")
function knife_kill(killer,victim,weapon)
 if (weapon==50) then
  parse("sv_sound \"sfx/brasil.wav\""); 
  msg ("©000255000"..player(killer,"name").." Matou De Faquinha O NOB Do "..player(victim,"name").."!@C")
 elseif (weapon==35) then
  parse("sv_sound \"quake/headshot.wav\""); 
  msg ("©255255255"..player(killer,"name").." Matou de Head-Shot O "..player(victim,"name").."!@C")	
 elseif (weapon==51) then
  parse("sv_sound \"quake/boomheadshots.wav\""); 
  msg ("©255255255"..player(killer,"name").." Matou De Granada O "..player(victim,"name").."!@C")
 end
end

---------------------------------
--Fast build script by LinuxGuy--
---------------------------------

--**Credits**:
--wups - for finding out money bug (you didn't loose money)
--The Killed Death - for explaining arrays
--DC - For this incredible game xD



addhook("build","no_site")
function no_site(id,type)
	if (type == 21) then
		return 0
	else
		return 1
	end
end

buildingmoney = {500,500,500,500,500,500,500,500}

addhook("build","no_sitenow")
function no_sitenow(id,type,x,y)
	if (type == 21) then
		return 0
	else
		parse("spawnobject "..type.." "..x.." "..y.." 90 1 "..player(id,"team").." "..id)
	end
end

addhook("build","money_loose")
function money_loose(id,type)
	if (type == 1) then
		parse("setmoney "..id.." "..player(id,"money")-buildingmoney[1])
	elseif (type == 2) then
		parse("setmoney "..id.." "..player(id,"money")-buildingmoney[2])
	elseif (type == 3) then
		parse("setmoney "..id.." "..player(id,"money")-buildingmoney[3])
	elseif (type == 4) then
		parse("setmoney "..id.." "..player(id,"money")-buildingmoney[4])
	elseif (type == 5) then
		parse("setmoney "..id.." "..player(id,"money")-buildingmoney[5])
	elseif (type == 6) then
		parse("setmoney "..id.." "..player(id,"money")-buildingmoney[6])
	elseif (type == 7) then
		parse("setmoney "..id.." "..player(id,"money")-buildingmoney[7])
	elseif (type == 8) then
		parse("setmoney "..id.." "..player(id,"money")-buildingmoney[7])
	elseif (type == 9) then
		parse("setmoney "..id.." "..player(id,"money")-buildingmoney[7])
	elseif (type == 13) then
		parse("setmoney "..id.." "..player(id,"money")-buildingmoney[8])
	elseif (type == 14) then
		parse("setmoney "..id.." "..player(id,"money")-buildingmoney[8])
	end
end
----------------------------
-------No Build Limit-------
--------By BLACK_J93--------
----------------------------


parse('mp_building_limit "dispenser" 5')
parse('mp_building_limit "turret" 5')
parse('mp_building_limit "supply" 20')
parse('mp_building_limit "gate field" 500')
parse('mp_building_limit "wall I" 500')
parse('mp_building_limit "wall II" 500')
parse('mp_building_limit "wall III" 500')
parse('mp_building_limit "barbed wire" 500')
parse('mp_building_limit "Barricade" 500')
parse('mp_building_limit "teleporter exit" 1')
parse('mp_building_limit "teleporter entrance" 1')

my server is giving exception Violation accessories for all players also why?
edited 1×, last 29.11.14 03:16:00 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview