mint3d Posted November 4, 2013 Share Posted November 4, 2013 I need a god mode you can activate with command any help? Link to comment
manawydan Posted November 4, 2013 Share Posted November 4, 2013 only example, try -- server local GodCommand = "god" -- command function SetGodAdmin(P) if isGuestAccount(getPlayerAccount(P)) then return outputChatBox("Only Adm can use",P) end -- guest if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(P)),aclGetGroup( "Admin" )) then -- is admin? local Is = getElementData(P,"GodAdmin") -- get data if Is then -- if data is true removeElementData(P,"GodAdmin") -- lets remove outputChatBox("God mod off",P) else -- else lets activate setElementData(P,"GodAdmin",true) outputChatBox("God mod on",P) end end end addCommandHandler(GodCommand,SetGodAdmin) -- client addEventHandler("onClientPlayerDamage",getLocalPlayer(), function() if getElementData(source,"GodAdmin") then cancelEvent() end end ) Link to comment
Price. Posted November 4, 2013 Share Posted November 4, 2013 your code is a total mess here try castillo's code SERVER SIDED: function toggleGodMode(thePlayer) local account = getPlayerAccount(thePlayer) if (not account or isGuestAccount(account)) then return end local accountName = getAccountName(account) if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Admin" ) ) ) then if getElementData(thePlayer,"invincible") then setElementData(thePlayer,"invincible",false) outputChatBox("God Mode is now Disabled.",thePlayer,0,255,0) else setElementData(thePlayer,"invincible",true) outputChatBox("God Mode is now Enabled.",thePlayer,0,255,0) end end end addCommandHandler("godmode",toggleGodMode) CLIENT SIDED: addEventHandler ( "onClientPlayerDamage",root, function () if getElementData(source,"invincible") then cancelEvent() end end) addEventHandler("onClientPlayerStealthKill",localPlayer, function (targetPlayer) if getElementData(targetPlayer,"invincible") then cancelEvent() end end) this is Castillo's code. Link to comment
Ab-47 Posted November 5, 2013 Share Posted November 5, 2013 only example, try -- server local GodCommand = "god" -- command function SetGodAdmin(P) if isGuestAccount(getPlayerAccount(P)) then return outputChatBox("Only Adm can use",P) end -- guest if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(P)),aclGetGroup( "Admin" )) then -- is admin? local Is = getElementData(P,"GodAdmin") -- get data if Is then -- if data is true removeElementData(P,"GodAdmin") -- lets remove outputChatBox("God mod off",P) else -- else lets activate setElementData(P,"GodAdmin",true) outputChatBox("God mod on",P) end end end addCommandHandler(GodCommand,SetGodAdmin) -- client addEventHandler("onClientPlayerDamage",getLocalPlayer(), function() if getElementData(source,"GodAdmin") then cancelEvent() end end ) Meh, tried to fix your code a bit using local defined variables: -- server local plrGodadmin = false function SetGodAdmin(P) if isGuestAccount(getPlayerAccount(P)) then outputChatBox("Only Admins can use this", P, 255, 0, 0) return end -- guest if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(P)),aclGetGroup( "Admin" )) then -- is admin? if (plrGodadmin == true) then -- if data is true plrGodadmin = false -- lets remove outputChatBox("God mod off",P) elseif (plrGodadmin == false) then -- else lets activate plrGodadmin = true outputChatBox("God mod on",P) else return end end end addCommandHandler("god", SetGodAdmin) -- client addEventHandler("onClientPlayerDamage", getLocalPlayer(), function() if (plrGodadmin == true) then cancelEvent() end end ) I can also use element data, buh, try it this way. (Untested) Link to comment
Spajk Posted November 5, 2013 Share Posted November 5, 2013 You cannot use it like that. local plrGodadmin = false It will work good as long as one player is on the server, but if there are more players it wont work correctly. 2nd, you dont have plrGodadmin defined client-side. Link to comment
-.Paradox.- Posted November 5, 2013 Share Posted November 5, 2013 Server side function setInince(thePlayer) if (hasObjectPermissionTo(thePlayer, "function.banPlayer")) then if (getElementData(thePlayer, "INV") == "true") then setElementData(thePlayer,"INV", "false") outputChatBox("God mode OFF", thePlayer) else setElementData(thePlayer,"INV", "true") outputChatBox("God mode ON", thePlayer) end else outputChatBox("You do not have permission for this", thePlayer) end end addCommandHandler("god", setInince) Client side function noadmdamage() if (getElementData(source, "INV") == "true") then cancelEvent() else end end addEventHandler("onClientPlayerDamage", getRootElement(), noadmdamage) Link to comment
Ab-47 Posted November 5, 2013 Share Posted November 5, 2013 Server side function setInince(thePlayer) if (hasObjectPermissionTo(thePlayer, "function.banPlayer")) then if (getElementData(thePlayer, "INV") == "true") then setElementData(thePlayer,"INV", "false") outputChatBox("God mode OFF", thePlayer) else setElementData(thePlayer,"INV", "true") outputChatBox("God mode ON", thePlayer) end else outputChatBox("You do not have permission for this", thePlayer) end end addCommandHandler("god", setInince) Client side function noadmdamage() if (getElementData(source, "INV") == "true") then cancelEvent() else end end addEventHandler("onClientPlayerDamage", getRootElement(), noadmdamage) Would this code even work? I mean, when the player triggers the command for the first time his data is nil towards "INV" so it wouldn't be false or true, which would cause the code not to work, I guess. If the code itself did automatically change the players element data to false, you've defined false as "false" meaning it's in a word-form, not recognizable by MTA, just a data definition. Suggestion, if what I say is correct: function onJoin() if (not getElementData(source, "INV") then setElementData(source, "INV", "false") end end addEventHandler("onPlayerJoin", root, onJoin) --Not tested Link to comment
xXMADEXx Posted November 5, 2013 Share Posted November 5, 2013 Oh my god people, it isn't that hard for him to search community. Link to comment
-.Paradox.- Posted November 5, 2013 Share Posted November 5, 2013 Server side function setInince(thePlayer) if (hasObjectPermissionTo(thePlayer, "function.banPlayer")) then if (getElementData(thePlayer, "INV") == "true") then setElementData(thePlayer,"INV", "false") outputChatBox("God mode OFF", thePlayer) else setElementData(thePlayer,"INV", "true") outputChatBox("God mode ON", thePlayer) end else outputChatBox("You do not have permission for this", thePlayer) end end addCommandHandler("god", setInince) Client side function noadmdamage() if (getElementData(source, "INV") == "true") then cancelEvent() else end end addEventHandler("onClientPlayerDamage", getRootElement(), noadmdamage) Would this code even work? I mean, when the player triggers the command for the first time his data is nil towards "INV" so it wouldn't be false or true, which would cause the code not to work, I guess. If the code itself did automatically change the players element data to false, you've defined false as "false" meaning it's in a word-form, not recognizable by MTA, just a data definition. Suggestion, if what I say is correct: function onJoin() if (not getElementData(source, "INV") then setElementData(source, "INV", "false") end end addEventHandler("onPlayerJoin", root, onJoin) --Not tested Try my code you genius, it's working. Link to comment
Castillo Posted November 5, 2013 Share Posted November 5, 2013 your code is a total messhere try castillo's code SERVER SIDED: function toggleGodMode(thePlayer) local account = getPlayerAccount(thePlayer) if (not account or isGuestAccount(account)) then return end local accountName = getAccountName(account) if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Admin" ) ) ) then if getElementData(thePlayer,"invincible") then setElementData(thePlayer,"invincible",false) outputChatBox("God Mode is now Disabled.",thePlayer,0,255,0) else setElementData(thePlayer,"invincible",true) outputChatBox("God Mode is now Enabled.",thePlayer,0,255,0) end end end addCommandHandler("godmode",toggleGodMode) CLIENT SIDED: addEventHandler ( "onClientPlayerDamage",root, function () if getElementData(source,"invincible") then cancelEvent() end end) addEventHandler("onClientPlayerStealthKill",localPlayer, function (targetPlayer) if getElementData(targetPlayer,"invincible") then cancelEvent() end end) this is Castillo's code. That code should work. 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