-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinternal.lua
211 lines (185 loc) · 4.05 KB
/
internal.lua
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
function dataview_type_from_property_type(view, propertyType)
if propertyType == 'i32' then
return view.GetInt32
elseif propertyType == 'f32' then
return view.GetFloat32
end
end
function float32_to_int32(num)
local _view = DataView.ArrayBuffer(16)
_view:SetFloat32(0, num, false);
return _view:GetInt32(0);
end
struct = {
--{
-- name = 'placeholder',
-- type = 'i32',
-- value = nil,
--},
{ -- 0
name = 'minigameState',
type = 'i32',
},
{ -- 1
name = 'throwingDistance',
type = 'f32',
},
{ -- 2
name = 'distanceToHook',
type = 'f32',
},
{ -- 3
name = 'lineCurvature',
type = 'f32',
},
{ -- 4
name = 'unk',
type = 'f32',
},
{ -- 5
name = 'unk1',
type = 'i32',
},
{ -- 6
name = 'transitionFlag',
type = 'i32',
},
{ -- 7
name = 'fishEntity',
type = 'i32',
},
{ -- 8
name = 'unk2',
type = 'f32',
},
{ -- 9
name = 'unk3',
type = 'f32',
},
{ -- 10
name = 'scriptTimer',
type = 'i32',
},
{ -- 11
name = 'hookEntity',
type = 'i32',
},
{ -- 12
name = 'bobberEntity',
type = 'i32',
},
{ -- 13
name = 'lineShake',
type = 'f32',
},
{ -- 14
name = 'unk4',
type = 'f32',
},
{ -- 15
name = 'unk5',
type = 'f32',
},
{ -- 16
name = 'unk6',
type = 'i32',
},
{ -- 17
name = 'unk7',
type = 'f32',
},
{ -- 18
name = 'rodWeight',
type = 'i32',
},
{ -- 19
name = 'unk8',
type = 'f32',
},
{ -- 20
name = 'unk9',
type = 'f32',
},
{ -- 21
name = 'lineShake2',
type = 'f32',
},
{ -- 22
name = 'rodPositionLR',
type = 'f32',
},
{ -- 23
name = 'rodPositionUD',
type = 'f32',
},
{ -- 24
name = 'unk10',
type = 'f32',
},
{ -- 25
name = 'unk11',
type = 'f32',
},
{ -- 26
name = 'unk12',
type = 'f32',
},
{ -- 27
name = 'unk13',
type = 'f32',
},
}
local view = DataView.ArrayBuffer(256)
function fetch()
Citizen.InvokeNative(0xF3735ACD11ACD500, PlayerPedId(), view:Buffer(), Citizen.ReturnResultAnyway());
for i, struct_property in ipairs(struct) do
local byte = (i - 1) * 8
local value
if struct_property.type == 'i32' then
value = view:GetInt32(byte)
elseif struct_property.type == 'f32' then
value = view:GetFloat32(byte)
end
struct[i].value = value
end
end
function flush()
for i, struct_property in ipairs(struct) do
struct[i].value = nil
end
end
function update(updated_property_name)
for i, struct_property in ipairs(struct) do
if struct_property.name == updated_property_name then
local byte = (i - 1) * 8
local value = struct_property.value
local int32 = value
if struct_property.type == 'f32' then
int32 = float32_to_int32(value)
end
view:SetInt32(byte, int32)
break
end
end
Citizen.InvokeNative("0xF3735ACD11ACD501", PlayerPedId(), view:Buffer());
end
function find(property)
for i, struct_property in ipairs(struct) do
if struct_property.name == property then
return struct_property
end
end
end
function get(property)
local struct_property = find(property)
if struct_property then
return struct_property.value
end
end
function set(property, new_value)
local struct_property = find(property)
if struct_property then
struct_property.value = new_value
update(struct_property.name)
end
end