Memory Posted November 3, 2012 Posted November 3, 2012 Hello, I have the code addEvent("onMapStarting") addEventHandler("onMapStarting", getRootElement(), function(mapInfo) if string.find(mapInfo.name, "[DM]", 1, true) or mapInfo.modename == "Sprint" then gmon() else gmoff() end end) function gmon(player) for theKey,thePlayer in ipairs(getElementsByType("player")) do setElementData( thePlayer, "overrideCollide.uniqueblah", 0, false ) outputChatBox("GM enabled",thePlayer,186,212,71,true) end end function gmoff(player) for theKey,thePlayer in ipairs(getElementsByType("player")) do setElementData(thePlayer, "overrideCollide.uniqueblah", nil, false ) outputChatBox("GM disabled",thePlayer,255,255,255,true) end end I want add image if gm enabled and if disabled. I tryed create client, but code doesn't work. What could be the problem? local screenWidth, screenHeight = guiGetScreenSize() function gmimgs(mapInfo) if string.find(mapInfo.name, "[DM]", 1, true) or mapInfo.modename == "Sprint" then gmonimg() else gmoffimg() end end addEvent("onMapStarting") addEventHandler("onMapStarting", getRootElement(), gmimgs) function gmonimg() guiCreateStaticImage ( screenWidth/2-65, 0, 165, 65, "gm_on.png", false, nil) end end function gmoffimg() guiCreateStaticImage(screenWidth/2-65, 0, 165, 65, "gm_off.png", false, nil) end end
Memory Posted November 4, 2012 Author Posted November 4, 2012 I think I need to use"triggerServerEvent", but doesn't work. local screenWidth, screenHeight = guiGetScreenSize() function gmonimg() triggerServerEvent("gmon",getRootElement()) guiCreateStaticImage(screenWidth/2-65, 0, 165, 65, "gm.png", false, nil) end
Scooby Posted November 4, 2012 Posted November 4, 2012 just for something simple like 1 small image, u could use element data, even more so since u set it in ur function. u have: 'setElementData( thePlayer, "overrideCollide.uniqueblah", 0, false )' if u use 'true' (or leave blank) its synched clientside. then in onClientRender u can check if the elementData exists or == 0, and if so, show the image. u have all the code and lines needed, so i think u can manage without the trigger for just 1 thing.
Scooby Posted November 6, 2012 Posted November 6, 2012 sure, u already have ur functions server side for ghostmode on/off which uses element data, but it needs changing to synch client side, just remove the 'false' ( or if this is done this way for some unseen reason u can add another element data line) anyway, u have the code needed server side, just edit the 'setElementData' lines in the on/off functions function gmon(player) for theKey,thePlayer in ipairs(getElementsByType("player")) do setElementData( thePlayer, "overrideCollide.uniqueblah", 0 ) outputChatBox("GM enabled",thePlayer,186,212,71,true) end end function gmoff(player) for theKey,thePlayer in ipairs(getElementsByType("player")) do setElementData(thePlayer, "overrideCollide.uniqueblah", nil ) outputChatBox("GM disabled",thePlayer,255,255,255,true) end end then clientside: this will check element data and if it exists it will show the image: local screenWidth,screenHeight = guiGetScreenSize() function showGhostModeImage() local ghostModeOn = getElementData(getLocalPlayer(),"overrideCollide.uniqueblah") if ghostModeOn then dxDrawImage (screenWidth/2 - 65, 0, 165, 65, "gm_on.png", 0, 0, -120 ) end end addEventHandler ( "onClientRender", root, showGhostModeImage) i havent tested it so let me know if u still need more help.
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