Jump to content

a little help


Recommended Posts

hi

i foundd script and i want running this script with GUIButton

I have tried but I don't know how i do this , please can someone help me

this is the script

[Client-Side]

    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) 

[server-Side]

    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) 

Link to comment
create button with guiCreateButton function

and use onClientGUIClick event

like this

GodMod_Button = guiCreateButton(556, 265, 133, 48, "", false) 
function guiclick() 
if source == GodMod_Button then 
  
    end 
    end 
addEventHandler("onClientGUIClick", resourceRoot, click) 
  

Edited by Guest
Link to comment

i do this but don't work please Correct the error

[Client-Side]

function click() 
if source == GodMod_Button then 
        triggerServerEvent ("GodMode", localPlayer) 
         
    end 
    end 
addEventHandler("onClientGUIClick", resourceRoot, click) 

[server-Side]

function godmode(thePlayer)   
    executeCommandHandler ( "godmode", thePlayer) 
end 
addEvent("GodMode", true) 
addEventHandler("GodMode", getRootElement(), godmode) 
  

Link to comment

exactly

Also you can use sth like this

-- Client

GodMod_Button = guiCreateButton(556, 265, 133, 48, "", false) 
  
function guiclick() 
    if source == GodMod_Button then 
        triggerServerEvent("godMod",localPlayer) 
    end 
end 
addEventHandler("onClientGUIClick", resourceRoot, guiclick) 

-- Server

function toggleGodMode() 
    local account = getPlayerAccount(source) 
    if (not account or isGuestAccount(account)) then return end 
    local accountName = getAccountName(account) 
    if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Admin" ) ) ) then 
        if getElementData(source,"invincible") then 
            setElementData(source,"invincible",false) 
            outputChatBox("God Mode is now Disabled.",source,0,255,0) 
        else 
            setElementData(source,"invincible",true) 
            outputChatBox("God Mode is now Enabled.",source,0,255,0) 
        end 
    end 
end 
addEvent("godMod",true) 
addEventHandler("godMod",root,toggleGodMode) 

Link to comment
exactly

Also you can use sth like this

-- Client

GodMod_Button = guiCreateButton(556, 265, 133, 48, "", false) 
  
function guiclick() 
    if source == GodMod_Button then 
        triggerServerEvent("godMod",localPlayer) 
    end 
end 
addEventHandler("onClientGUIClick", resourceRoot, guiclick) 

-- Server

function toggleGodMode() 
    local account = getPlayerAccount(source) 
    if (not account or isGuestAccount(account)) then return end 
    local accountName = getAccountName(account) 
    if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Admin" ) ) ) then 
        if getElementData(source,"invincible") then 
            setElementData(source,"invincible",false) 
            outputChatBox("God Mode is now Disabled.",source,0,255,0) 
        else 
            setElementData(source,"invincible",true) 
            outputChatBox("God Mode is now Enabled.",source,0,255,0) 
        end 
    end 
end 
addEvent("godMod",true) 
addEventHandler("godMod",root,toggleGodMode) 

thx man it work now

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