1
- local resX , resY = guiGetScreenSize ()
2
- local tbl = {}
3
-
1
+ local radioSpeakers = {}
2
+ local blackColor = tocolor ( 0 , 0 , 0 , 255 )
3
+ local textColor = tocolor ( 150 , 50 , 150 , 255 )
4
4
local radioTable = {
5
5
{" [Top 40 Mix] BAYERN Radio - Top40" , " http://stream.antenne.de:80/top-40" },
6
6
{" [Top 40 Mix] 1.FM - Absolute Top 40" , " http://185.33.21.111:80/top40_32a" },
@@ -89,12 +89,13 @@ local radioTable = {
89
89
}
90
90
91
91
function speakersysGUI ()
92
-
93
92
if (speakersys ) then
94
93
return true
95
94
end
96
95
97
- speakersys = guiCreateWindow ((resX - 325 ) / 1.1 , (resY - 380 ) / 1.4 , 325 , 380 , " SPEAKER MUSIC (RADIO/MP3)" , false )
96
+ local screenX , screenY = guiGetScreenSize ()
97
+
98
+ speakersys = guiCreateWindow ((screenX - 325 ) / 1.1 , (screenY - 380 ) / 1.4 , 325 , 380 , " SPEAKER MUSIC (RADIO/MP3)" , false )
98
99
guiSetAlpha (speakersys , 1 )
99
100
guiWindowSetSizable (speakersys , false )
100
101
urlGrid = guiCreateGridList (10 , 54 , 304 , 139 , false , speakersys )
@@ -192,36 +193,36 @@ end
192
193
addEventHandler (" onClientGUIClick" , resourceRoot , clickEvent )
193
194
194
195
function setData (value , theType , serial )
195
- if (not tbl [serial ]) then
196
+ if (not radioSpeakers [serial ]) then
196
197
return
197
198
end
198
199
199
- if (not isElement (tbl [serial ][1 ])) then
200
+ if (not isElement (radioSpeakers [serial ][1 ])) then
200
201
return
201
202
end
202
203
203
204
if (theType == " vol" ) then
204
- setSoundVolume (tbl [serial ][1 ], value )
205
+ setSoundVolume (radioSpeakers [serial ][1 ], value )
205
206
elseif (theType == " dist" ) then
206
- setSoundMaxDistance (tbl [serial ][1 ], 65 )
207
+ setSoundMaxDistance (radioSpeakers [serial ][1 ], 65 )
207
208
elseif (theType == " destroy" ) then
208
- stopSound (tbl [serial ][1 ])
209
- destroyElement (tbl [serial ][2 ])
210
- tbl [serial ] = nil
209
+ stopSound (radioSpeakers [serial ][1 ])
210
+ destroyElement (radioSpeakers [serial ][2 ])
211
+ radioSpeakers [serial ] = nil
211
212
end
212
213
end
213
214
addEvent (" speaker.setData" , true )
214
215
addEventHandler (" speaker.setData" , root , setData )
215
216
216
217
function setPaused (serial )
217
- if (not tbl [serial ]) then
218
+ if (not radioSpeakers [serial ]) then
218
219
return
219
220
end
220
221
221
- if (not isElement (tbl [serial ][1 ])) then
222
+ if (not isElement (radioSpeakers [serial ][1 ])) then
222
223
return
223
224
end
224
- setSoundPaused (tbl [serial ][1 ], not isSoundPaused (tbl [serial ][1 ]))
225
+ setSoundPaused (radioSpeakers [serial ][1 ], not isSoundPaused (radioSpeakers [serial ][1 ]))
225
226
end
226
227
addEvent (" speaker.ps" , true )
227
228
addEventHandler (" speaker.ps" , root , setPaused )
@@ -233,9 +234,9 @@ function setBox(str)
233
234
234
235
for serial , ent in pairs (str ) do
235
236
236
- if (tbl [serial ] and isElement (tbl [serial ][1 ])) then
237
- destroyElement (tbl [serial ][1 ])
238
- destroyElement (tbl [serial ][2 ])
237
+ if (radioSpeakers [serial ] and isElement (radioSpeakers [serial ][1 ])) then
238
+ destroyElement (radioSpeakers [serial ][1 ])
239
+ destroyElement (radioSpeakers [serial ][2 ])
239
240
end
240
241
241
242
if (isElement (ent [1 ])) then
@@ -246,7 +247,7 @@ function setBox(str)
246
247
setElementAlpha (dumm , 0 )
247
248
setElementCollisionsEnabled (dumm , false )
248
249
attachElements (dumm , ent [1 ], - 0.32 , - 0.22 , 0.8 )
249
- tbl [serial ] = {radio , dumm }
250
+ radioSpeakers [serial ] = {radio , dumm }
250
251
251
252
if (ent [6 ] and isElement (ent [6 ])) then
252
253
attachElements (radio , ent [6 ])
@@ -265,16 +266,16 @@ addEvent("speaker.setBox", true)
265
266
addEventHandler (" speaker.setBox" , root , setBox )
266
267
267
268
function getRadioInfo ()
268
- for key , radio in pairs (tbl ) do
269
+ for key , radio in pairs (radioSpeakers ) do
269
270
if (radio [1 ] and isElement (radio [1 ])) then
270
- tbl [key ][3 ] = nil
271
- table.insert (tbl [key ], getSoundMetaTags (radio [1 ]).stream_title or getSoundMetaTags (radio [1 ]).title )
271
+ radioSpeakers [key ][3 ] = nil
272
+ table.insert (radioSpeakers [key ], getSoundMetaTags (radio [1 ]).stream_title or getSoundMetaTags (radio [1 ]).title )
272
273
end
273
274
end
274
275
end
275
276
276
277
function drawData ()
277
- for key , radio in pairs (tbl ) do
278
+ for key , radio in pairs (radioSpeakers ) do
278
279
if (radio [2 ] and isElement (radio [2 ] and radio [1 ])) then
279
280
local eX , eY , eZ = getElementPosition (radio [2 ])
280
281
eZ = (eZ + 1 )
@@ -285,7 +286,7 @@ function drawData()
285
286
if (not enable and getElementData (radio [1 ], " ob" ) ~= getPlayerName (localPlayer )) then
286
287
stopSound (radio [1 ])
287
288
destroyElement (radio [2 ])
288
- tbl [key ] = nil
289
+ radioSpeakers [key ] = nil
289
290
return false
290
291
end
291
292
@@ -302,8 +303,8 @@ function drawData()
302
303
303
304
local width = dxGetTextWidth (text , 1 , " default-bold" )
304
305
305
- dxDrawRectangle (sx - width / 2 - 5 , sy , width + 8 , height , tocolor ( 0 , 0 , 0 , 255 ) , false )
306
- dxDrawText (text , sx - width / 2 , sy , sx - width / 2 , sy , tocolor ( 150 , 50 , 150 , 255 ) , 1 , " default-bold" )
306
+ dxDrawRectangle (sx - width / 2 - 5 , sy , width + 8 , height , blackColor , false )
307
+ dxDrawText (text , sx - width / 2 , sy , sx - width / 2 , sy , textColor , 1 , " default-bold" )
307
308
end
308
309
end
309
310
end
0 commit comments