papam77 Posted July 8, 2013 Share Posted July 8, 2013 local me = getLocalPlayer() local maxStreamedPlayers = 16 sx,sy = guiGetScreenSize() function isDM() for i, pu in pairs (getElementsByType("racepickup")) do local puType = getElementData(pu, "type") if (puType == "vehiclechange") then local puVehicle = tonumber(getElementData(pu, "vehicle")) if puVehicle == 425 then return true end end end return false end enabled = false function toggleHideAll() startTimess = getTickCount() setElementData(me, "hideAllPlayers", not getElementData(me, "hideAllPlayers"), false) if enabled == false then removeEventHandler("onClientRender",getRootElement(),mapwindowa) removeEventHandler("onClientRender",getRootElement(),carclose) removeEventHandler("onClientRender",getRootElement(),caropen) removeEventHandler("onClientRender",getRootElement(),wateropen) removeEventHandler("onClientRender",getRootElement(),waterclose) addEventHandler("onClientRender",getRootElement(),mapwindowda) else removeEventHandler("onClientRender",getRootElement(),mapwindowda) removeEventHandler("onClientRender",getRootElement(),carclose) removeEventHandler("onClientRender",getRootElement(),caropen) removeEventHandler("onClientRender",getRootElement(),wateropen) removeEventHandler("onClientRender",getRootElement(),waterclose) addEventHandler("onClientRender",getRootElement(),mapwindowa) end enabled = not enabled end addCommandHandler("hide", toggleHideAll) bindKey("F1", "down", toggleHideAll) function getPlayers() return getElementsByType("player") end streamedPlayers = {} function hidePlayer(player) local vehicle = getPedOccupiedVehicle(player) if vehicle then if getElementModel(vehicle) == 425 then showPlayer(player) return end if getElementDimension(vehicle) ~= 255 or getElementDimension(player) ~= 255 or getElementInterior(player) ~= 255 or getElementInterior(vehicle) ~= 255 then setElementDimension(vehicle, 255) setElementDimension(player, 255) setElementInterior(vehicle, 255) setElementInterior(player, 255) end end end function showPlayer(player) local vehicle = getPedOccupiedVehicle(player) if vehicle then if getElementDimension(vehicle) ~= 0 or getElementDimension(player) ~= 0 or getElementInterior(player) ~= 0 or getElementInterior(vehicle) ~= 0 then setElementDimension(vehicle, 0) setElementDimension(player, 0) setElementInterior(vehicle, 0) setElementInterior(player, 0) end end end setTimer( function() streamedPlayers = {} if getElementData(me, "state") ~= "alive" then for id, player in ipairs(getPlayers()) do if getElementData(player,"state") == "alive" then showPlayer(player) end end else if getElementData(me, "hideAllPlayers") and isDM() then for id, player in ipairs(getPlayers()) do if player ~= me then hidePlayer(player) end end return end local x2,y2,z2 = getElementPosition(me) for id, player in ipairs(getPlayers()) do if player ~= me then local x1,y1,z1 = getElementPosition(player) local d = getDistanceBetweenPoints3D(x1,y1,z1,x2,y2,z2 ) if d < 200 then table.insert(streamedPlayers, {player, d }) end end end if #streamedPlayers > maxStreamedPlayers then table.sort(streamedPlayers, function(a,b) return a[2] < b[2] end) for i = 1, maxStreamedPlayers do showPlayer(streamedPlayers[i][1]) end for i = maxStreamedPlayers+1, #streamedPlayers do hidePlayer(streamedPlayers[i][1]) end else for id, player in ipairs(getPlayers()) do if getElementData(player, "state") == "alive" then showPlayer(player) end end end end end, 500,0 ) function mapwindowa() deltaTime = (getTickCount()) - startTimess if deltaTime <= 1000 then beta = sy - ((deltaTime/1000)*100) elseif (deltaTime > 1000) and (deltaTime < 4000) then beta = sy-100 elseif (deltaTime >= 4000) and (deltaTime <= 6000) then beta = sy-((1-((deltaTime-4000)/800))*100) else removeEventHandler("onClientRender",getRootElement(),mapwindowa) end app = guiCreateStaticImage(0.33, 0.05, 0.32, 0.11, "img/notif.png", true) app = guiCreateLabel(0.00, 0.00, 1.00, 0.25, "Car Hide", true, app) guiLabelSetHorizontalAlign(app, "center", false) guiLabelSetVerticalAlign(app, "center") app = guiCreateLabel(0.00, 0.28, 1.00, 0.72, "CarHide has been disabled...", true, app) guiLabelSetHorizontalAlign(app, "center", false) guiLabelSetVerticalAlign(app, "center") playSound ("audio/notification.mp3", false) end function mapwindowda() deltaTime = (getTickCount()) - startTimess if deltaTime <= 1000 then beta = sy - ((deltaTime/1000)*100) elseif (deltaTime > 1000) and (deltaTime < 4000) then beta = sy-100 elseif (deltaTime >= 4000) and (deltaTime <= 6000) then beta = sy-((1-((deltaTime-4000)/800))*100) else removeEventHandler("onClientRender",getRootElement(),mapwindowda) end app2 = guiCreateStaticImage(0.33, 0.05, 0.32, 0.11, "img/notif.png", true) app2 = guiCreateLabel(0.00, 0.00, 1.00, 0.25, "Car Hide", true, app2) guiLabelSetHorizontalAlign(app2, "center", false) guiLabelSetVerticalAlign(app2, "center") app2 = guiCreateLabel(0.00, 0.28, 1.00, 0.72, "CarHide has been enabled...", true, app2) guiLabelSetHorizontalAlign(app2, "center", false) guiLabelSetVerticalAlign(app2, "center") playSound ("audio/notification.mp3", false) end This is my hide but when i press F1 it makes cca 100x image with texts and 100x playsound... Why ? Link to comment
iPrestege Posted July 8, 2013 Share Posted July 8, 2013 Because you're using onClientRender Event ! Link to comment
iPrestege Posted July 8, 2013 Share Posted July 8, 2013 And what i must use ? setTimer For what? There' no need for timer . use this : if not app2 then -- Create image Don't forget to add 'end' . Link to comment
papam77 Posted July 8, 2013 Author Share Posted July 8, 2013 function mapwindowa() if not app then app = guiCreateStaticImage(0.33, 0.05, 0.32, 0.11, "img/notif.png", true) app = guiCreateLabel(0.00, 0.00, 1.00, 0.25, "Car Hide", true, app) guiLabelSetHorizontalAlign(app, "center", false) guiLabelSetVerticalAlign(app, "center") app1 = guiCreateLabel(0.00, 0.28, 1.00, 0.72, "CarHide has been disabled...", true, app) guiLabelSetHorizontalAlign(app1, "center", false) guiLabelSetVerticalAlign(app1, "center") playSound ("audio/notification.mp3", false) end end function mapwindowda() if not app2 then app2 = guiCreateStaticImage(0.33, 0.05, 0.32, 0.11, "img/notif.png", true) app2 = guiCreateLabel(0.00, 0.00, 1.00, 0.25, "Car Hide", true, app2) guiLabelSetHorizontalAlign(app2, "center", false) guiLabelSetVerticalAlign(app2, "center") app2 = guiCreateLabel(0.00, 0.28, 1.00, 0.72, "CarHide has been enabled...", true, app2) guiLabelSetHorizontalAlign(app2, "center", false) guiLabelSetVerticalAlign(app2, "center") playSound ("audio/notification.mp3", false) end end I changed it, now it works, but when i press F1 it's still on the screen, it must be destoryed after 2sec Link to comment
iPrestege Posted July 8, 2013 Share Posted July 8, 2013 enabled = false function toggleHideAll() startTimess = getTickCount() -- what is this hell? setElementData(me, "hideAllPlayers", not getElementData(me, "hideAllPlayers"), false) if not enabled then removeEventHandler("onClientRender",getRootElement(),mapwindowa) removeEventHandler("onClientRender",getRootElement(),carclose) removeEventHandler("onClientRender",getRootElement(),caropen) removeEventHandler("onClientRender",getRootElement(),wateropen) removeEventHandler("onClientRender",getRootElement(),waterclose) addEventHandler("onClientRender",getRootElement(),mapwindowda) else removeEventHandler("onClientRender",getRootElement(),mapwindowda) removeEventHandler("onClientRender",getRootElement(),carclose) removeEventHandler("onClientRender",getRootElement(),caropen) removeEventHandler("onClientRender",getRootElement(),wateropen) removeEventHandler("onClientRender",getRootElement(),waterclose) addEventHandler("onClientRender",getRootElement(),mapwindowa) end enabled = not enabled end addCommandHandler("hide", toggleHideAll) bindKey("F1", "down", toggleHideAll) Link to comment
papam77 Posted July 8, 2013 Author Share Posted July 8, 2013 But why it doesn't hide my window? Link to comment
papam77 Posted July 8, 2013 Author Share Posted July 8, 2013 This window ! http://www.upload.ee/image/3432547/Hideeeeeeeeeee.png I need to destroy it after 2sec Link to comment
iPrestege Posted July 8, 2013 Share Posted July 8, 2013 OK use timer to destroy it gui window or what? setTimer Link to comment
papam77 Posted July 8, 2013 Author Share Posted July 8, 2013 guiCreateStaticImage guiCreateLabel this i need to destroy Link to comment
iPrestege Posted July 8, 2013 Share Posted July 8, 2013 setTimer ( function ( ) if isElement ( .. ) and isElement ( .. ) then destroyElement ( .. ) destroyElement ( .. ) end end,2000,1 ) Link to comment
papam77 Posted July 8, 2013 Author Share Posted July 8, 2013 function mapwindowa() setTimer ( function ( ) if isElement ( obrazek ) and isElement ( nadpis ) and isElement ( vpis ) then destroyElement ( obrazek ) destroyElement ( nadpis ) destroyElement ( vpis ) end end,2000,1 ) if not obrazek and nadpis and vpis then obrazek = guiCreateStaticImage(0.33, 0.05, 0.32, 0.11, "img/notif.png", true) nadpis = guiCreateLabel(0.00, 0.00, 1.00, 0.25, "Car Hide", true, obrazek) guiLabelSetHorizontalAlign(nadpis, "center", false) guiLabelSetVerticalAlign(nadpis, "center") vpis = guiCreateLabel(0.00, 0.28, 1.00, 0.72, "CarHide has been disabled...", true, obrazek) guiLabelSetHorizontalAlign(vpis, "center", false) guiLabelSetVerticalAlign(vpis, "center") playSound ("audio/notification.mp3", false) end end But i need to destroy it after Press F1 now can't open it. Link to comment
iPrestege Posted July 8, 2013 Share Posted July 8, 2013 Use this timer when you add the event : setTimer ( function ( ) if isElement ( obrazek ) and isElement ( nadpis ) and isElement ( vpis ) then destroyElement ( obrazek ) destroyElement ( nadpis ) destroyElement ( vpis ) end end,2000,1 ) Link to comment
papam77 Posted July 8, 2013 Author Share Posted July 8, 2013 I made this function mapwindowa() if ( obrazek ) and ( nadpis ) and ( vpis ) then -- Check if is created setTimer ( function ( ) if isElement ( obrazek ) and isElement ( nadpis ) and isElement ( vpis ) then destroyElement ( obrazek ) destroyElement ( nadpis ) destroyElement ( vpis ) end end,2000,1 ) end if not obrazek and nadpis and vpis then -- Check if is created obrazek = guiCreateStaticImage(0.33, 0.05, 0.32, 0.11, "img/notif.png", true) nadpis = guiCreateLabel(0.00, 0.00, 1.00, 0.25, "Car Hide", true, obrazek) guiLabelSetHorizontalAlign(nadpis, "center", false) guiLabelSetVerticalAlign(nadpis, "center") vpis = guiCreateLabel(0.00, 0.28, 1.00, 0.72, "CarHide has been disabled...", true, obrazek) guiLabelSetHorizontalAlign(vpis, "center", false) guiLabelSetVerticalAlign(vpis, "center") playSound ("audio/notification.mp3", false) end end And doesn't work. Link to comment
iPrestege Posted July 8, 2013 Share Posted July 8, 2013 if ( obrazek ) and ( nadpis ) and ( vpis ) then -- Check if is created For what is this? Remove this fuck Link to comment
papam77 Posted July 8, 2013 Author Share Posted July 8, 2013 I was thinking that if is already created then will start function setTimer with Destroy 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