English Physics_cars not working

5 replies
Goto Page
To the start Previous 1 Next To the start
11.04.21 07:29:25 pm
Up
NanuPlayer
User
Offline Off
hey all, i can't use physics cars *Samples Script* when i spawn car this error happen :
***************************
Windows exception
EXCEPTION_ACCESS_VIOLATION
***************************

if someone can fix this bug pls

here is the script :

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
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
--------------------------------------------------
-- Cars Script by Unreal Software               --
-- 21.02.2019 - www.UnrealSoftware.de           --
-- Uses physics to create cars                  --
--------------------------------------------------

dofile("sys/lua/physics.lua")

physController = { movement_absolute = 0, movement_relative = 1, movement_vehicle = 2}
physObject = { property_wall = 0, property_obstacle = 1, property_floor = 2}
physImage = { parent_relative = 0, parent_absolute = 1}

addhook("startround","startround")

function startround()
     --parse("phys_spawnvehicle 1 850 250")

     car1(400,450)
     car2(400,350)
end

function car1(x, y)
     local platform = Physics:newRectanglePlatform(x, y, 0, 170, 60)
     platform:setMass(3)
     --platform:setBounciness(1)

     -- Walls/Obstacles (Optimize)
     physObject = Physics:newRectangle(48, -30, 0, 64, 5)
     physObject:setParent(platform)

     physObject = Physics:newRectangle(48, 30, 0, 64, 5)
     physObject:setParent(platform)

     physObject = Physics:newRectangle(-38, -30, 0, 80, 5)
     physObject:setParent(platform)

     --physObject = Physics:newRectangle(6, 0, 5, 0, 60)
     --physObject:setParent(platform)

     physObject = Physics:newRectangle(60, 0, 0, 45, 60)
     physObject:setParent(platform)

     physObject = Physics:newRectangle(-57, 0, 0, 44, 60)
     physObject:setParent(platform)

     -- Wheels
     wheelRL = Physics:newTire(44, 29, 0, 24, 8)
     wheelRL:setParent(platform)

     wheelRR = Physics:newTire(44, -29, 0, 24, 8)
     wheelRR:setParent(platform)

     wheelFL = Physics:newTire(-54, 29, 0, 24, 8)
     wheelFL:setParent(platform)

     wheelFR = Physics:newTire(-54, -29, 0, 24, 8)
     wheelFR:setParent(platform)

     -- Controller Setup
     controller = Physics:newController(-32, 0, 16, platform, Physics.CONTROLLER_VEHICLE)
     controller:setParent(platform)

     controller:set("force_clear")
     controller:set("force_front_up", 700)
     controller:set("force_front_down", 450)

     -- Setup Controller Wheels
     controller:set("add_frontwheel", wheelFL:getId())
     controller:set("add_frontwheel", wheelFR:getId())

     controller:set("add_rearwheel", wheelRL:getId())
     controller:set("add_rearwheel", wheelRR:getId())
     controller:set("steering_sensitivity", 15)
     controller:set("steering_angle", 15)

     -- Images
     img1 = image("incbin::incbindata/vehicles/car2_floor.png", 0, 0, 0)
     img2 = image("incbin::incbindata/vehicles/car2_obstacle.png", 0, 0, 1)
     img3 = image("incbin::incbindata/vehicles/car2_wall.png", 0, 0, 1)

     imagephysicsparent(img1, platform:getId(), physImage.parent_relative)
     imagephysicsparent(img2, platform:getId(), physImage.parent_relative)
     imagephysicsparent(img3, platform:getId(), physImage.parent_relative)

     imageshadow(img1, 1)

     return platform
end

function car2(x, y)
     local platform = Physics:newRectanglePlatform(x, y, 0, 170, 60)
     platform:setMass(3)
     --platform:setBounciness(1)

     -- Walls/Obstacles
     physObject = Physics:newRectangle(48, -30, 0, 64, 5)
     physObject:setParent(platform)

     physObject = Physics:newRectangle(48, 30, 0, 64, 5)
     physObject:setParent(platform)

     physObject = Physics:newRectangle(6, 0, 0, 5, 60)
     physObject:setParent(platform)

     physObject = Physics:newRectangle(-64, 0, 0, 32, 60)
     physObject:setParent(platform)

     -- Wheels
     wheelRL = Physics:newTire(44, 33, 0, 24, 8)
     wheelRL:setParent(platform)

     wheelRR = Physics:newTire(44, -33, 0, 24, 8)
     wheelRR:setParent(platform)

     wheelFL = Physics:newTire(-54, 33, 0, 24, 8)
     wheelFL:setParent(platform)

     wheelFR = Physics:newTire(-54, -33, 0, 24, 8)
     wheelFR:setParent(platform)

     -- Controller Setup
     controller = Physics:newController(-32, 0, 16, platform, Physics.CONTROLLER_VEHICLE)
     controller:setParent(platform)

     controller:set("force_clear")
     controller:set("force_front_up", 500)
     controller:set("force_front_down", 450)

     -- Setup Controller Wheels
     controller:set("add_frontwheel", wheelFL:getId())
     controller:set("add_frontwheel", wheelFR:getId())
     controller:set("steering_sensitivity", 5)

     controller:set("add_rearwheel", wheelRL:getId())
     controller:set("add_rearwheel", wheelRR:getId())
     controller:set("steering_angle", 15)

     -- Images
     img1 = image("incbin::incbindata/vehicles/car_floor.png", 0, 0, 0)
     img2 = image("incbin::incbindata/vehicles/car_obstacle.png", 0, 0, 1)
     img3 = image("incbin::incbindata/vehicles/car_wall.png", 0, 0, 1)

     imagephysicsparent(img1, platform:getId(), physImage.parent_relative)
     imagephysicsparent(img2, platform:getId(), physImage.parent_relative)
     imagephysicsparent(img3, platform:getId(), physImage.parent_relative)

     imageshadow(img1, 1)

     return platform
end

startround()


can someone fix it please
Bad Life
11.04.21 07:34:18 pm
Up
SQ
Moderator
Offline Off
Have you enabled physics in the server?
11.04.21 07:55:59 pm
Up
NanuPlayer
User
Offline Off
@user SQ: sv_physics 1
Bad Life
11.04.21 07:59:42 pm
Up
Mami Tomoe
User
Offline Off
Are you running any other scripts on the server?
Try disabling any other scripts that could be interfering with the sample script.

Still doesn't work? Try to play on an empty map that is 200x200 tiles in size and is entirely filled with floor tiles (and spawns of course).
fish
11.04.21 08:08:06 pm
Up
NanuPlayer
User
Offline Off
@user Mami Tomoe: i play empty cs2d without scripts and 200x200 map no changes still not working
Bad Life
11.04.21 08:11:59 pm
Up
SQ
Moderator
Offline Off
It could crash if you spawn vehicles inside the wall as far as I remember.
I could check it soon. I haven't been testing physics for a while, so perhaps bigger flaw opened with updates.

Could you pack CS2D and send it to me?
I wonder what's causing the crash, I could probably trace it.
edited 1×, last 11.04.21 11:52:04 pm
To the start Previous 1 Next To the start