Jump to content

koragg

Members
  • Posts

    730
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by koragg

  1. I get what you mean but I can't seem to do it with my script. I tried moving the value of the last number (600 in your example) but then text position moves so I have to edit the second number's value (300 in your example's case) and at the end it still looks same as in my first post.
  2. Hello people, I've got a small bug with a dxdrawing. Check the things above radar in the following picture: The date and time are fine but the day name should be right ontop of the time drawing (not so high above it). This is how it looks on 1440x900^ and here's how it looks on 1920x1080 (and how it should look on all widely used resolutions --> Here's the code, hope somebody can help out with positioning this thing the way it is on the second screenshot for any (or close to any) resolution. Client script below: local sx_, sy_ = guiGetScreenSize ( ) local sx, sy = sx_/1440, sy_/900 local visible = true function drawdatetime() local hours = getRealTime().hour local minutes = getRealTime().minute local seconds = getRealTime().second local datestring = FormatDate("d/m/Y") local daystring = FormatDate("W") if visible then if seconds <= 9 then seconds = "0"..seconds end if minutes <= 9 then minutes = "0"..minutes end if hours <= 9 then hours = "0"..hours end dxSetAspectRatioAdjustmentEnabled(true, 4/3) dxDrawText(hours..":"..minutes..":"..seconds, 140*sx, 648*sy, 0*sx, 0*sy, tocolor(255,255,0,255), 0.8*sy,"bankgothic") dxDrawText(datestring, 142*sx, 665*sy, 0*sx, 0*sy, tocolor(255,255,0,255), 0.6*sy,"bankgothic") dxDrawText(daystring, -650*sx - 1, 1038*sy - 1, 1044*sx - 1, 25*sy - 1, tocolor(255,255,0,255), 0.6*sy, "bankgothic", "center", "center", false, false, false, false, false) end end addEventHandler("onClientRender",root,drawdatetime) function showtimedate() visible = true end function hidetimedate() if visible then visible = false end end --Edited by AleksCore & MegasXLR function Check(funcname, ...) local arg = {...} if (type(funcname) ~= "string") then error("Argument type mismatch at 'Check' ('funcname'). Expected 'string', got '"..type(funcname).."'.", 2) end if (#arg % 3 > 0) then error("Argument number mismatch at 'Check'. Expected #arg % 3 to be 0, but it is "..(#arg % 3)..".", 2) end for i=1, #arg-2, 3 do if (type(arg[i]) ~= "string" and type(arg[i]) ~= "table") then error("Argument type mismatch at 'Check' (arg #"..i.."). Expected 'string' or 'table', got '"..type(arg[i]).."'.", 2) elseif (type(arg[i+2]) ~= "string") then error("Argument type mismatch at 'Check' (arg #"..(i+2).."). Expected 'string', got '"..type(arg[i+2]).."'.", 2) end if (type(arg[i]) == "table") then local aType = type(arg[i+1]) for _, pType in next, arg[i] do if (aType == pType) then aType = nil break end end if (aType) then error("Argument type mismatch at '"..funcname.."' ('"..arg[i+2].."'). Expected '"..table.concat(arg[i], "' or '").."', got '"..aType.."'.", 3) end elseif (type(arg[i+1]) ~= arg[i]) then error("Argument type mismatch at '"..funcname.."' ('"..arg[i+2].."'). Expected '"..arg[i].."', got '"..type(arg[i+1]).."'.", 3) end end end local gWeekDays = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" } function FormatDate(format, escaper, timestamp) Check("FormatDate", "string", format, "format", {"nil","string"}, escaper, "escaper", {"nil","string"}, timestamp, "timestamp") escaper = (escaper or "'"):sub(1, 1) local time = getRealTime(timestamp) local formattedDate = "" local escaped = false time.year = time.year + 1900 time.month = time.month + 1 local datetime = { d = ("%02d"):format(time.monthday), h = ("%02d"):format(time.hour), i = ("%02d"):format(time.minute), m = ("%02d"):format(time.month), s = ("%02d"):format(time.second), w = gWeekDays[time.weekday+1]:sub(1, 2), W = gWeekDays[time.weekday+1], y = tostring(time.year):sub(-2), Y = time.year } for char in format:gmatch(".") do if (char == escaper) then escaped = not escaped else formattedDate = formattedDate..(not escaped and datetime[char] or char) end end return formattedDate end
  3. No need to create the same topic over and over again. If somebody knows a solution, they'll try to help you.
  4. If so, I'd be happy to see an example as I myself have a few dxdrawings that should look nice on pretty much any resolution but on some unknown resolutions they just look horrible.
  5. I don't know which kind you're looking for, ped spawn changer or for race servers? If it's for race, here is the one I use : http://www.mediafire.com/file/cw6rpvy6cdh924w/buyspawn.lua (If this is what you're looking for, let me know and I'll help make it work for you).
  6. wow I don't think anyone will reply to this topic so... First of all that's not a script, it's a build-in feature in MTA. You need to be registered and logged in as admin to access it. Once you're admin, write in chat "/debugscript 3" and that same window will show displaying all errors/warnings (if any) of all running resources on the server. To get rid of it type "/debugscript 0" in chat. https://wiki.multitheftauto.com/wiki/Debugging
  7. Yes, I also always change font scale same way as he did but some things just can't get fixed for every resolution, which you gotta just live with I guess
  8. FIXED Thanks to @dugasz1 @xiti and @lukum! Working code below if anyone's interested. Client drawNextText = '' _nextWidth = 0 _nextHeight = 0 local g__sW, g__sH = guiGetScreenSize() local sx, sy = g__sW/1440, g__sH/900 local visible = true function getinfo(name, oldvalue) if source == getResourceRootElement() and name == 'gamemode.nextmap' then local what = getElementData(getResourceRootElement(), 'gamemode.nextmap') drawNextText = what _nextWidth = dxGetTextWidth(what, 0.45, 'bankgothic') _nextHeight = dxGetFontHeight(0.45, 'bankgothic') * 3 end end addEventHandler('onClientElementDataChange', root, getinfo) function drawinfo() if _nextWidth == 0 then return end if visible then dxDrawRectangle((g__sW-95)-(_nextWidth+20), 12*sy, _nextWidth+20, _nextHeight+10, tocolor(0,0,0,100),false) dxDrawText(drawNextText, (g__sW-95)-(_nextWidth+20)+5, 12*sy, (g__sW-100)-(_nextWidth+20)+_nextWidth+15, 5+_nextHeight+17, tocolor(254, 254, 34, 255), 0.45, 'bankgothic', 'center', 'center', true) end end addEventHandler("onClientRender",root, drawinfo) function shownextmap() visible = true end function hidenextmap() if visible then visible = false end end Server addEvent('onNextmapSettingChange', true) function nmap(nmap) local mapName = getResourceInfo(nmap, "name") or getResourceName(nmap) local rating = exports.mapratings:getMapRating(getResourceName(nmap)) local average = 0 if rating then average = tonumber(rating.average) or "0" end local stringSet = "Next map: "..mapName.." ("..tostring(average).."/10)" nextmap = stringSet map = exports.mapmanager:getRunningGamemodeMap() if map then local mapName = getResourceInfo(map, "name") or getResourceName(map) local rating = exports.mapratings:getMapRating(getResourceName(map)) local average = 0 if rating then average = tonumber(rating.average) or "0" end stringSet = "Current map: ".. mapName.." ("..tostring(average).."/10)\n"..stringSet end setElementData(resourceRoot, 'gamemode.nextmap', stringSet) end addEventHandler('onNextmapSettingChange', root, nmap) function safeString(s) s = string.gsub(s, '&', '&amp;') s = string.gsub(s, '"', '&quot;') s = string.gsub(s, '<', '&lt;') s = string.gsub(s, '>', '&gt;') return s:gsub( "(['])", "''" ) end meta.xml <meta> <info name="Current/Next Map Info" description="Map Names Info" author="SDK/BinSlayer" type="script" version="1.0"/> <script src="server.lua" type="server"/> <script src="client.lua" type="client"/> <export function="shownextmap" type="client"/> <export function="hidenextmap" type="client"/> </meta> PS Not sure if it can work on default race.zip but won't hurt to try. Lock the topic, problem fixed.
  9. I put outputChatBoxes after each line and problem appears to be in lines: 5,6,14,15.
  10. This can be useful as well, for further formatting : https://wiki.multitheftauto.com/wiki/FormatDate
  11. Getting dxtext to be PERFECT for ALL resolutions is hard. I'd advise you to make it look as you want it to on the most widely used ones and try making it look 'good' on lower resolutions (so that those guys can still get the idea although not as perfect as the other resolutions). Like, who uses 800x600
  12. Here's my car replace script, just replace the car ID and file names. client.lua function CarModel() txd = engineLoadTXD ( "BMW.txd" ) engineImportTXD ( txd, 451 ) dff = engineLoadDFF ( "BMW.dff", 451 ) engineReplaceModel ( dff, 451 ) end addEventHandler('onClientResourceStart', resourceRoot, CarModel) addCommandHandler ( 'reloadcar', CarModel ) function Timer() setTimer(CarModel, 500, 1) end addEventHandler('onClientResourceStart', resourceRoot, Timer) meta.xml <meta> <file src="BMW.txd" /> <file src="BMW.dff" /> <script src="BMW.lua" type="client" /> </meta>
  13. Hello, I'm trying to add average map rating into a dxdraw window but I have trouble doing so. If anybody can help, would be great. Here's the code: Client drawNextText = '' _nextWidth = 0 _nextHeight = 0 local g__sW, g__sH = guiGetScreenSize() local sx, sy = g__sW/1440, g__sH/900 local visible = true function getinfo(name, oldvalue) if source == getResourceRootElement() and name == 'gamemode.nextmap' then local what = getElementData(getResourceRootElement(), 'gamemode.nextmap') drawNextText = what _nextWidth = dxGetTextWidth(what, 0.45, 'bankgothic') _nextHeight = dxGetFontHeight(0.45, 'bankgothic') * 3 end end addEventHandler('onClientElementDataChange', root, getinfo) function drawinfo() if _nextWidth == 0 then return end if visible then dxDrawRectangle((g__sW-95)-(_nextWidth+20), 12*sy, _nextWidth+20, _nextHeight+10, tocolor(0,0,0,100),false) dxDrawText(drawNextText, (g__sW-95)-(_nextWidth+20)+5, 12*sy, (g__sW-100)-(_nextWidth+20)+_nextWidth+15, 5+_nextHeight+17, tocolor(254, 254, 34, 255), 0.45, 'bankgothic', 'center', 'center', true) end end addEventHandler("onClientRender",root, drawinfo) function shownextmap() visible = true end function hidenextmap() if visible then visible = false end end Server addEvent('onNextmapSettingChange', true) function nmap(nmap) local mapName = getResourceInfo(nmap, "name") or getResourceName(nmap) local rating = exports.mapratings:getMapRating(mapName) if rating then local average = tonumber(rating.average) or "0" end local stringSet = "Next map: "..mapName.." ("..tostring(average).."/10)" nextmap = stringSet map = exports.mapmanager:getRunningGamemodeMap() if map then local mapName = getResourceInfo(map, "name") or getResourceName(map) local rating = exports.mapratings:getMapRating(mapName) if rating then local average = tonumber(rating.average) or "0" end stringSet = "Current map: ".. mapName.." ("..tostring(average).."/10)\n"..stringSet end setElementData(resourceRoot, 'gamemode.nextmap', stringSet) end addEventHandler('onNextmapSettingChange', root, nmap) And here's a screenshot showing what I want to achieve As you see, the "Next Map" window at top right shows "(nil/10) as map rating. I can't get it to show the actual average rating of the maps there (or if map has no rating yet, to show 0/10).
  14. Hello, I read somewhere that I have to post link to my resource which I want deleted here as I couldn't find a delete option in my profile. Please delete this one : https://community.multitheftauto.com/in ... s&id=13460 That was my first resource upload ever so I wasn't quite familiar that I can' change the name shown to something other than the .zip file name, won't happen again. Thanks! DONE
  15. Hello everyone, so I downloaded this resource : https://community.multitheftauto.com/in ... s&id=12294 and wanted to edit it so that the player receives coins for doing WinStreaks as well. I did the following (in rank.lua file) and it does show client msg in chatbox and everything but it does not give any coins at all. Please, I wasted a lot of time on this, trying different things but in the end coins weren't given to me for doing a WinStreak (despite messages showing correct ammount in chat). addEvent("onPlayerRaceWinStreak") function winstreak(playerName) local playerName = getPlayerName(source) local playerNamenick = string.gsub(playerName, "#%x%x%x%x%x%x", "") local accountid = getAccountName(getPlayerAccount(source)) local players = getElementsByType("player") local serial = getPlayerSerial(source) local uyelik = getPlayerAccount(source) local statlar = executeSQLQuery("SELECT * FROM Scores WHERE AccountId = ? AND PlayerName = ?", accountid, playerName) local coins = 0 if not PlayerData[playerName] then ResetPlayerData(source) end local minPlayers = 1 or 0 if #players < minPlayers then PlayerData[playerName].Streaks = 0 return end local wins = PlayerData[playerName].Streaks or 0 wins = wins + 1 local playernames = getPlayerName(source) if wins == 2 then --kazanmasesleri("data/sounds/kidLaugh.wav") --outputChatBox(""..playerNamenick.." has done a WinStreak of "..wins.."!", getRootElement(), 0,255,255) coins = 3 exports.messages:outputGameMessage(""..playerNamenick.." earned "..coins.." KnightCoins for his WinStreak of "..wins.."", getRootElement(), 2, 255, 0, 0) local mesaj = "You earned "..coins.." KnightCoins for your WinStreak of "..wins.."!" triggerClientEvent(source ,"serverMEsajlarAl", source, mesaj) points = tonumber(statlar[1]["Points"]) cash = tonumber(statlar[1]["Cash"]) + coins toptimes = tonumber(statlar[1]["TopTimes"]) executeSQLQuery("UPDATE Scores SET Points = ?, Cash = ?, TopTimes = ? WHERE AccountId = '"..accountid.."' AND PlayerName = '"..playerName.."'", points, cash, toptimes) setElementData ( source ,"data.cash", cash, true) end PS: This is just one part of the code (only for WinStreak of 2) but others are the same so I don't think they're needed here. Also I don't know if this should be added to update in one of the other files of the resource as well. That's why I need someone with a bit more knowledge to try help me out
  16. If you mean the resource which displays the mapinfo, then yes. I just edited the colors. This is it btw : https://community.multitheftauto.com/in ... ls&id=7124 I did try using stock race.zip and the "TimesPlayed" did show but as I said I can't stick with default MTA race.zip as a lot of scripts require the modded one. It'd be great if someone told me what to edit and in which file to fix this as I tried original racevoting_server.lua but was still bugged.
  17. Hello everyone. I have a problem with getting the two things written in title to work and idk how to fix this. I tried different resources and the problem isn't in them, it's in my race.zip (tried original one and they both work). So the "TimesPlayed" always show "Unknown" and the "LastTimePlayed" displays the current date and time, not when the map was last played. Example: I start "An Xmas Present" by FloW on 16.06.2016 at 17:36 and it says that the last time this map has been played is "on 16.06.2016 at 17:36". Xiti told me that the racevoting_server.lua is responsible for this but even after I tried a default racevoting_server.lua from original MTA resources there was still same problem. I'm using the following race.zip and can't change to stock one for script compatibility reasons : https://github.com/JarnoVgr/Mr.Green-MT ... %5Brace%5D
  18. Hey guys, I am facing a very annoying problem with the IRC resource, it restarts itself each 5 mins or so for no apparent reason whatsoever. Idk how to upload pics as attachments here so please check the following topic's first 2 posts : https://mrgreengaming.com/forums/topic/ ... no-reason/ At first I had that "nick in use" problem although the nick was free. And when I tried to register it. it said that it's already registered (ik it is, by me), but when I tried to unregister it, it said it's not registered at all That^ was fixed somehow (idk how nor for how long) and then I get the thing from 2nd post, the resource restarts itself for no reason at all. I tried disabling all other resources and it still did that. PS: Some months ago I had the same bugs/problems and idk how but they just went away..until few days ago! Any help is greatly appreciated as this is driving me crazy since a few days ago
  19. At the moment I think it adds 1 point for each team when the team wins. In RaceLeague it adds for example 15 points from 1st finished player, then 13 points from 2nd finished, etc. And the score goes beyond 400 for a team sometimes. Idk if you'd like that though. But yes, forget about suggestions, first need to make old stuff working again. If you need any kind of help, just ask (altho I can't script ).
  20. Well from what I've seen it works but another player said that he has tried it and has had bugs in map switching and stuff like that. At the moment I'm using the RaceLeague resource and am ok with it...but I love yours' style :v Maybe you can also kind of make an option which doesn't just count score like on a football match, but more like the raceleague one. These are just suggestions, ignore 'em if you want PS I'd be happy to test the res if you need testing. I got a local server which is on whenever my PC is on (every day for some time ) so that's no problem for me.
  21. Hello, I want to thank you for this amazing CW resource, it's simply the best one I've ever seen. But could you please tell me how I can change the binds/scoreboard position and everything like that FOR ALL PLAYERS. Meaning that they shouldn't have to go into /settings and change "Client" stuff on their own. I need this because at the moment all my F keys are bound to other resources and I want to use the num_div and num_mul for the "Select Team" and "Management Panel"...and it works FOR ME. Others must edit their /settings in order to change what I want to be as default for everybody (again, my settings would be best as the ones which come by default overlapse with F buttons and the map timeleft box at the top. I see you've been busy lately but can you have a look at this and probably make an option which disables "Client" /settings and puts an admin's "Client" /settings as default for everyone? That's the only thing stopping me from using your amazing script. I'm really looking forward to another *small* update which contains this as I think a lot of people would want that option in. Cheers!
  22. Well I know how to edit some parameters and such stuff but I can't create .lua scripts. I was same with .cs for single player :\ I'm trying to learn it step by step but here is the code below. Maybe you can highlight the parts (or put comments) on what needs to be done to do my request. Also, can volume be changed from MTA slider to normal GTA SA Radio slider in ESC? local xml = xmlLoadFile ( "settings.xml" ) local nodeColor = xmlFindChild ( xml, "color", 0 ) local nodeFont = xmlFindChild ( xml, "font", 0 ) local nodeRealism = xmlFindChild ( xml, "realism", 0 ) local nodeStations = xmlFindChild ( xml, "stations", 0 ) local label = guiCreateLabel ( 0, 0, 1, 0.1, "Radio Off", true ) guiLabelSetColor ( label, xmlNodeGetAttribute ( nodeColor, "r" ), xmlNodeGetAttribute ( nodeColor, "g" ), xmlNodeGetAttribute ( nodeColor, "b" ) ) guiLabelSetHorizontalAlign ( label, "center" ) guiSetFont ( label, xmlNodeGetValue ( nodeFont ) ) guiSetVisible ( label, false ) addEventHandler ( "onClientResourceStart", getResourceRootElement (), function () showPlayerHudComponent ( "radio", false ) setElementData ( getLocalPlayer (), "liveradio.radio", 0 ) for k, v in ipairs ( getElementsByType ( "vehicle" ) ) do setElementData ( v, "liveradio.radio0", false ) setElementData ( v, "liveradio.radio1", false ) setElementData ( v, "liveradio.radio2", false ) setElementData ( v, "liveradio.radio3", false ) end end ) addEventHandler ( "onClientResourceStop", getResourceRootElement (), function () showPlayerHudComponent ( "radio", true ) end ) addEventHandler ( "onClientPlayerVehicleEnter", getLocalPlayer (), function ( vehicle, seat ) setRadioChannel ( 0 ) setElementData ( getLocalPlayer (), "liveradio.seat", seat ) if sound then if isElement ( sound ) then destroyElement ( sound ) end end if xmlNodeGetAttribute ( nodeRealism, "enabled" ) == "true" then if getElementData ( vehicle, "liveradio.radio0" ) then setElementData ( getLocalPlayer (), "liveradio.radio", getElementData ( vehicle, "liveradio.radio0" ) ) else for k, v in ipairs ( xmlNodeGetChildren ( nodeStations ) ) do setElementData ( getLocalPlayer (), "liveradio.radio", k ) end setElementData ( getLocalPlayer (), "liveradio.radio", math.random ( getElementData ( getLocalPlayer (), "liveradio.radio" ) ) ) setElementData ( vehicle, "liveradio.radio0", getElementData ( getLocalPlayer (), "liveradio.radio" ) ) setElementData ( vehicle, "liveradio.radio1", getElementData ( getLocalPlayer (), "liveradio.radio" ) ) setElementData ( vehicle, "liveradio.radio2", getElementData ( getLocalPlayer (), "liveradio.radio" ) ) setElementData ( vehicle, "liveradio.radio3", getElementData ( getLocalPlayer (), "liveradio.radio" ) ) end else if getElementData ( vehicle, "liveradio.radio" .. seat ) then setElementData ( getLocalPlayer (), "liveradio.radio", getElementData ( vehicle, "liveradio.radio" .. seat ) ) else for k, v in ipairs ( xmlNodeGetChildren ( nodeStations ) ) do setElementData ( getLocalPlayer (), "liveradio.radio", k ) end setElementData ( getLocalPlayer (), "liveradio.radio", math.random ( getElementData ( getLocalPlayer (), "liveradio.radio" ) ) ) setElementData ( vehicle, "liveradio.radio" .. seat, getElementData ( getLocalPlayer (), "liveradio.radio" ) ) end end local nodeStation = xmlFindChild ( nodeStations, "station", getElementData ( vehicle, "liveradio.radio" .. seat ) - 1 ) if nodeStation then local radioName = xmlNodeGetAttribute ( nodeStation, "name" ) local radioURL = xmlNodeGetAttribute ( nodeStation, "URL" ) sound = playSound ( radioURL ) guiSetText ( label, radioName ) guiSetVisible ( label, true ) if isTimer ( timerLabel ) then killTimer ( timerLabel ) end timerLabel = setTimer ( guiSetVisible, 5000, 1, label, false ) else guiSetText ( label, "Radio Off" ) guiSetVisible ( label, true ) setElementData ( getLocalPlayer (), "liveradio.radio", 0 ) if isTimer ( timerLabel ) then killTimer ( timerLabel ) end timerLabel = setTimer ( guiSetVisible, 5000, 1, label, false ) end timerVehicle = setTimer ( function ( vehicle ) if isPedInVehicle ( getLocalPlayer () ) == false or getPedOccupiedVehicle ( getLocalPlayer () ) ~= vehicle or getElementHealth ( getLocalPlayer () ) <= 0 then if sound then if isElement ( sound ) then destroyElement ( sound ) end end killTimer ( timerVehicle ) guiSetVisible ( label, false ) setElementData ( getLocalPlayer (), "liveradio.radio", 0 ) end end , 50, 0, vehicle ) end ) addEventHandler ( "onClientPlayerRadioSwitch", getLocalPlayer (), function ( station ) if station ~= 0 then cancelEvent () end if xmlNodeGetAttribute ( nodeRealism, "enabled" ) ~= "true" or getElementData ( getLocalPlayer (), "liveradio.seat" ) == 0 or getPedOccupiedVehicle ( getLocalPlayer () ) == false then if station == 1 then setElementData ( getLocalPlayer (), "liveradio.radio", getElementData ( getLocalPlayer (), "liveradio.radio" ) + 1 ) elseif station == 12 then setElementData ( getLocalPlayer (), "liveradio.radio", getElementData ( getLocalPlayer (), "liveradio.radio" ) - 1 ) if getElementData ( getLocalPlayer (), "liveradio.radio" ) == -1 then for k, v in ipairs ( xmlNodeGetChildren ( nodeStations ) ) do setElementData ( getLocalPlayer (), "liveradio.radio", k ) end end end if sound then if isElement ( sound ) then destroyElement ( sound ) end end if getPedOccupiedVehicle ( getLocalPlayer () ) then setElementData ( getPedOccupiedVehicle ( getLocalPlayer () ), "liveradio.radio" .. getElementData ( getLocalPlayer (), "liveradio.seat" ), getElementData ( getLocalPlayer (), "liveradio.radio" ) ) end local nodeStation = xmlFindChild ( nodeStations, "station", getElementData ( getLocalPlayer (), "liveradio.radio" ) - 1 ) if nodeStation then local radioName = xmlNodeGetAttribute ( nodeStation, "name" ) local radioURL = xmlNodeGetAttribute ( nodeStation, "URL" ) sound = playSound ( radioURL ) guiSetText ( label, radioName ) guiSetVisible ( label, true ) if isTimer ( timerLabel ) then killTimer ( timerLabel ) end timerLabel = setTimer ( guiSetVisible, 5000, 1, label, false ) else guiSetText ( label, "Radio Off" ) guiSetVisible ( label, true ) setElementData ( getLocalPlayer (), "liveradio.radio", 0 ) if isTimer ( timerLabel ) then killTimer ( timerLabel ) end timerLabel = setTimer ( guiSetVisible, 5000, 1, label, false ) end if xmlNodeGetAttribute ( nodeRealism, "enabled" ) == "true" and getPedOccupiedVehicle ( getLocalPlayer () ) then setElementData ( getPedOccupiedVehicle ( getLocalPlayer () ), "liveradio.radio0", getElementData ( getLocalPlayer (), "liveradio.radio" ) ) setElementData ( getPedOccupiedVehicle ( getLocalPlayer () ), "liveradio.radio1", getElementData ( getLocalPlayer (), "liveradio.radio" ) ) setElementData ( getPedOccupiedVehicle ( getLocalPlayer () ), "liveradio.radio2", getElementData ( getLocalPlayer (), "liveradio.radio" ) ) setElementData ( getPedOccupiedVehicle ( getLocalPlayer () ), "liveradio.radio3", getElementData ( getLocalPlayer (), "liveradio.radio" ) ) triggerServerEvent ( "onPlayerRadioSwitch", getLocalPlayer (), getPedOccupiedVehicle ( getLocalPlayer () ) ) end end end ) addEventHandler ( "onClientVehicleStartExit", getRootElement (), function ( player ) if player == getLocalPlayer () then if sound then if isElement ( sound ) then destroyElement ( sound ) end end if isTimer ( timerVehicle ) then killTimer ( timerVehicle ) end guiSetVisible ( label, false ) setElementData ( player, "liveradio.radio", 0 ) end end ) addEvent ( "switchRadioChannel", true ) addEventHandler ( "switchRadioChannel", getLocalPlayer (), function () if sound then if isElement ( sound ) then destroyElement ( sound ) end end local nodeStation = xmlFindChild ( nodeStations, "station", getElementData ( getPedOccupiedVehicle ( getLocalPlayer () ), "liveradio.radio0" ) - 1 ) if nodeStation then local radioName = xmlNodeGetAttribute ( nodeStation, "name" ) local radioURL = xmlNodeGetAttribute ( nodeStation, "URL" ) sound = playSound ( radioURL ) guiSetText ( label, radioName ) guiSetVisible ( label, true ) setElementData ( getLocalPlayer (), "liveradio.radio", getElementData ( getPedOccupiedVehicle ( getLocalPlayer () ), "liveradio.radio0" ) ) if isTimer ( timerLabel ) then killTimer ( timerLabel ) end timerLabel = setTimer ( guiSetVisible, 5000, 1, label, false ) else guiSetText ( label, "Radio Off" ) guiSetVisible ( label, true ) setElementData ( getLocalPlayer (), "liveradio.radio", 0 ) if isTimer ( timerLabel ) then killTimer ( timerLabel ) end timerLabel = setTimer ( guiSetVisible, 5000, 1, label, false ) end end ) Thanks for anyone who helps with this Btw this is the client.lua ^ as I think the things I need are both client sided.
×
×
  • Create New...