Bilal135 Posted April 17, 2015 Share Posted April 17, 2015 My script works fine, but the dx text appears just for a second on hit of col shape and won't stay until I leave the radar area. So here's it, I can't find anyway to solve this problem so I'm here to ask for help. server local radararea = createRadarArea(1338.5789794922, -1753.3083496094, 200, 200, 255, 0, 0) local col = createColRectangle(1338.5789794922, -1753.3083496094, 100, 200) function sa() setElementAlpha(radararea, 100) end addEventHandler("onResourceStart", root, sa) function areaEnter(thePlayer, matchingDimension) if (getElementType(thePlayer) == "player") then setRadarAreaFlashing(radararea, true) triggerClientEvent(thePlayer, "colHit", thePlayer) end end addEventHandler("onColShapeHit", getRootElement(), areaEnter) function areaExit(thePlayer, matchingDimension) if (getElementType(thePlayer) == "player") then if isPedDead(thePlayer) ~= true then setRadarAreaFlashing(radararea, false) end end end addEventHandler("onColShapeLeave", getRootElement(), areaExit) client: addEvent("colHit", true) addEventHandler("colHit", root, function() dxDrawText("You have entered the red zone. A hidden package (Gunbox) can be found here.", 378, 594, 1055, 680, tocolor(255, 255, 255, 255), 1.00, "sans", "center", "center", false, false, false, false, false) end ) Link to comment
HunT Posted April 17, 2015 Share Posted April 17, 2015 You need use : https://wiki.multitheftauto.com/wiki/OnClientRender onColShapeHit And https://wiki.multitheftauto.com/wiki/RemoveEventHandler onColShapeLeave Link to comment
Bilal135 Posted April 17, 2015 Author Share Posted April 17, 2015 You need use : https://wiki.multitheftauto.com/wiki/OnClientRender onColShapeHitAnd https://wiki.multitheftauto.com/wiki/RemoveEventHandler onColShapeLeave Can you do it for me, coz I'm not expert in GUI scripting, and it will be helpful for me in my future scripts if you do it. Thanks. Link to comment
HunT Posted April 17, 2015 Share Posted April 17, 2015 Server : local radararea = createRadarArea(1338.5789794922, -1753.3083496094, 200, 200, 255, 0, 0) local col = createColRectangle(1338.5789794922, -1753.3083496094, 100, 200) function sa() setElementAlpha(radararea, 100) end addEventHandler("onResourceStart", root, sa) function areaEnter(thePlayer, matchingDimension) if (getElementType(thePlayer) == "player") then setRadarAreaFlashing(radararea, true) triggerClientEvent(thePlayer, "colHit", thePlayer) end end addEventHandler("onColShapeHit", getRootElement(), areaEnter) function areaExit(thePlayer, matchingDimension) if (getElementType(thePlayer) == "player") then if isPedDead(thePlayer) ~= true then setRadarAreaFlashing(radararea, false) triggerClientEvent(thePlayer, "colLeave", thePlayer) end end end addEventHandler("onColShapeLeave", getRootElement(), areaExit) Client : function drawText () dxDrawText("You have entered the red zone. A hidden package (Gunbox) can be found here.", 378, 594, 1055, 680, tocolor(255, 255, 255, 255), 1.00, "sans", "center", "center", false, false, false, false, false) end addEvent("colHit", true) addEventHandler("colHit", root, function() addEventHandler("onClientRender", root, drawText) end ) addEvent("colLeave", true) addEventHandler("colLeave", root, function() removeEventHandler( "onClientRender", root, drawText ) end ) Probably u need edit the size of createColRectangle Link to comment
Dimos7 Posted April 17, 2015 Share Posted April 17, 2015 function draw() dxDrawText("You have entered the red zone. A hidden package (Gunbox) can be found here.", 378, 594, 1055, 680, tocolor(255, 255, 255, 255), 1.00, "sans", "center", "center", false, false, false, false, false) end addEvent("colHit", true) addEventHandler("colHit", root, draw) addEventHandler("onClientRender", root, draw) Link to comment
Bilal135 Posted April 17, 2015 Author Share Posted April 17, 2015 function draw() dxDrawText("You have entered the red zone. A hidden package (Gunbox) can be found here.", 378, 594, 1055, 680, tocolor(255, 255, 255, 255), 1.00, "sans", "center", "center", false, false, false, false, false) end addEvent("colHit", true) addEventHandler("colHit", root, draw) addEventHandler("onClientRender", root, draw) That works, but it doesn't get removed when out of the zone. EDIT: it appears as the resource starts, no matter if the player is out of redzone or not. Link to comment
Dimos7 Posted April 17, 2015 Share Posted April 17, 2015 Server: local radararea = createRadarArea(1338.5789794922, -1753.3083496094, 200, 200, 255, 0, 0) local col = createColRectangle(1338.5789794922, -1753.3083496094, 100, 200) function sa() setElementAlpha(radararea, 100) end addEventHandler("onResourceStart", root, sa) function areaEnter(thePlayer, matchingDimension) if (getElementType(thePlayer) == "player") then setRadarAreaFlashing(radararea, true) triggerClientEvent(thePlayer, "colHit", thePlayer) end end addEventHandler("onColShapeHit", getRootElement(), areaEnter) function areaExit(thePlayer, matchingDimension) if (getElementType(thePlayer) == "player") then if isPedDead(thePlayer) ~= true then setRadarAreaFlashing(radararea, false) triggerClientEvent(thePlayer, "colLeave", thePlayer) end end end addEventHandler("onColShapeLeave", getRootElement(), areaExit) Client: function Draw() dxDrawText("You have entered the red zone. A hidden package (Gunbox) can be found here.", 378, 594, 1055, 680, tocolor(255, 255, 255, 255), 1.00, "sans", "center", "center", false, false, false, false, false) end addEvent("colHit", true) addEventHandler("colHit", root, function() addEventHandler("onClientRender", root, Draw) end ) addEvent("colLeave", true) addEventHandler("colLeave", root, function() removeEventHandler("onClientRender", root, Draw) end ) Link to comment
Bilal135 Posted April 17, 2015 Author Share Posted April 17, 2015 Thanks Dimos7, it works perfectly and now I understood how to do it. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now