Jump to content

koragg

Members
  • Posts

    730
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by koragg

  1. That's not how community works Post screenshot of all errors and people will try to help you understand what the problem is so you can fix it yourself (or atleast try to).
  2. I suggested him to put : local state = getElementData(localPlayer, "player state") if state == "spectating" then return end but it still didn't work (we tested).
  3. Released: https://community.multitheftauto.com/index.php?p=resources&s=details&id=14043 Enjoy!
  4. So I got a script which counted race laps by counting its checkpoints and when a player reaches a certain cp number, it increases the laps (script had to be manually added to each map for this to work). It goes with no saying that this is just bad for a server resource (as it was made for one map only) so I edited it to work on any map at my server. And the problem now's that it works too good When I go through the start it doesn't increase the lap by 1, but by a lot (random number). How can I cancel this and make it increase lap by 1 each time I pass the start/finish line? local sx,sy = guiGetScreenSize() fontLCD22 = dxCreateFont("lcd.ttf", 22) local lap = 1 local x, y, z = false local a, b, c = false local dist = false function updateDisplay() a, b, c = getElementPosition(localPlayer) if x and y and z then dist = getDistanceBetweenPoints3D(x, y, z, a, b, c) end if getElementData(localPlayer, "race.checkpoint") == nil then return end if getElementData(localPlayer, "race.checkpoint") >= 4 then if dist and dist < 40 then setElementData(localPlayer, "lap", lap+1) lap = lap+1 end end local target = localPlayer if getElementData(localPlayer, "race.spectating") then target = getVehicleOccupant(getCameraTarget(localPlayer), 0) end dxDrawText("Lap: "..tostring(getElementData(target, "lap")), sx - 90, sy- 155, 40, 30, tocolor(255, 255, 255, 255), 0.6, fontLCD22, "left", "top", false, false, false) end addEventHandler("onClientRender", getRootElement(), updateDisplay) addEvent("onClientMapStarting", true) function onMapStart() if getElementData(localPlayer, "lap") ~= 1 then setElementData(localPlayer, "lap", 1) end x, y, z = getElementPosition(localPlayer) end addEventHandler("onClientMapStarting", root, onMapStart) function onClientResStart() if getElementData(localPlayer, "lap") ~= lap then setElementData(localPlayer, "lap", lap) end end addEventHandler("onClientResourceStart", resourceRoot, onClientResStart)
  5. Check this out : https://github.com/JarnoVgr/Mr.Green-MTA-Resources/tree/master/resources/[race]/race_toptimes Idk what method is used but maybe it's what you're looking for.
  6. koragg

    (Help)Vehicle

    That's true but he's using NerdGaming's script which is open-source.
  7. Well I found Nerd-Gaming's resources on github so I don't think that's leaked? (it's open-source?)
  8. @myonlake Thanks a lot mate worked.
  9. @myonlake that was just part of the code responsible for drawing. Here's full: local name, author, mode ------------------------------------------------------------------------------------------------------------------------- function handleMapInfo(mapInfo) name = mapInfo.name or "Unknown" author = mapInfo.author or "Unknown" mode = mapInfo.modename ~= "Race" and mapInfo.modename or "Destruction derby" end addEvent("onClientMapStarting",true) addEventHandler("onClientMapStarting",getRootElement(),handleMapInfo) ------------------------------------------------------------------------------------------------------------------------- function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, alignX, alignY) bx, by, color, scale, font = bx or ax, by or ay, color or tocolor(255,255,255,255), scale or 1, font or "default" if alignX then if alignX == "center" then ax = ax + (bx - ax - dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font))/2 elseif alignX == "right" then ax = bx - dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font) end end if alignY then if alignY == "center" then ay = ay + (by - ay - dxGetFontHeight(scale, font))/2 elseif alignY == "bottom" then ay = by - dxGetFontHeight(scale, font) end end local alpha = string.format("%08X", color):sub(1,2) local pat = "(.-)#(%x%x%x%x%x%x)" local s, e, cap, col = str:find(pat, 1) local last = 1 while s do if cap == "" and col then color = tocolor(getColorFromString("#"..col..alpha)) end if s ~= 1 or cap ~= "" then local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) ax = ax + w color = tocolor(getColorFromString("#"..col..alpha)) end last = e + 1 s, e, cap, col = str:find(pat, last) end if last <= #str then cap = str:sub(last) dxDrawText(cap, ax, ay, ax + dxGetTextWidth(cap, scale, font), by, color, scale, font) end end ------------------------------------------------------------------------------------------------------------------------- addEvent("onClientMapStarting",true) function prerender() fade = 0 width, height = guiGetScreenSize() setTimer(function() check = 0 end,3650,1) if isEventHandlerAdded("onClientRender",getRootElement(),renderText) == false then addEventHandler("onClientRender",getRootElement(),renderText) end end addEventHandler("onClientMapStarting",getRootElement(), prerender) ------------------------------------------------------------------------------------------------------------------------- function prerenderfix() fade = 0 width, height = guiGetScreenSize() setTimer(function() check = 0 end,50,1) if isEventHandlerAdded("onClientRender",getRootElement(),renderText) == false then addEventHandler("onClientRender",getRootElement(),renderText) end end ------------------------------------------------------------------------------------------------------------------------- function renderText() if fade <= 253 and check == 0 then fade = fade + 2 dxDrawColorText("Map: "..name, 1, 1, width+1, height+1, tocolor(0,0,0,fade), (width/1660)*3, "sans", "center", "bottom") dxDrawColorText("#00FFFFMap: #FEFE22"..name, 0, 0, width, height, tocolor(255,255,255,fade), (width/1660)*3, "sans", "center", "bottom") elseif check == 0 then check = 1 dxDrawColorText("Map: "..name, 1, 1, width+1, height+1, tocolor(0,0,0,255), (width/1660)*3, "sans", "center", "bottom") dxDrawColorText("#00FFFFMap: #FEFE22"..name, 0, 0, width, height, tocolor(255,255,255,255), (width/1660)*3, "sans", "center", "bottom") fade = 254 elseif fade <= 254 and check == 1 and fade ~= 0 then fade = fade - 2 dxDrawColorText("Map: "..name, 1, 1, width+1, height+1, tocolor(0,0,0,fade), (width/1660)*3, "sans", "center", "bottom") dxDrawColorText("#00FFFFMap: #FEFE22"..name, 0, 0, width, height, tocolor(255,255,255,fade), (width/1660)*3, "sans", "center", "bottom") elseif fade == 0 and check == 1 then check = 2 elseif fade <= 253 and check == 2 then fade = fade + 2 dxDrawColorText("Author(s): "..author, 1, 1, width+1, height+1, tocolor(0,0,0,fade), (width/1660)*3, "sans", "center", "bottom") dxDrawColorText("#00FFFFAuthor(s): #FEFE22"..author, 0, 0, width, height, tocolor(255,255,255,fade), (width/1660)*3, "sans", "center", "bottom") elseif check == 2 then check = 3 dxDrawColorText("Author(s): "..author, 1, 1, width+1, height+1, tocolor(0,0,0,255), (width/1660)*3, "sans", "center", "bottom") dxDrawColorText("#00FFFFAuthor(s): #FEFE22"..author, 0, 0, width, height, tocolor(255,255,255,255), (width/1660)*3, "sans", "center", "bottom") fade = 254 elseif fade <= 254 and check == 3 and fade ~= 0 then fade = fade - 2 dxDrawColorText("Author(s): "..author, 1, 1, width+1, height+1, tocolor(0,0,0,fade), (width/1660)*3, "sans", "center", "bottom") dxDrawColorText("#00FFFFAuthor(s): #FEFE22"..author, 0, 0, width, height, tocolor(255,255,255,fade), (width/1660)*3, "sans", "center", "bottom") elseif fade == 0 and check == 3 then check = 4 elseif fade <= 253 and check == 4 then fade = fade + 2 dxDrawColorText("Gamemode: "..mode, 1, 1, width+1, height+1, tocolor(0,0,0,fade), (width/1660)*3, "sans", "center", "bottom") dxDrawColorText("#00FFFFGamemode: #FEFE22"..mode, 0, 0, width, height, tocolor(255,255,255,fade), (width/1660)*3, "sans", "center", "bottom") elseif check == 4 then check = 5 dxDrawColorText("Gamemode: "..mode, 1, 1, width+1, height+1, tocolor(0,0,0,255), (width/1660)*3, "sans", "center", "bottom") dxDrawColorText("#00FFFFGamemode: #FEFE22"..mode, 0, 0, width, height, tocolor(255,255,255,255), (width/1660)*3, "sans", "center", "bottom") fade = 254 elseif fade <= 254 and check == 5 and fade ~= 0 then fade = fade - 2 dxDrawColorText("Gamemode: "..mode, 1, 1, width+1, height+1, tocolor(0,0,0,fade), (width/1660)*3, "sans", "center", "bottom") dxDrawColorText("#00FFFFGamemode: #FEFE22"..mode, 0, 0, width, height, tocolor(255,255,255,fade), (width/1660)*3, "sans", "center", "bottom") elseif fade == 0 and check == 5 then check = 6 end end bindKey("F5","down",prerenderfix,renderText) ------------------------------------------------------------------------------------------------------------------------- function isEventHandlerAdded(sEventName, pElementAttachedTo, func) if type(sEventName) == 'string' and isElement(pElementAttachedTo) and type(func) == 'function' then local aAttachedFunctions = getEventHandlers(sEventName, pElementAttachedTo) if type(aAttachedFunctions) == 'table' and #aAttachedFunctions > 0 then for i, v in ipairs(aAttachedFunctions) do if v == func then return true end end end end return false end Well, when I press F5 the text fades in, stays a few seconds on screen and then fades out. And if I press F5 while the text is showing, it starts from the beginning again. I wanna make it so that if there's any text (map name, author or gamemode) on screen it wouldn't do anything when I press F5.
  10. Hello, I'm facing a small but really annoying problem with the mapinfo script I'm using. Problem's that when I press the key (F5) to show mapinfo while text is still being drawn at the moment (fades away slowly) it just starts from the beginning again. This makes a really bad effect and also gets annoying if you just want to check toptimes as the mapinfo starts over and over again and again. I tried messing with timers and some booleans but no deal. Help? function prerenderfix() fade = 0 width, height = guiGetScreenSize() setTimer(function() check = 0 end,50,1) if isEventHandlerAdded("onClientRender",getRootElement(),renderText) == false then addEventHandler("onClientRender",getRootElement(),renderText) end end bindKey("F5","down",prerenderfix) ------------------------------------------------------------------------------------------------------------------------- function renderText() if fade <= 253 and check == 0 then fade = fade + 2 dxDrawColorText("Map: "..name, 1, 1, width+1, height+1, tocolor(0,0,0,fade), (width/1660)*3, "sans", "center", "bottom") dxDrawColorText("#00FFFFMap: #FEFE22"..name, 0, 0, width, height, tocolor(255,255,255,fade), (width/1660)*3, "sans", "center", "bottom") elseif check == 0 then check = 1 dxDrawColorText("Map: "..name, 1, 1, width+1, height+1, tocolor(0,0,0,255), (width/1660)*3, "sans", "center", "bottom") dxDrawColorText("#00FFFFMap: #FEFE22"..name, 0, 0, width, height, tocolor(255,255,255,255), (width/1660)*3, "sans", "center", "bottom") fade = 254 elseif fade <= 254 and check == 1 and fade ~= 0 then fade = fade - 2 dxDrawColorText("Map: "..name, 1, 1, width+1, height+1, tocolor(0,0,0,fade), (width/1660)*3, "sans", "center", "bottom") dxDrawColorText("#00FFFFMap: #FEFE22"..name, 0, 0, width, height, tocolor(255,255,255,fade), (width/1660)*3, "sans", "center", "bottom") elseif fade == 0 and check == 1 then check = 2 elseif fade <= 253 and check == 2 then fade = fade + 2 dxDrawColorText("Author(s): "..author, 1, 1, width+1, height+1, tocolor(0,0,0,fade), (width/1660)*3, "sans", "center", "bottom") dxDrawColorText("#00FFFFAuthor(s): #FEFE22"..author, 0, 0, width, height, tocolor(255,255,255,fade), (width/1660)*3, "sans", "center", "bottom") elseif check == 2 then check = 3 dxDrawColorText("Author(s): "..author, 1, 1, width+1, height+1, tocolor(0,0,0,255), (width/1660)*3, "sans", "center", "bottom") dxDrawColorText("#00FFFFAuthor(s): #FEFE22"..author, 0, 0, width, height, tocolor(255,255,255,255), (width/1660)*3, "sans", "center", "bottom") fade = 254 elseif fade <= 254 and check == 3 and fade ~= 0 then fade = fade - 2 dxDrawColorText("Author(s): "..author, 1, 1, width+1, height+1, tocolor(0,0,0,fade), (width/1660)*3, "sans", "center", "bottom") dxDrawColorText("#00FFFFAuthor(s): #FEFE22"..author, 0, 0, width, height, tocolor(255,255,255,fade), (width/1660)*3, "sans", "center", "bottom") elseif fade == 0 and check == 3 then check = 4 elseif fade <= 253 and check == 4 then fade = fade + 2 dxDrawColorText("Gamemode: "..mode, 1, 1, width+1, height+1, tocolor(0,0,0,fade), (width/1660)*3, "sans", "center", "bottom") dxDrawColorText("#00FFFFGamemode: #FEFE22"..mode, 0, 0, width, height, tocolor(255,255,255,fade), (width/1660)*3, "sans", "center", "bottom") elseif check == 4 then check = 5 dxDrawColorText("Gamemode: "..mode, 1, 1, width+1, height+1, tocolor(0,0,0,255), (width/1660)*3, "sans", "center", "bottom") dxDrawColorText("#00FFFFGamemode: #FEFE22"..mode, 0, 0, width, height, tocolor(255,255,255,255), (width/1660)*3, "sans", "center", "bottom") fade = 254 elseif fade <= 254 and check == 5 and fade ~= 0 then fade = fade - 2 dxDrawColorText("Gamemode: "..mode, 1, 1, width+1, height+1, tocolor(0,0,0,fade), (width/1660)*3, "sans", "center", "bottom") dxDrawColorText("#00FFFFGamemode: #FEFE22"..mode, 0, 0, width, height, tocolor(255,255,255,fade), (width/1660)*3, "sans", "center", "bottom") elseif fade == 0 and check == 5 then check = 6 end end
  11. I think I fixed it with the following code. Only the flag's Y position gets sliiiiiiiiightly low when another player is on a higher surface than you and is a bit far away from you but that's a really minor thing which only I see probably --Draw our text local nickLength = dxGetTextWidth( getPlayerName(player), textscale*NAMETAG_TEXTSIZE/100*7, font) local nickHeight = dxGetFontHeight( textscale*NAMETAG_TEXTSIZE/100*6.5, font) local offset = (scale) * NAMETAG_TEXT_BAR_SPACE/2 local offset2 = (scale) * 0 local offset3 = (scale) * 1.8 local rank = getElementData(player, "race rank")..""..getPrefix(getElementData(player, "race rank")) local flag = ":admin/client/images/flags/" .. (getElementData(player, "countryid") or "gtasa") .. ".png" local FLAG_SIZE_X = 13 local FLAG_SIZE_Y = 9 local flagLength = textscale*FLAG_SIZE_X local flagHeight = textscale*FLAG_SIZE_Y local rankLength = dxGetTextWidth( rank, textscale*NAMETAG_TEXTSIZE/100*7, font) -- Edit #1 Colour nicknames if not bOnlyHealthBar then if not enableCustomNametags then dxDrawText(getPlayerNameColored(player), sx, sy - offset, sx, sy - offset, tocolor(r,g,b,textalpha), textscale*NAMETAG_TEXTSIZE, "default", "center", "bottom", false, false, false, true) elseif enableCustomNametags then dxDrawText(rank, sx-(nickLength/2)-rankLength-offset3+1, sy - offset+1, sx+1, sy - offset-4, tocolor(0, 0, 0, textalpha), textscale*NAMETAG_TEXTSIZE/100*7, font, "left", "bottom", false, false, false) dxDrawText(getPlayerNameColored(player):gsub( '#%x%x%x%x%x%x', '' ), sx+1, sy-offset+1, sx+1, sy-offset-4, tocolor(0, 0, 0, textalpha), textscale*NAMETAG_TEXTSIZE/100*7, font, "center", "bottom", false, false, false, true, true) dxDrawText(rank, sx-(nickLength/2)-rankLength-offset3, sy - offset, sx, sy - offset-5, tocolor(0, 255, 255, textalpha), textscale*NAMETAG_TEXTSIZE/100*7, font, "left", "bottom", false, false, false) dxDrawText(getPlayerNameColored(player), sx, sy-offset, sx, sy-offset-5, tocolor(255, 255, 255, textalpha), textscale*NAMETAG_TEXTSIZE/100*7, font, "center", "bottom", false, false, false, true, true) dxDrawImage(sx+(nickLength/2)+offset3, (sy-offset)-(nickHeight+offset2), flagLength, flagHeight, flag) end end
  12. Corrupted map then. Download another one from google and try again. PS: I'm not familiar with other gamemodes than race so i just assumed it's same way.
  13. So it's a map for another gamemode.
  14. type /refresh all in F8 in game. Then open admin panel with P, go to Maps tab and click Refresh at bottom. Now search for your map.
  15. You need the meta.xml as well. You can't just put .map files and want them to work You need to create the map in the Map Editor or download a full map (with all of the files) from the internet.
  16. No, all maps get loaded automatically, no need to add maps to mtaserver.conf. You add just scripts to that file if you want them to auto-start with your server. About maps, download a race map from the internet and you'll see what they have Yes, the most basic maps have a meta.xml, name.map and some editor .lua files. Some info : https://wiki.multitheftauto.com/wiki/Resource:Race
  17. Hello, you can put all of your maps in the "C:\MTA Server\mods\deathmatch\resources" directory. But I advice you to create another folder inside the "deathmatch" one called "[maps]" and put all of your maps there, it's more organized And remember, you can have as many folders as you want inside the "deathmatch" one as long as they have those brackets []. If they have brackets you can put other normal folders inside of them and for MTA it's no difference, but for people it's more clear and easy to find where things are. Here's my server for example: As you see I have a seperate folder for all of my scripts and a seperate one for all of my maps. Inside those there are the actual script or map folders
  18. Here are two screenshots showing what the problem is: This is how it looks when I am spectating somebody : And this is how it looks when a player goes far away from me : Notice how in the second picture the flag is just floating somewhere near the player? That's my problem. How to make it attached to the rank and nickname text so that it always looks like on the first picture (both while spectating and while the player goes far away from me)?
  19. Hey guys, I added player rank and flag in nametags.lua and it works except one annoying part. The flag image does not go along with the text of the nametag. What I mean is that when a player goes far away from you his nametag changes it's size and position. Well the flag doesn't and is left floating in air somewhere next to the player (which looks ugly). My question is, how to make the flag move in the same places as the text so they look like one thing, not seperate drawings. --Draw our text local nickLength = dxGetTextWidth( getPlayerName(player):gsub( '#%x%x%x%x%x%x', '' ), textscale*NAMETAG_TEXTSIZE/100*7, font) local nickHeight = dxGetFontHeight( textscale*NAMETAG_TEXTSIZE/100*6.5, font) local offset = (scale) * NAMETAG_TEXT_BAR_SPACE/2 local offset2 = (scale) * 0 local offset3 = (scale) * 3 local rank = getElementData(player, "race rank")..""..getPrefix(getElementData(player, "race rank")) local flag = ":admin/client/images/flags/" .. (getElementData(player, "countryid") or "gtasa") .. ".png" local FLAG_SIZE_X = 13 local FLAG_SIZE_Y = 9 local flagLength = textscale*FLAG_SIZE_X local flagHeight = textscale*FLAG_SIZE_Y local rankLength = dxGetTextWidth( rank, textscale*NAMETAG_TEXTSIZE/100*7, font) -- Edit #1 Colour nicknames if not bOnlyHealthBar then if not enableCustomNametags then dxDrawText(getPlayerNameColored(player), sx, sy - offset, sx, sy - offset, tocolor(r,g,b,textalpha), textscale*NAMETAG_TEXTSIZE, "default", "center", "bottom", false, false, false, true) elseif enableCustomNametags then dxDrawText(rank.." "..getPlayerNameColored(player):gsub( '#%x%x%x%x%x%x', '' ), sx-69, sy-offset+1, sx+1, sy-offset-4, tocolor(0, 0, 0, textalpha), textscale*NAMETAG_TEXTSIZE/100*7, font, "center", "bottom", false, false, false, true, true) dxDrawText("#00FFFF"..rank.." "..getPlayerNameColored(player), sx-70, sy-offset, sx, sy-offset-5, tocolor(255, 255, 255, textalpha), textscale*NAMETAG_TEXTSIZE/100*7, font, "center", "bottom", false, false, false, true, true) dxDrawImage(sx+(nickLength/2)+offset3, (sy-offset)-(nickHeight+offset2), flagLength, flagHeight, flag) end end
  20. Hey, the "destroyElement" destroys elements, and you're trying to destroy ElementData. Check this example taken from the wiki: for i,v in ipairs(vehicles) do -- if the vehicle's ID is the one provided, destroy it if (getElementModel(v) == modelID) then destroyElement(v) end end In the above case the function "destroyElement" destroys the vehicle. It can also be used to destroy other elements but "ElementData" is not an element. If you want to remove it, you can use something like: if getElementData(source, "playerCol") then setElementData(source, "playerCol", nil) end And about the getPlayerName, please post the full script so I can see what's wrong (killer can be undefined)
  21. Until the start of 2016 i didn't really notice how much work is being put into making and managing this game and community. Since i started to work seriously on my server months ago i saw that every little thing needs to be fixed and thought about if you wanna have an amazing experience. What you guys are doing is not only hard but time consuming as well. And considering that you do this in your free time I've nothing else to say except to thank all of you for your dedication to the players and the game even so many years after the official release of San Andreas. Happy holidays and good luck on work on the next version.
  22. Thanks But any idea why it doesn't add the categories in the order in which they are written in the script? Like, first all Bulgarian, then all Russian radios etc.
  23. Hello, since all of the good online radio resources on community are compiled () I decided to create my own. I know it's not done in the best way but it's ok for me. The thing I need help with is the search bar at the top. I want when the user starts typing a radio name, all radios with the typed part in their name to show up in the list. And when the user clears the search bar (erases all the text) all radios would show up (just like before he started to search). Thanks if anyone helps with this Happy holidays! --https://community.multitheftauto.com/index.php?p=resources&s=details&id=13662 Sound Bars local visible = false local stream = false local availableRadios = false local search = false local sound = false local ls, rs = false local x, y = guiGetScreenSize() local sx, sy = x/1440, y/900 local faded = true ------------------------------------------------------------------------------------------------------------------------- BG = { [1] = "Radio Fresh", [2] = "Radio The Voice", [3] = "Radio City", [4] = "Radio FM+", [5] = "Radio N-Joy", [6] = "Radio Melody", [7] = "Radio NRJ", [8] = "Radio Star FM", [9] = "Z-Rock Radio", [10] = "BG Radio", [11] = "Darik Radio", [12] = "Radio Focus", [13] = "Radio Magic FM", [14] = "Radio Jazz FM", [15] = "Radio BNR Horizont", } ------------------------------------------------------------------------------------------------------------------------- RU = { [1] = "Radio Europa Plus", [2] = "Radio Record", [3] = "Trancemission", [4] = "Record EDM", [5] = "Pirate Station", [6] = "VIP House", [7] = "Record Hardstyle", [8] = "Record Dancecore", [9] = "Record Breaks", [10] = "Record Chill-Out", [11] = "Record Dubstep", [12] = "Super Disco 90-х", [13] = "Radio Pump", [14] = "Radio Medliak FM", [15] = "Radio Gop FM", [16] = "Radio Russian Mix", [17] = "Radio Yo! FM", } ------------------------------------------------------------------------------------------------------------------------- CZ = { [1] = "Radio Evropa 2", } ------------------------------------------------------------------------------------------------------------------------- SK = { [1] = "Radio Expres", } ------------------------------------------------------------------------------------------------------------------------- PL = { [1] = "Radio Party", } ------------------------------------------------------------------------------------------------------------------------- function createGUI() local radioname = false local radiolocation = false radioPanel = guiCreateWindow(0, 300, 345, 410, "Online Radio (R)", false) availableRadios = guiCreateGridList(20, 50, 300, 300, false, radioPanel) guiGridListSetSortingEnabled(availableRadios, false) local column1 = guiGridListAddColumn(availableRadios, "Radio name:", 0.6) local column2 = guiGridListAddColumn(availableRadios, "Radio location:", 0.3) local playbtn = guiCreateButton(19, 355, 150, 50, "Play Radio", false, radioPanel) local stopbtn = guiCreateButton(171, 355, 150, 50, "Stop Radio", false, radioPanel) search = guiCreateEdit(22, 21, 299, 26, "", false, radioPanel) for id = 1, #BG do local radio = BG[id] local row = guiGridListAddRow(availableRadios) guiGridListSetItemText(availableRadios, row, column1, radio, false, false) guiGridListSetItemText(availableRadios, row, column2, "Bulgaria", false, false) end local row = guiGridListAddRow(availableRadios) guiGridListSetItemText(availableRadios, row, column1, "", false, false) guiGridListSetItemText(availableRadios, row, column2, "", false, false) for id = 1, #RU do local radio = RU[id] local row = guiGridListAddRow(availableRadios) guiGridListSetItemText(availableRadios, row, column1, radio, false, false) guiGridListSetItemText(availableRadios, row, column2, "Russia", false, false) end local row = guiGridListAddRow(availableRadios) guiGridListSetItemText(availableRadios, row, column1, "", false, false) guiGridListSetItemText(availableRadios, row, column2, "", false, false) for id = 1, #CZ do local radio = CZ[id] local row = guiGridListAddRow(availableRadios) guiGridListSetItemText(availableRadios, row, column1, radio, false, false) guiGridListSetItemText(availableRadios, row, column2, "Czech Republic", false, false) end local row = guiGridListAddRow(availableRadios) guiGridListSetItemText(availableRadios, row, column1, "", false, false) guiGridListSetItemText(availableRadios, row, column2, "", false, false) for id = 1, #SK do local radio = SK[id] local row = guiGridListAddRow(availableRadios) guiGridListSetItemText(availableRadios, row, column1, radio, false, false) guiGridListSetItemText(availableRadios, row, column2, "Slovakia", false, false) end local row = guiGridListAddRow(availableRadios) guiGridListSetItemText(availableRadios, row, column1, "", false, false) guiGridListSetItemText(availableRadios, row, column2, "", false, false) for id = 1, #PL do local radio = PL[id] local row = guiGridListAddRow(availableRadios) guiGridListSetItemText(availableRadios, row, column1, radio, false, false) guiGridListSetItemText(availableRadios, row, column2, "Poland", false, false) end guiSetVisible(radioPanel, visible) addEventHandler("onClientGUIClick", stopbtn, radioList, false) addEventHandler("onClientGUIClick", playbtn, radioList, false) addEventHandler("onClientGUIDoubleClick", availableRadios, radioList, false) addEventHandler("onClientGUIClick", stopbtn, stopRadio, false) addEventHandler("onClientGUIClick", playbtn, playRadio, false) addEventHandler("onClientGUIDoubleClick", availableRadios, playRadio, false) if isEventHandlerAdded("onClientRender", root, drawNoSoundText) == false then addEventHandler("onClientRender", root, drawNoSoundText) end end addEventHandler("onClientResourceStart", resourceRoot, createGUI) ------------------------------------------------------------------------------------------------------------------------- function stopRadio() if sound then stopSound(sound) sound = nil end removeEventHandler("onClientRender", root, drawSoundBars) removeEventHandler("onClientRender", root, drawRadioName) if isEventHandlerAdded("onClientRender", root, drawNoSoundText) == false then addEventHandler("onClientRender", root, drawNoSoundText) end end ------------------------------------------------------------------------------------------------------------------------- function playRadio() if sound then stopSound(sound) sound = nil end sound = playSound(stream) setSoundVolume(sound, 0.5) removeEventHandler("onClientRender", root, drawNoSoundText) if isEventHandlerAdded("onClientRender", root, drawSoundBars) == false then addEventHandler("onClientRender", root, drawSoundBars) end if isEventHandlerAdded("onClientRender", root, drawRadioName) == false then addEventHandler("onClientRender", root, drawRadioName) end end ------------------------------------------------------------------------------------------------------------------------- function openRadioGUI() if (guiGetVisible(radioPanel) == false) then guiSetVisible(radioPanel, true) showCursor(true) else guiSetVisible(radioPanel, false) showCursor(false) end end bindKey( "R", "down", openRadioGUI) ------------------------------------------------------------------------------------------------------------------------- function isEventHandlerAdded(sEventName, pElementAttachedTo, func) if type(sEventName) == 'string' and isElement(pElementAttachedTo) and type(func) == 'function' then local aAttachedFunctions = getEventHandlers(sEventName, pElementAttachedTo) if type(aAttachedFunctions) == 'table' and #aAttachedFunctions > 0 then for i, v in ipairs(aAttachedFunctions) do if v == func then return true end end end end return false end ------------------------------------------------------------------------------------------------------------------------- function drawRadioName() local radioName = guiGridListGetItemText(availableRadios, guiGridListGetSelectedItem(availableRadios), 1) if not faded then return end if isPlayerMapVisible() then return end dxDrawText(radioName, x*0.01302083+1, y*0.9713+1, x*0.2546875+1, y*1+1, tocolor(0, 0, 0, 255), 0.9*sy, "bankgothic", "center", "center", false, false, false, false, false) dxDrawText(radioName, x*0.01302083, y*0.9713, x*0.2546875, y*1, tocolor(255, 255, 255, 255), 0.9*sy, "bankgothic", "center", "center", false, false, false, false, false) end ------------------------------------------------------------------------------------------------------------------------- function drawNoSoundText() if not faded then return end if isPlayerMapVisible() then return end dxDrawText("Radio Off", x*0.01302083+1, y*0.9713+1, x*0.2546875+1, y*1+1, tocolor(0, 0, 0, 255), 0.9*sy, "bankgothic", "center", "center", false, false, false, false, false) dxDrawText("Radio Off", x*0.01302083, y*0.9713, x*0.2546875, y*1, tocolor(255, 255, 255, 255), 0.9*sy, "bankgothic", "center", "center", false, false, false, false, false) end ------------------------------------------------------------------------------------------------------------------------- function drawSoundBars() if sound then ls, rs = getSoundLevelData(sound) end if (ls ~= false) then if not faded then return end if isPlayerMapVisible() then return end dxDrawRectangle(x*0, y*1, x*0.004583, y*0.11852*(ls/-230768), tocolor(0, 128, 255, 255)) dxDrawRectangle(x*0.00583, y*1, x*0.004583, y*0.11852*(ls/-150768), tocolor(0, 128, 255, 255)) dxDrawRectangle(x*0.01167, y*1, x*0.004583, y*0.11852*(ls/-190768), tocolor(0, 128, 255, 255)) dxDrawRectangle(x*0.0175, y*1, x*0.004583, y*0.11852*(ls/-90768), tocolor(0, 128, 255, 255)) dxDrawRectangle(x*0.023, y*1, x*0.004583, y*0.11852*(ls/-120768), tocolor(0, 128, 255, 255)) dxDrawRectangle(x*0.029167, y*1, x*0.004583, y*0.11852*(ls/-60768), tocolor(0, 128, 255, 255)) dxDrawRectangle(x*0.035, y*1, x*0.004583, y*0.11852*(ls/-90768), tocolor(0, 128, 255, 255)) dxDrawRectangle(x*0.04083, y*1, x*0.004583, y*0.11852*(rs/-75768), tocolor(0, 128, 255, 255)) dxDrawRectangle(x*0.0471875, y*1, x*0.004583, y*0.11852*(ls/-132571), tocolor(0, 128, 255, 255)) dxDrawRectangle(x*0.0525, y*1, x*0.004583, y*0.11852*(ls/-182571), tocolor(0, 128, 255, 255)) end end ------------------------------------------------------------------------------------------------------------------------- addEventHandler('onClientScreenFadedIn', root, function() faded = true end) addEventHandler('onClientScreenFadedOut', root, function() faded = false end) ------------------------------------------------------------------------------------------------------------------------- function radioList() local row, col = guiGridListGetSelectedItem(availableRadios) --Bulgarian Radios if guiGridListGetItemText(availableRadios, row, col) == "Radio Fresh" then stream = "http://193.108.24.21:8000/fresh_low" elseif guiGridListGetItemText(availableRadios, row, col) == "Radio The Voice" then stream = "http://31.13.223.148:8000/thevoice.mp3" elseif guiGridListGetItemText(availableRadios, row, col) == "Radio City" then stream = "http://149.13.0.81:80/city64" elseif guiGridListGetItemText(availableRadios, row, col) == "Radio FM+" then stream = "http://193.108.24.21:8000/fmplus" elseif guiGridListGetItemText(availableRadios, row, col) == "Radio N-Joy" then stream = "http://live.btvradio.bg/njoy.mp3" elseif guiGridListGetItemText(availableRadios, row, col) == "Radio Melody" then stream = "http://live.btvradio.bg/melody.mp3" elseif guiGridListGetItemText(availableRadios, row, col) == "Radio NRJ" then stream = "http://149.13.0.81:80/nrj128" elseif guiGridListGetItemText(availableRadios, row, col) == "Radio Star FM" then stream = "http://pulsar.atlantis.bg:8000/starfm.m3u" elseif guiGridListGetItemText(availableRadios, row, col) == "Z-Rock Radio" then stream = "http://live.btvradio.bg/z-rock.mp3" elseif guiGridListGetItemText(availableRadios, row, col) == "BG Radio" then stream = "http://149.13.0.81:80/bgradio128" elseif guiGridListGetItemText(availableRadios, row, col) == "Darik Radio" then stream = "http://darikradio.by.host.bg:8000/S2-128.m3u" elseif guiGridListGetItemText(availableRadios, row, col) == "Radio Focus" then stream = "http://online.focus-radio.net:8100/sofia" elseif guiGridListGetItemText(availableRadios, row, col) == "Radio Magic FM" then stream = "http://31.13.223.148:8000/magicfm.mp3" elseif guiGridListGetItemText(availableRadios, row, col) == "Radio Jazz FM" then stream = "http://46.10.150.123:80/jazz-fm.mp3" elseif guiGridListGetItemText(availableRadios, row, col) == "Radio BNR Horizont" then stream = "http://stream.bnr.bg:8002/horizont.mp3" end --Russian Radios if guiGridListGetItemText(availableRadios, row, col) == "Radio Europa Plus" then stream = "http://ep128server.streamr.ru:8030/ep128" elseif guiGridListGetItemText(availableRadios, row, col) == "Radio Record" then stream = "http://air.radiorecord.ru:8101/rr_128" elseif guiGridListGetItemText(availableRadios, row, col) == "Trancemission" then stream = "http://air.radiorecord.ru:8102/tm_128" elseif guiGridListGetItemText(availableRadios, row, col) == "Record EDM" then stream = "http://air.radiorecord.ru:8102/club_128" elseif guiGridListGetItemText(availableRadios, row, col) == "Pirate Station" then stream = "http://air.radiorecord.ru:8102/ps_128" elseif guiGridListGetItemText(availableRadios, row, col) == "VIP House" then stream = "http://air.radiorecord.ru:8102/vip_128" elseif guiGridListGetItemText(availableRadios, row, col) == "Record Hardstyle" then stream = "http://air.radiorecord.ru:8102/teo_128" elseif guiGridListGetItemText(availableRadios, row, col) == "Record Dancecore" then stream = "http://air.radiorecord.ru:8102/dc_128" elseif guiGridListGetItemText(availableRadios, row, col) == "Record Breaks" then stream = "http://air.radiorecord.ru:8102/brks_128" elseif guiGridListGetItemText(availableRadios, row, col) == "Record Chill-Out" then stream = "http://air.radiorecord.ru:8102/chil_128" elseif guiGridListGetItemText(availableRadios, row, col) == "Record Dubstep" then stream = "http://air.radiorecord.ru:8102/dub_128" elseif guiGridListGetItemText(availableRadios, row, col) == "Super Disco 90-х" then stream = "http://air.radiorecord.ru:8102/sd90_128" elseif guiGridListGetItemText(availableRadios, row, col) == "Radio Pump" then stream = "http://air.radiorecord.ru:8102/pump_128" elseif guiGridListGetItemText(availableRadios, row, col) == "Radio Medliak FM" then stream = "http://air.radiorecord.ru:8102/mdl_128" elseif guiGridListGetItemText(availableRadios, row, col) == "Radio Gop FM" then stream = "http://air.radiorecord.ru:8102/gop_128" elseif guiGridListGetItemText(availableRadios, row, col) == "Radio Russian Mix" then stream = "http://air.radiorecord.ru:8102/rus_128" elseif guiGridListGetItemText(availableRadios, row, col) == "Radio Yo! FM" then stream = "http://air.radiorecord.ru:8102/yo_128" end --Czech Radios if guiGridListGetItemText(availableRadios, row, col) == "Radio Evropa 2" then stream = "http://icecast4.play.cz:80/evropa2-64.mp3" end --Slovak Radios if guiGridListGetItemText(availableRadios, row, col) == "Radio Expres" then stream = "http://85.248.7.162:8000/64.mp3" end --Polish Radios if guiGridListGetItemText(availableRadios, row, col) == "Radio Party" then stream = "http://s3.radioparty.pl:8000/rp.mp3" end end
×
×
  • Create New...