Jump to content

Why this script isn't working ? I tryed to give access


shoBy

Recommended Posts

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

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

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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...