shoBy Posted September 5, 2014 Share Posted September 5, 2014 Why this script isn't working ? I tryed to give access to the godmode but it doesn't working...Why? Server.lua function toggleGodMode(thePlayer) local account = getPlayerAccount(thePlayer) if (not account or isGuestAccount(account)) then return end local accountName = getAccountName(account) local groups = { "Owner", "Co-Owner", "Admin" , "SuperModerator" , "Moderator" } addEventHandler("onPlayerLogin", root, function ( _,account ) local account = getPlayerAccount(source) if (not account or isGuestAccount(account)) then return end local accountName = getAccountName(account) for i, v in pairs ( groups ) do if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( v ) ) ) then if getElementData(thePlayer,"invincible") == true then setElementData(thePlayer,"invincible",false) outputChatBox("God Mode is now Disabled.",thePlayer,0,255,0) else setElementData(thePlayer,"invincible",true) setElementData(thePlayer, "blood", 99999999) outputChatBox("God Mode is now Enabled.",thePlayer,0,255,0) end end end addCommandHandler("godmode",toggleGodMode) Client.lua 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) Link to comment
Dimos7 Posted September 5, 2014 Share Posted September 5, 2014 if understand right you want no fell damage when you have that command i am coorect? Link to comment
Ab-47 Posted September 5, 2014 Share Posted September 5, 2014 Woah dude, just looking at your server file, I wouldn't even move onto debugging errors on your client side file. You've already defined the account and added a check to see if the account exists or not AND you already have a function taking place, why enter a function within a function? But then you've added the same check and same defined variable within that function too. Delete the extra function, delete the extra variable definition and the check. Then finish of your first function and end it, then create a separate function using your event handler and finish that off. Once all of that is done, post your new code and we'll help you diagnose any problems if you find there are any.. Oh and /debugscript 3 for more details about errors in your code. Link to comment
shoBy Posted September 5, 2014 Author Share Posted September 5, 2014 Guys, I just want to give acces to the acl groups and I can't..Look server.lua line 7 and 11-15 Link to comment
Mr.Aleks Posted September 5, 2014 Share Posted September 5, 2014 server local groups = { "Owner", "Co-Owner", "Admin" , "SuperModerator" , "Moderator" } function toggleGodMode(thePlayer) local account = getPlayerAccount(thePlayer) if account then if not isGuestAccount(account) then local accountName = getAccountName(account) for i, v in pairs ( groups ) do if isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( v ) ) then if getElementData(thePlayer, "godmode") == true then setElementData(thePlayer, "godmode", false) outputChatBox("God Mode is now Disabled.",thePlayer,0,255,0) setAccountData(account, "godmode", false) elseif getElementData(thePlayer, "godmode") == false then setElementData(thePlayer, "godmode", true) setElementData(thePlayer, "blood", 99999999) setAccountData(account, "godmode", true) outputChatBox("God Mode is now Enabled.",thePlayer,0,255,0) end end end end end end addCommandHandler("godmode",toggleGodMode) addEventHandler("onPlayerLogin", root, function ( _,account ) local account = getPlayerAccount(source) if account then if not isGuestAccount(account) then local godstate = getAccountData(account, "godmode") if godstate == true then setElementData(source, "blood", 99999999) setElementData(source, "godmode", true) outputChatBox("You had been disconnected with your godmode enabled.",source,0,255,0) else setElementData(source, "godmode", false) end end end end) client addEventHandler ( "onClientPlayerDamage",root, function () if getElementData(source,"godmode") == true then cancelEvent() end end) addEventHandler("onClientPlayerStealthKill",localPlayer, function (targetPlayer) if getElementData(targetPlayer,"godmode") == true then cancelEvent() end end) Link to comment
shoBy Posted September 5, 2014 Author Share Posted September 5, 2014 It works! But when I disable godmode, my blood is still 999999...Please help Link to comment
Mr.Aleks Posted September 5, 2014 Share Posted September 5, 2014 local groups = { "Owner", "Co-Owner", "Admin" , "SuperModerator" , "Moderator" } function toggleGodMode(thePlayer) local account = getPlayerAccount(thePlayer) if account then if not isGuestAccount(account) then local accountName = getAccountName(account) for i, v in pairs ( groups ) do if isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( v ) ) then if getElementData(thePlayer, "godmode") == true then setElementData(thePlayer, "godmode", false) setElementData(thePlayer, "blood", 12000) outputChatBox("God Mode is now Disabled.",thePlayer,0,255,0) setAccountData(account, "godmode", false) elseif getElementData(thePlayer, "godmode") == false then setElementData(thePlayer, "godmode", true) setElementData(thePlayer, "blood", 99999999) setAccountData(account, "godmode", true) outputChatBox("God Mode is now Enabled.",thePlayer,0,255,0) end end end end end end addCommandHandler("godmode",toggleGodMode) addEventHandler("onPlayerLogin", root, function ( _,account ) local account = getPlayerAccount(source) if account then if not isGuestAccount(account) then local godstate = getAccountData(account, "godmode") if godstate == true then setElementData(source, "blood", 99999999) setElementData(source, "godmode", true) outputChatBox("You had been disconnected with your godmode enabled.",source,0,255,0) else setElementData(source, "godmode", false) end end end end) Link to comment
shoBy Posted September 5, 2014 Author Share Posted September 5, 2014 It works! Can you write on the global chat behind the admin nick [ON-DUTY] when is with godmode enabled ? Or you can't ? Link to comment
Mr.Aleks Posted September 5, 2014 Share Posted September 5, 2014 You haven't posted anything about the chats... that's only about the godmode. If you need help with chats, post the code. 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