Forum

> > CS2D > Scripts > expection_access_violation
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch expection_access_violation

5 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt expection_access_violation

0oa
User Off Offline

Zitieren
I made a script on my RP server with a change in time.
Only when players came at them this error got out.

IMG:https://www.dropbox.com/s/p4brm52r9hsbjzq/12313.PNG?dl=1


Some were fine,some weren't.
P. S - sv_physics down.

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
Day = {}
Day.Time = 300
Day.Seconds = 0
Day.Day = true
Day.Night = false

  parse("sv_daylighttime " .. Day.Time)
  
function main.second()
Day.Seconds = Day.Seconds + 1
if Day.Time > 170 and Day.Time < 300 then Day.Day = true Day.Night = false  end
if Day.Time > 300 or Day.Time < 170 then Day.Day = false Day.Night = true end

if Day.Seconds == 2 and Day.Day then 
Day.Seconds = 0 
Day.Time = Day.Time + 1
parse("sv_daylighttime " .. Day.Time) 
for i,id in pairs(player(0,"table")) do parse("hudtxt2 " .. id .. ' 2 "' .. "' " .. Day.Time .. " ' Day" .. ' " ' .. player(id,"screenw") / 2 .. " " .. player(id,"screenh") - 20 .. " 1 1 20" ) end
end

if Day.Seconds == 1 and Day.Night then 
Day.Seconds = 0 
Day.Time = Day.Time + 1
parse("sv_daylighttime " .. Day.Time) 
for i,id in pairs(player(0,"table")) do parse("hudtxt2 " .. id .. ' 2 "' .. "' " .. Day.Time .. " ' Night" .. '" ' .. player(id,"screenw") / 2 .. " " .. player(id,"screenh") - 20 .. " 1 1 20" ) end
end

if Day.Time > 360 then Day.Time = 0 end
end

alt Re: expection_access_violation

Edik
User Off Offline

Zitieren
the error came because of main.second(). Errors occur sometime, but you can lookup them in console or in the serverlogs. Further there was the hook missing and I shortened your code a little bit.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
day = {}
day.time = 300
day.day = "night"

parse("sv_daylighttime " .. day.time)
parse("mp_hudscale 1")

addhook("second", "second")
function second()
	day.time = day.time + 1
	if day.Time == 170 then day.day = "day" end
	if day.Time == 300 then day.day = "night" end
	
	parse("sv_daylighttime " .. day.time)
	parse('hudtxt 2 "©255255000'..day.time..' - '..day.day..'" 425 480 1 2')

	if day.time >= 360 then day.time = 0 end
end

alt Re: expection_access_violation

DC
Admin Off Offline

Zitieren
You should try to write less stuff in one line and use proper indentation. This will greatly improve the quality of your code and makes it easier to read and understand. For yourself and others!

• always start a new line after then/do
• "end" always in separate line
• never write two statements in one line

This is what it should look like (only added proper indentation and line breaks, can still be improved of course):
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
Day = {}
Day.Time = 300
Day.Seconds = 0
Day.Day = true
Day.Night = false

parse("sv_daylighttime " .. Day.Time)
  
function main.second()
	Day.Seconds = Day.Seconds + 1
	if Day.Time > 170 and Day.Time < 300 then
		Day.Day = true
		Day.Night = false
	end
	if Day.Time > 300 or Day.Time < 170 then
		Day.Day = false
		Day.Night = true
	end

	if Day.Seconds == 2 and Day.Day then 
		Day.Seconds = 0 
		Day.Time = Day.Time + 1
		parse("sv_daylighttime " .. Day.Time) 
		for i,id in pairs(player(0,"table")) do
			parse("hudtxt2 " .. id .. ' 2 "' .. "' " .. Day.Time .. " ' Day" .. ' " ' .. player(id,"screenw") / 2 .. " " .. player(id,"screenh") - 20 .. " 1 1 20" )
		end
	end

	if Day.Seconds == 1 and Day.Night then 
		Day.Seconds = 0 
		Day.Time = Day.Time + 1
		parse("sv_daylighttime " .. Day.Time) 
		for i,id in pairs(player(0,"table")) do
			parse("hudtxt2 " .. id .. ' 2 "' .. "' " .. Day.Time .. " ' Night" .. '" ' .. player(id,"screenw") / 2 .. " " .. player(id,"screenh") - 20 .. " 1 1 20" )
		end
	end

	if Day.Time > 360 then
		Day.Time = 0
	end
end

I don't see any severe problems in the code though.
I don't see "addhook" either so this can't be the complete code. Are you using libraries? Is there more code?

Edit: Oh, too slow...

alt Re: expection_access_violation

GeoB99
Moderator Off Offline

Zitieren
Could you please elaborate on what you say? Do you have any other scripts running within the server that may potentially trigger this issue?

alt Re: expection_access_violation

0oa
User Off Offline

Zitieren
Ohohoho
A lot!

• Inventory system : Multifunctional
• Group system
• The radiation system
• Voice system :
the Player says the phrase,depending on the group

• Store system

• As well as the small details

I will say that there is a mess.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht