Jump to content

koragg

Members
  • Posts

    730
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by koragg

  1. No, look at other exports a bit up, that's the right way. Interesting suggestion with executeCommandHandler. I always thought that it's server only :) I'll give it a go soon.
  2. @LoPollo just tried with a 5 second delay, still same. And btw, those function you said to put timer on load the settings on join. My problem's that it doesn't fully unload if it has been set the last time when the player was on server and he tries to disable the gta v radar now.
  3. Well there is a 1 or 2 second delay when I join the server. It first shows the default radar and after that second it loads the new one from the user panel. Here's the full script which loads all such settings from the .xml file (See lines below so you don't look at all of them). PASTEBIN (As I don't wanna spam the topic with 1k line codes ) Lines 109-112 tell which functions the resource should use Line 157 sets the default function to be called when a new player joins (aka, still doesn't have a .xml file yet) Lines 408-418 tell what should happen when the player ticks/unticks the checkbox ( saveTime() saves this to the .xml file) Lines 745-750 tell the GUI window to update if the checkbox should be ticked or not (depending on the user's preference and what he has (dis)activated)
  4. engineRemoveShaderFromWorldTexture(shaders, blips_textures[1]) And ok, I'll try all that tomorrow, wanna race now EDIT: addEventHandler("onClientGUIClick", resourceRoot, ui_ClickHandler) is used to call the required function and addEventHandler("onClientResourceStart", resourceRoot, loadUISettings) is used when the panel loads the xml file and then execute the things
  5. Yea, those two. "radaron" is fine but as I said, I'll say again in case you didn't get it *Player joins server, opens F1 panel, checks the GTA V Radar to try it out *Player quits server *In few hours he comes back on the server, but wants to remove the GTA V Radar *Player unticks the checkbox *Minimap images unload fine, radar blip images stay the same from the GTA V Radar, although there is a line which unloads shaders in the "radaroff" function Note: If the player ticks the GTA V Radar, plays a bit, then unticks it (without disconnecting from the server), everything unloads fine. Problem's when he quits and comes back, then it doesn't unload the shaders. PS The user-panel I use saves such settings for ticked checkboxes in a xml file which it loads when the player connects again and applies the functions for the client.
  6. OK well, there is one small bug that came up after linking it to the settings panel. If a player has already set the radar to the GTA V one (the last time he was on the server) and clicks on the checkbox to untick it now, the shader images do not unload. The minimap ones revert to default gta ones but not the shaders. :\
  7. @LoPollo yes I saw that later and fixed Don't know why it said function's nil as it was there and @Wojak, yes I replaced that and worked. Then it didn't unload the minimap images when I typed "off" command (as they're not shaders, just the radar outline and blips are shaders apparently) so I had to edit a bit more. Now everything works and there's no lag, fps drop or any kind of problems. Thanks to both of you, now I can easily add a switch checkbox to my (MrGreen's) settings panel. Working code (with commands) below: local tiles = {} local timer local visible = true local ROW_COUNT = 12 --# Textures table local blips_textures = { { "arrow", "blips/arrow.png" }, { "radardisc", "blips/radardisc.png" }, { "radar_airYard", "blips/radar_airYard.png" }, { "radar_ammugun", "blips/radar_ammugun.png" }, { "radar_barbers", "blips/radar_barbers.png" }, { "radar_BIGSMOKE", "blips/radar_BIGSMOKE.png" }, { "radar_boatyard", "blips/radar_boatyard.png" }, { "radar_bulldozer", "blips/radar_bulldozer.png" }, { "radar_burgerShot", "blips/radar_burgerShot.png" }, { "radar_cash", "blips/radar_cash.png" }, { "radar_CATALINAPINK", "blips/radar_CATALINAPINK.png"}, { "radar_centre", "blips/radar_centre.png" }, { "radar_CESARVIAPANDO", "blips/radar_CESARVIAPANDO.png" }, { "radar_chicken", "blips/radar_chicken.png" }, { "radar_CJ", "blips/radar_CJ.png" }, { "radar_CRASH1", "blips/radar_CRASH1.png" }, { "radar_dateDisco", "blips/radar_dateDisco.png" }, { "radar_dateDrink", "blips/radar_dateDrink.png" }, { "radar_dateFood", "blips/radar_dateFood.png" }, { "radar_diner", "blips/radar_diner.png" }, { "radar_emmetGun", "blips/radar_emmetGun.png" }, { "radar_enemyAttack", "blips/radar_enemyAttack.png" }, { "radar_fire", "blips/radar_fire.png" }, { "radar_Flag", "blips/radar_Flag.png" }, { "radar_gangB", "blips/radar_gangB.png" }, { "radar_gangG", "blips/radar_gangG.png" }, { "radar_gangN", "blips/radar_gangN.png" }, { "radar_gangP", "blips/radar_gangP.png" }, { "radar_gangY", "blips/radar_gangY.png" }, { "radar_girlfriend", "blips/radar_girlfriend.png" }, { "radar_gym", "blips/radar_gym.png" }, { "radar_hostpital", "blips/radar_hostpital.png" }, { "radar_impound", "blips/radar_impound.png" }, { "radar_light", "blips/radar_light.png" }, { "radar_LocoSyndicate", "blips/radar_LocoSyndicate.png" }, { "radar_MADDOG", "blips/radar_MADDOG.png" }, { "radar_mafiaCasino", "blips/radar_mafiaCasino.png" }, { "radar_MCSTRAP", "blips/radar_MCSTRAP.png" }, { "radar_modGarage", "blips/radar_modGarage.png" }, { "radar_north", "blips/radar_north.png" }, { "radar_OGLOC", "blips/radar_OGLOC.png" }, { "radar_pizza", "blips/radar_pizza.png" }, { "radar_police", "blips/radar_police.png" }, { "radar_propertyG", "blips/radar_propertyG.png" }, { "radar_propertyR", "blips/radar_propertyR.png" }, { "radar_qmark", "blips/radar_qmark.png" }, { "radar_race", "blips/radar_race.png" }, { "radar_runway", "blips/radar_runway.png" }, { "radar_RYDER", "blips/radar_RYDER.png" }, { "radar_saveGame", "blips/radar_saveGame.png" }, { "radar_school", "blips/radar_school.png" }, { "radar_spray", "blips/radar_spray.png" }, { "radar_SWEET", "blips/radar_SWEET.png" }, { "radar_tattoo", "blips/radar_tattoo.png" }, { "radar_THETRUTH", "blips/radar_THETRUTH.png" }, { "radar_TORENO", "blips/radar_TORENO.png" }, { "radar_TorenoRanch", "blips/radar_TorenoRanch.png" }, { "radar_triads", "blips/radar_triads.png" }, { "radar_triadsCasino", "blips/radar_triadsCasino.png" }, { "radar_truck", "blips/radar_truck.png" }, { "radar_tshirt", "blips/radar_tshirt.png" }, { "radar_waypoint", "blips/radar_waypoint.png" }, { "radar_WOOZIE", "blips/radar_WOOZIE.png" }, { "radar_ZERO", "blips/radar_ZERO.png" }, { "siteM16", "blips/siteM16.png" }, { "siterocket", "blips/siterocket.png" } } local shaders = {} function radaron() visible = true if visible then for i = 2, #blips_textures do shaders[i] = dxCreateShader("texture.fx") engineApplyShaderToWorldTexture(shaders[i], blips_textures[i][1]) dxSetShaderValue(shaders[i], "gTexture", dxCreateTexture(blips_textures[i][2])) end handleTileLoading() if isTimer(timer) then killTimer(timer) end timer = setTimer(handleTileLoading, 500, 0) end visible = false end addCommandHandler("on", radaron) function radaroff() if visible == false then for i = 2, #blips_textures do engineRemoveShaderFromWorldTexture(shaders[i], blips_textures[i][1]) end if isTimer(timer ) then killTimer(timer) end for name, data in pairs(tiles) do unloadTile(name) end end end addCommandHandler("off", radaroff) function handleTileLoading ( ) local visibleTileNames = table.merge ( engineGetVisibleTextureNames ( "radar??" ), engineGetVisibleTextureNames ( "radar???" ) ) for name, data in pairs ( tiles ) do if not table.find ( visibleTileNames, name ) then unloadTile ( name ) end end for index, name in ipairs ( visibleTileNames ) do loadTile ( name ) end end function table.merge ( ... ) local ret = { } for index, tbl in ipairs ( {...} ) do for index, val in ipairs ( tbl ) do table.insert ( ret, val ) end end return ret end function table.find ( tbl, val ) for index, value in ipairs ( tbl ) do if ( value == val ) then return index end end return false end function loadTile ( name ) if type ( name ) ~= "string" then return false end if ( tiles[name] ) then return true end local id = tonumber ( name:match ( "%d+" ) ) if not ( id ) then return false end local row = math.floor ( id / ROW_COUNT ) local col = id - ( row * ROW_COUNT ) local posX = -3000 + 500 * col local posY = 3000 - 500 * row local file = string.format ( "sattelite/sattelite_%d_%d.png", row, col ) local texture = dxCreateTexture ( file ) if not ( texture ) then outputChatBox ( string.format ( "Failed to load texture for %q (%q)", tostring ( name ), tostring ( file ) ) ) return false end local shader = dxCreateShader ( "texreplace.fx" ) if not ( shader ) then outputChatBox ( "Failed to load shader" ) destroyElement ( texture ) return false end dxSetShaderValue ( shader, "gTexture", texture ) engineApplyShaderToWorldTexture ( shader, name ) tiles[name] = { shader = shader, texture = texture } return true end function unloadTile ( name ) local tile = tiles[name] if not ( tile ) then return false end if isElement ( tile.shader ) then destroyElement ( tile.shader ) end if isElement ( tile.texture ) then destroyElement ( tile.texture ) end tiles[name] = nil return true end
  8. @Wojak I got this with your way In main function what I did was: if visible then //code which loads custom radar And in two seperate functions: function radaron() visible = true end addCommandHandler("on", radaron) function radaroff() if visible then visible = false end end addCommandHandler("off", radaroff) Some parts of the custom radar unloaded (not all) and the fps drop started after typing the "off" command. Then if I type the "on" command fps increased a bit but was still bad.
  9. OK, but when I start the resource the custom radar is turned on and then there is no lag. The moment I use the "off" command lag starts (from 60fps slowly to 40-30-5..). That's why I'm not really sure what's wrong, also no errors in debug at all.
  10. So thanks to @Stroth (who gave me link) I now have this cool looking radar but I have a problem with the edits I wanna do to it. I want to make it toggleable by two commands: "on" and "off", so that each player can enable or disable it if they wish to do so. I've done a lot of those on/off functions until now and thought it'll be easy but with radar textures it's a bit different than with dxdraw I guess. Here's the code below (I combined both scripts in one file), hope someone who is more familiar with shaders and textures can help me out to achieve the things I want. local tiles = { } local timer local enabled = true local ROW_COUNT = 12 --# Textures table local blips_textures = { { "arrow", "blips/arrow.png" }, { "radardisc", "blips/radardisc.png" }, { "radar_airYard", "blips/radar_airYard.png" }, { "radar_ammugun", "blips/radar_ammugun.png" }, { "radar_barbers", "blips/radar_barbers.png" }, { "radar_BIGSMOKE", "blips/radar_BIGSMOKE.png" }, { "radar_boatyard", "blips/radar_boatyard.png" }, { "radar_bulldozer", "blips/radar_bulldozer.png" }, { "radar_burgerShot", "blips/radar_burgerShot.png" }, { "radar_cash", "blips/radar_cash.png" }, { "radar_CATALINAPINK", "blips/radar_CATALINAPINK.png"}, { "radar_centre", "blips/radar_centre.png" }, { "radar_CESARVIAPANDO", "blips/radar_CESARVIAPANDO.png" }, { "radar_chicken", "blips/radar_chicken.png" }, { "radar_CJ", "blips/radar_CJ.png" }, { "radar_CRASH1", "blips/radar_CRASH1.png" }, { "radar_dateDisco", "blips/radar_dateDisco.png" }, { "radar_dateDrink", "blips/radar_dateDrink.png" }, { "radar_dateFood", "blips/radar_dateFood.png" }, { "radar_diner", "blips/radar_diner.png" }, { "radar_emmetGun", "blips/radar_emmetGun.png" }, { "radar_enemyAttack", "blips/radar_enemyAttack.png" }, { "radar_fire", "blips/radar_fire.png" }, { "radar_Flag", "blips/radar_Flag.png" }, { "radar_gangB", "blips/radar_gangB.png" }, { "radar_gangG", "blips/radar_gangG.png" }, { "radar_gangN", "blips/radar_gangN.png" }, { "radar_gangP", "blips/radar_gangP.png" }, { "radar_gangY", "blips/radar_gangY.png" }, { "radar_girlfriend", "blips/radar_girlfriend.png" }, { "radar_gym", "blips/radar_gym.png" }, { "radar_hostpital", "blips/radar_hostpital.png" }, { "radar_impound", "blips/radar_impound.png" }, { "radar_light", "blips/radar_light.png" }, { "radar_LocoSyndicate", "blips/radar_LocoSyndicate.png" }, { "radar_MADDOG", "blips/radar_MADDOG.png" }, { "radar_mafiaCasino", "blips/radar_mafiaCasino.png" }, { "radar_MCSTRAP", "blips/radar_MCSTRAP.png" }, { "radar_modGarage", "blips/radar_modGarage.png" }, { "radar_north", "blips/radar_north.png" }, { "radar_OGLOC", "blips/radar_OGLOC.png" }, { "radar_pizza", "blips/radar_pizza.png" }, { "radar_police", "blips/radar_police.png" }, { "radar_propertyG", "blips/radar_propertyG.png" }, { "radar_propertyR", "blips/radar_propertyR.png" }, { "radar_qmark", "blips/radar_qmark.png" }, { "radar_race", "blips/radar_race.png" }, { "radar_runway", "blips/radar_runway.png" }, { "radar_RYDER", "blips/radar_RYDER.png" }, { "radar_saveGame", "blips/radar_saveGame.png" }, { "radar_school", "blips/radar_school.png" }, { "radar_spray", "blips/radar_spray.png" }, { "radar_SWEET", "blips/radar_SWEET.png" }, { "radar_tattoo", "blips/radar_tattoo.png" }, { "radar_THETRUTH", "blips/radar_THETRUTH.png" }, { "radar_TORENO", "blips/radar_TORENO.png" }, { "radar_TorenoRanch", "blips/radar_TorenoRanch.png" }, { "radar_triads", "blips/radar_triads.png" }, { "radar_triadsCasino", "blips/radar_triadsCasino.png" }, { "radar_truck", "blips/radar_truck.png" }, { "radar_tshirt", "blips/radar_tshirt.png" }, { "radar_waypoint", "blips/radar_waypoint.png" }, { "radar_WOOZIE", "blips/radar_WOOZIE.png" }, { "radar_ZERO", "blips/radar_ZERO.png" }, { "siteM16", "blips/siteM16.png" }, { "siterocket", "blips/siterocket.png" } } function toggleCustomTiles ( ) for i = 2, #blips_textures do local shader = dxCreateShader("texture.fx") engineApplyShaderToWorldTexture(shader, blips_textures[i][1]) dxSetShaderValue(shader, "gTexture", dxCreateTexture(blips_textures[i][2])) end disabled = not enabled if ( enabled ) then handleTileLoading ( ) timer = setTimer ( handleTileLoading, 500, 0 ) else if isTimer ( timer ) then killTimer ( timer ) end for name, data in pairs ( tiles ) do unloadTile ( name ) end end end addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), toggleCustomTiles) function handleTileLoading ( ) local visibleTileNames = table.merge ( engineGetVisibleTextureNames ( "radar??" ), engineGetVisibleTextureNames ( "radar???" ) ) for name, data in pairs ( tiles ) do if not table.find ( visibleTileNames, name ) then unloadTile ( name ) end end for index, name in ipairs ( visibleTileNames ) do loadTile ( name ) end end function table.merge ( ... ) local ret = { } for index, tbl in ipairs ( {...} ) do for index, val in ipairs ( tbl ) do table.insert ( ret, val ) end end return ret end function table.find ( tbl, val ) for index, value in ipairs ( tbl ) do if ( value == val ) then return index end end return false end function loadTile ( name ) if type ( name ) ~= "string" then return false end if ( tiles[name] ) then return true end local id = tonumber ( name:match ( "%d+" ) ) if not ( id ) then return false end local row = math.floor ( id / ROW_COUNT ) local col = id - ( row * ROW_COUNT ) local posX = -3000 + 500 * col local posY = 3000 - 500 * row local file = string.format ( "sattelite/sattelite_%d_%d.png", row, col ) local texture = dxCreateTexture ( file ) if not ( texture ) then outputChatBox ( string.format ( "Failed to load texture for %q (%q)", tostring ( name ), tostring ( file ) ) ) return false end local shader = dxCreateShader ( "texreplace.fx" ) if not ( shader ) then outputChatBox ( "Failed to load shader" ) destroyElement ( texture ) return false end dxSetShaderValue ( shader, "gTexture", texture ) engineApplyShaderToWorldTexture ( shader, name ) tiles[name] = { shader = shader, texture = texture } return true end function unloadTile ( name ) local tile = tiles[name] if not ( tile ) then return false end if isElement ( tile.shader ) then destroyElement ( tile.shader ) end if isElement ( tile.texture ) then destroyElement ( tile.texture ) end tiles[name] = nil return true end Above is original code from author but what I did in my attempt to edit it was that I changed "onClientResourceStart" to "onClientRender" and added two functions to check if 'enabled' is true or not, that way radar would be turned on "if enabled = true" and turned off "if enabled = false" but I had extreme lag after using the commands. That's because I haven't properly unloaded all shaders/textures which the resource loads. So I decided to just post the original, clean script above and see what ideas you guys may have to make this happen. Cheers
  11. The way I learned (some) lua was by trial and error and asking others for help. It helps a lot to first just edit really simple stuff from already made resources which you can get from the community site. Like, change position of a text on screen, make it look good on any resolution etc. You get the idea. And when you can edit most such parts of already made resources you will start understanding how things work and won't have a problem with creating functions. Remember: always Google or ask in here (if Google has let you down) and you'll learn it, not immediately but you will. So, good luck with it
  12. I don't think you can get any user password in mta. You can just change a user's password with the chgpass command.
  13. local res = getResourceFromName ( "accounts" ) if getResourceState(res) == "running" then --some action here end That's for checking resourse state.
  14. startResource(accResource) should be startResource(accResource, true)
  15. Either that's not the whole code or you haven't added the event itself. Check how it's done here : https://wiki.multitheftauto.com/wiki/AddEvent
  16. Man i loled sry Glad you figured it out
  17. I think it should be if getPlayerName(source) == "Musuh" then
  18. In racevoting_server.lua I edited "startNextMapVote()" function to this but still voter isn't showing when a player buys it or admin sets it :\ function startNextMapVote() exports.votemanager:stopPoll() -- Handle forced nextmap setting if maybeApplyForcedNextMap() then return end local poll = { title="Next or Play again?", visibleTo=getRootElement(), percentage=51, timeout=5, allowchange=true; } local usedGcMapQueue = false if getResourceFromName('scoringsystem') and getResourceState(getResourceFromName('scoringsystem')) == 'running' then if g_ForcedNextMap and getResourceFromName(g_ForcedNextMap) then local mapName = getResourceInfo(getResourceFromName(g_ForcedNextMap), "name") or getResourceName(getResourceFromName(g_ForcedNextMap)) local mapName = "[Maps-Center] "..mapName table.insert(poll, {mapName , 'nextMapVoteResult', getRootElement(), getResourceFromName(g_ForcedNextMap)}) else-- normal next map local mapName = getResourceInfo(_nextMap, "name") or getResourceName(_nextMap) table.insert(poll, {mapName , 'nextMapVoteResult', getRootElement(), _nextMap}) end else -- Normal next map local mapName = getResourceInfo(_nextMap, "name") or getResourceName(_nextMap) table.insert(poll, {mapName , 'nextMapVoteResult', getRootElement(), _nextMap}) end local currentMap = exports.mapmanager:getRunningGamemodeMap() local currentRes = currentMap if currentMap then if not times[currentMap] or times[currentMap] < maxPlayAgain+1 then table.insert(poll, {"Play again", 'nextMapVoteResult', getRootElement(), currentMap}) elseif usedGcMapQueue then -- Start GC mapcenter map outputChatBox('Maximum \'Play Again\' times('..maxPlayAgain..') has been reached. Changing to next map in Maps-Center queue ...') local map = exports.gcshop:getCurrentMapQueued() if not exports.mapmanager:changeGamemodeMap ( getResourceFromName(map[2]), nil, true ) then outputWarning( 'Forced next map failed' ) startRandomMap() else outputChatBox("[Maps-Center] Starting queued map for " .. map[4], root, 0, 255, 0) end skipMapQueue = getResourceFromName(map[2]) return else outputChatBox('Maximum \'Play Again\' times('..maxPlayAgain..') has been reached. Changing to random ...') startRandomMap() return end end -- Allow addons to modify the poll g_Poll = poll triggerEvent('onPollStarting', g_Root, poll ) poll = g_Poll g_Poll = nil local pollDidStart = exports.votemanager:startPoll(poll) if pollDidStart then gotoState('NextMapVote') addEventHandler("onPollEnd", getRootElement(), chooseRandomMap) end return pollDidStart end The things I did are from line 21 to line 33.
  19. I think so, here it is. function getCurrentMapQueued(noRemove) if #myQueue == 0 then return false end if not getResourceFromName(myQueue[1][2]) then outputChatBox("[Maps-Center] ERROR: QUEUED MAP MAY HAVE BEEN DELETED BEFORE IT WAS PLAYED. CONTACT ADMIN FOR REFUND.", root, 255, 0, 0) return false end local choice = myQueue[1] if not noRemove then table.remove(myQueue, 1) if #myQueue > 0 then triggerEvent('onNextmapSettingChange', root, getResourceFromName(myQueue[1][2])) end end return choice end Everything there is linked with 1000 other things so it'll be better if we use default mta functions/methods/idk what. But idk how to get the nextmap and put it in the votemanager.
  20. The votemanager is used with this " table.insert" when the current map ends, no commands or anything. I can't export that function as it uses another server's SQL database and won't work if I export it. I need the g_ForcedNextMap (I assume) to be added to the votemanager rather than for it starting immediatly after current one ends.
  21. Anyone ? Tried again just now, no go.
  22. koragg

    Race Problem

    I'm also interested in this as I have had it at some point as well, though not recently and when it did happen, it was rare.
  23. No problem, Strothie. A tip for the future: never even open the editor in the main server, never, ever. I have a complete MTA 1.5.3 installation from which I play and use editor and a completely seperate folder with my server in it. Editor is just :~ with all those bugs so better keep it away from your server You can copy/paste the "server" folder to another place and start your server from there (it doesn't need the whole MTA to run), that's what I did and no problems anymore.
×
×
  • Create New...