micheal1230 Posted May 20, 2012 Posted May 20, 2012 I Cant make it admin only local godModeState = false addCommandHandler ( "godmode", function ( ) if exports.global:isPlayerSuperAdmin( ) godModeState = ( not godModeState ) outputChatBox ( "God Mode is now ".. ( godModeState and "Enabled" or "Disabled" ) ..".", 0, 255, 0 ) end end ) function togdamage ( attacker, weapon, bodypart ) if ( godModeState ) then cancelEvent ( ) end end addEventHandler ( "onClientPlayerDamage", localPlayer, togdamage )
micheal1230 Posted May 20, 2012 Author Posted May 20, 2012 Use setElementData getElementData I Dont Understand Use It Where? Instead Of What?
myonlake Posted May 20, 2012 Posted May 20, 2012 addCommandHandler("godmode", function() if exports.global:isPlayerSuperAdmin() then if getElementData(source, "godmode") and getElementData(source, "godmode") == true then setElementData(localPlayer, "godmode", false) outputChatBox("God Mode is now disabled.", 0, 255, 0, false) else setElementData(localPlayer, "godmode", true) outputChatBox("God Mode is now enabled.", 0, 255, 0, false) end end end ) function togdamage(attacker, weapon, bodypart) if getElementData(source, "godmode") and getElementData(source, "godmode") == true then cancelEvent() end end addEventHandler("onClientPlayerDamage", localPlayer, togdamage)
micheal1230 Posted May 20, 2012 Author Posted May 20, 2012 addCommandHandler("godmode", function() if exports.global:isPlayerSuperAdmin() then if getElementData(source, "godmode") and getElementData(source, "godmode") == true then setElementData(localPlayer, "godmode", false) outputChatBox("God Mode is now disabled.", 0, 255, 0, false) else setElementData(localPlayer, "godmode", true) outputChatBox("God Mode is now enabled.", 0, 255, 0, false) end end end ) function togdamage(attacker, weapon, bodypart) if getElementData(source, "godmode") and getElementData(source, "godmode") == true then cancelEvent() end end addEventHandler("onClientPlayerDamage", localPlayer, togdamage) Does'nt Work
myonlake Posted May 20, 2012 Posted May 20, 2012 Are you sure this script is running and the resource 'global' is running and you're a super admin?
micheal1230 Posted May 20, 2012 Author Posted May 20, 2012 Are you sure this script is running and the resource 'global' is running and you're a super admin? Yes
Alpha Posted May 20, 2012 Posted May 20, 2012 Try: addCommandHandler("godmode", function() if exports.global:isPlayerSuperAdmin() then if getElementData(localPlayer, "godmode") and getElementData(localPlayer, "godmode") == true then setElementData(localPlayer, "godmode", false) outputChatBox("God Mode is now disabled.", 0, 255, 0, false) else setElementData(localPlayer, "godmode", true) outputChatBox("God Mode is now enabled.", 0, 255, 0, false) end end end ) function togdamage(attacker, weapon, bodypart) if getElementData(source, "godmode") and getElementData(source, "godmode") == true then cancelEvent() end end addEventHandler("onClientPlayerDamage", localPlayer, togdamage)
myonlake Posted May 20, 2012 Posted May 20, 2012 Oh yes, I forgot that, hehe'. Try Alpha's version, he fixed the 'source' issue there.
Castillo Posted May 20, 2012 Posted May 20, 2012 Use setElementData getElementData Why should he use element data? his script is 100% client side and the function: isPlayerSuperAdmin is as well client side.
Kenix Posted May 20, 2012 Posted May 20, 2012 He not showed source code function IsPlayerSuperAdmin. I'm not a telepathist. setElementData getElementData Server side: Player login -> if player admin then set data 'Admin' and etc. Client side: just check what return data.
Castillo Posted May 20, 2012 Posted May 20, 2012 @micheal1230: This should work: local godModeState = false addCommandHandler ( "godmode", function ( ) if ( exports.global:isPlayerSuperAdmin ( localPlayer ) ) then -- You had forgot to define 'localPlayer' and forgot about 'then'. godModeState = ( not godModeState ) outputChatBox ( "God Mode is now ".. ( godModeState and "Enabled" or "Disabled" ) ..".", 0, 255, 0 ) end end ) function togdamage ( attacker, weapon, bodypart ) if ( godModeState ) then cancelEvent ( ) end end addEventHandler ( "onClientPlayerDamage", localPlayer, togdamage )
FSXTim Posted May 20, 2012 Posted May 20, 2012 That means the functions 'getElementData' and 'setElementData' can only be used in serverside scripts? Greets
Jaysds1 Posted May 20, 2012 Posted May 20, 2012 no, they could be used in both sides, These functions could only be used server-sided: getAccountData setAccountData
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