joubouti Posted May 16, 2015 Share Posted May 16, 2015 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
ALw7sH Posted May 16, 2015 Share Posted May 16, 2015 create button with guiCreateButton function and use onClientGUIClick event Link to comment
joubouti Posted May 16, 2015 Author Share Posted May 16, 2015 (edited) create button with guiCreateButton functionand 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 May 16, 2015 by Guest Link to comment
ALw7sH Posted May 16, 2015 Share Posted May 16, 2015 exactly, then you can execute the command of your code using executeCommandHandler Link to comment
Atton Posted May 16, 2015 Share Posted May 16, 2015 (edited) I made a gui about a year ago that should do this job and more. Also the above looks like solid snakes code. http://www.mediafire.com/download/hw4ew ... jc/fap.zip Edited May 16, 2015 by Guest Link to comment
joubouti Posted May 16, 2015 Author Share Posted May 16, 2015 i tried this command before but don't work please write to me the script Link to comment
Atton Posted May 16, 2015 Share Posted May 16, 2015 i tried this command before but don't workplease write to me the script Save yourself the time and use the gui I gave you. Link to comment
joubouti Posted May 16, 2015 Author Share Posted May 16, 2015 but I made panel admin i want if i press the button on/off the godmode Link to comment
Walid Posted May 16, 2015 Share Posted May 16, 2015 but I made panel admin i want if i press the button on/off the godmode You can't use executeCommandHandler in client side because the command is in server side so you need to use triggerServerEvent() Link to comment
joubouti Posted May 16, 2015 Author Share Posted May 16, 2015 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
Walid Posted May 16, 2015 Share Posted May 16, 2015 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
joubouti Posted May 16, 2015 Author Share Posted May 16, 2015 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
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