English expection_access_violation

5 replies
Goto Page
To the start Previous 1 Next To the start
05.08.19 05:26:37 pm
Up
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
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
b
05.08.19 07:49:55 pm
Up
Edik
User
Offline Off
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.

Code:
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
05.08.19 07:52:36 pm
Up
DC
Admin
Offline Off
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):
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
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...
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
06.08.19 01:00:43 pm
Up
Okkaayyy...?
Like changed on your,and like-would players not crashes.
b
06.08.19 02:47:13 pm
Up
Fraizeraust
Moderator
Offline Off
Could you please elaborate on what you say? Do you have any other scripts running within the server that may potentially trigger this issue?
06.08.19 05:59:16 pm
Up
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.
b
To the start Previous 1 Next To the start