Jump to content

Doesn't work (GUI Problem)


Recommended Posts

Posted

CLIENT:

function checkBox() 
if (guiCheckBoxGetSelected(GUIEditor.checkbox[1])) then 
setElementData(localPlayer, "invincible", true) 
else 
setElementData(localPlayer, "invincible", false) 
end 
end 
  
addEventHandler ( "onClientPlayerDamage",root, 
    function () 
        if getElementData(localPlayer,"invincible") then 
            cancelEvent() 
        end 
    end) 

The player health still decreases. No errors in debug.

"Get busy living or get busy dying"

Posted

it must be like this

addEventHandler ( "onClientPlayerDamage",localPlayer, 
    function () 
        if getElementData(localPlayer,"invincible") then 
            cancelEvent() 
        end 
end) 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

checkBox function is never being triggered in the code you provided

Also as walid said you should use localPlayer in damage event function

If you find my post useful or if it helped you, please like my post :)
Ingame name: ZoeN

560x95_FFFFFF_FF9900_000000_000000.png

Posted

Well, I did something like this. Doesn't work.

function checkBox() 
if ( getElementType(localPlayer) == "GUIEditor.checkbox[1]" ) then 
if (guiCheckBoxGetSelected(localPlayer)) then 
setElementData(localPlayer, "invincible", true) 
else 
setElementData(localPlayer, "invincible", false) 
end 
end 
end 
  
addEventHandler ( "onClientPlayerDamage",localPlayer, 
    function () 
        if getElementData(localPlayer,"invincible") then 
            cancelEvent() 
        end 
end) 

No errors in debug.

"Get busy living or get busy dying"

Posted

it's Wrong.

Try this

function checkBox() 
    if ( getElementType(source) == "gui-checkbox" ) then  
        if ( guiCheckBoxGetSelected(GUIEditor.checkbox[1])) then 
            setElementData(localPlayer, "invincible", true) 
        else 
           setElementData(localPlayer, "invincible", false) 
        end 
    end 
end 
addEventHandler("onClientGUIClick", root, checkBox, false) 
  
addEventHandler ( "onClientPlayerDamage",localPlayer, 
    function () 
        if getElementData(source,"invincible") then 
            cancelEvent() 
        end 
end) 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted
Doesn't work at all.

Post full code here. i'm pretty sure that you have something wrong

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

CLIENT:

GUIEditor = { 
    checkbox = {}, 
    staticimage = {}, 
    label = {}, 
    button = {}, 
    window = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(542, 254, 348, 92, "No Deathmatch Mode", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
  
        GUIEditor.label[1] = guiCreateLabel(10, 25, 283, 15, "You can enable or disable 'No Deathmatch' mode.", false, GUIEditor.window[1]) 
        GUIEditor.staticimage[1] = guiCreateStaticImage(10, 50, 34, 26, "icon.png", false, GUIEditor.window[1]) 
        GUIEditor.checkbox[1] = guiCreateCheckBox(49, 52, 234, 24, "Enable / Disable No Deathmatch Mode", false, false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.checkbox[1], "default-bold-small") 
        GUIEditor.button[1] = guiCreateButton(303, 52, 31, 25, "X", false, GUIEditor.window[1])     
        guiSetVisible(GUIEditor.window[1], false) 
    end 
) 
  
  
addCommandHandler("nodm", 
function() 
guiSetVisible(GUIEditor.window[1], true) 
showCursor(true) 
end 
) 
  
function onGuiClick() 
if (source == GUIEditor.button[1]) then 
guiSetVisible(GUIEditor.window[1], false) 
showCursor(false) 
end 
end 
addEventHandler("onClientGUIClick", root, onGuiClick) 
  
function checkBox() 
    if ( getElementType(source) == "gui-checkbox" ) then 
        if ( guiCheckBoxGetSelected(GUIEditor.checkbox[1])) then 
            setElementData(localPlayer, "invincible", true) 
        else 
           setElementData(localPlayer, "invincible", false) 
        end 
    end 
end 
addEventHandler("onClientGUIClick", root, checkBox, false) 
  
addEventHandler ( "onClientPlayerDamage",localPlayer, 
    function () 
        if getElementData(source,"invincible") then 
            cancelEvent() 
        end 
end) 

"Get busy living or get busy dying"

Posted

As i told many things wrong try this one

GUIEditor = { 
    checkbox = {}, 
    staticimage = {}, 
    label = {}, 
    button = {}, 
    window = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(542, 254, 348, 92, "No Deathmatch Mode", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        GUIEditor.label[1] = guiCreateLabel(10, 25, 283, 15, "You can enable or disable 'No Deathmatch' mode.", false, GUIEditor.window[1]) 
        GUIEditor.staticimage[1] = guiCreateStaticImage(10, 50, 34, 26, "icon.png", false, GUIEditor.window[1]) 
        GUIEditor.checkbox[1] = guiCreateCheckBox(49, 52, 234, 24, "Enable / Disable No Deathmatch Mode", false, false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.checkbox[1], "default-bold-small") 
        GUIEditor.button[1] = guiCreateButton(303, 52, 31, 25, "X", false, GUIEditor.window[1])     
        guiSetVisible(GUIEditor.window[1], false) 
        addEventHandler("onClientGUIClick", GUIEditor.button[1], onGuiClick,false) 
        addEventHandler("onClientGUIClick",GUIEditor.checkbox[1], checkBox, false) 
    end 
) 
  
  
addCommandHandler("nodm", 
function() 
guiSetVisible(GUIEditor.window[1], true) 
showCursor(true) 
end 
) 
  
function onGuiClick() 
guiSetVisible(GUIEditor.window[1], false) 
showCursor(false) 
end 
  
  
function checkBox() 
        if ( guiCheckBoxGetSelected(GUIEditor.checkbox[1])) then 
        setElementData(localPlayer, "invincible", true) 
        else 
        setElementData(localPlayer, "invincible", false) 
    end 
end 
  
  
addEventHandler ( "onClientPlayerDamage",localPlayer, 
    function () 
        if getElementData(source,"invincible") then 
            cancelEvent() 
        end 
end) 

  • Thanks 1

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

One more problem, how I do I prevent players from getting weapons if they have checked "GUIEditor.checkbox[1]"?

"Get busy living or get busy dying"

Posted
One more problem, how I do I prevent players from getting weapons if they have checked "GUIEditor.checkbox[1]"?

explain your problem better

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

The script I made was "No Deathmatch Mode", which gives godmode power to those who tick the checkbox. So I want, for example, if they have enabled "No Deathmatch Mode", and if they try to /wp or something to get weapons, it would give them an error that "Getting weapon in no dm mode isn't allowed".

"Get busy living or get busy dying"

Posted
The script I made was "No Deathmatch Mode", which gives godmode power to those who tick the checkbox. So I want, for example, if they have enabled "No Deathmatch Mode", and if they try to /wp or something to get weapons, it would give them an error that "Getting weapon in no dm mode isn't allowed".

Show me the part where you add the command .

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted
The script I made was "No Deathmatch Mode", which gives godmode power to those who tick the checkbox. So I want, for example, if they have enabled "No Deathmatch Mode", and if they try to /wp or something to get weapons, it would give them an error that "Getting weapon in no dm mode isn't allowed".

Really i don't undrestand what you want exactly Show me the part where you add the command .

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

@Walid,

LOL, you still don't understand me? Well I simply wanted to prevent players from getting weapons if they have getElementData(source, "invincible", true).

So, I just found this in freeroam/fr_server.lua..

function giveMeWeapon(weapon, amount) 
    if weapon > 50 then 
        return 
    end 
    if table.find(getOption('weapons.disallowed'), weapon) then 
        errMsg((getWeaponNameFromID(weapon) or tostring(weapon)) .. 's are not allowed', source) 
    else 
        giveWeapon(source, weapon, amount, true) 
    end 
end 

I edited, and made it like this..

function giveMeWeapon(weapon, amount) 
        if getElementData(source, "invincible", true) then 
         toggleControl (source, "fire", false) 
         toggleControl (source, "next_weapon", false) 
         toggleControl (source, "previous_weapon", false) 
         toggleControl (source, "aim_weapon", false) 
         toggleControl (source, "vehicle_fire", false) 
end 
        if getElementData(source, "invincible", false) then 
         toggleControl (source, "fire", true) 
         toggleControl (source, "next_weapon", true) 
         toggleControl (source, "previous_weapon", true) 
         toggleControl (source, "aim_weapon", true) 
         toggleControl (source, "vehicle_fire", true) 
end 
    if weapon and weapon > 50 then 
        return 
    end 
    if table.find(getOption('weapons.disallowed'), weapon) then 
        errMsg((getWeaponNameFromID(weapon) or tostring(weapon)) .. 's are not allowed', source) 
    else 
        giveWeapon(source, weapon, amount, true) 
    end 
end 

It won't work.

"Get busy living or get busy dying"

Posted

Try this

function giveMeWeapon(weapon, amount) 
    if getElementData(source, "invincible") then  
        outputChatBox(" your message here ",source,255,0,0)  
    return  
    end  
    if weapon > 50 then  
        return 
    end 
    if table.find(getOption('weapons.disallowed'), weapon) then 
        errMsg((getWeaponNameFromID(weapon) or tostring(weapon)) .. 's are not allowed', source) 
    else 
        giveWeapon(source, weapon, amount, true) 
    end 
end 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

Works perfect but if I already have a weapon, then it should also get removed. How can I do that? I tried setPedWeaponSlot(source, 0) but it didn't work so....

"Get busy living or get busy dying"

Posted
Works perfect but if I already have a weapon, then it should also get removed. How can I do that? I tried setPedWeaponSlot(source, 0) but it didn't work so....

Try this

function disableWeaponOnGodMod (prev,new) 
    if getElementData(localPlayer, "invincible") then 
        if getPedWeapon(localPlayer,new) ~= 0 then  
            setPedWeaponSlot(localPlayer, 0) 
        end 
    end  
end 
addEventHandler ( "onClientPlayerWeaponSwitch", getRootElement(), disableWeaponOnGodMod ) 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted
Nope, it doesn't work.

it dosent work because the player is already holding the gun try to switch

you can use this

function disableWeaponOnGodMod (prev,new) 
    if getElementData(localPlayer, "invincible") then 
            setPedWeaponSlot(localPlayer, 0) 
    end 
end 
addEventHandler ( "onClientPlayerWeaponSwitch", localPlayer, disableWeaponOnGodMod ) 

or you can use onClientRender or a timer to check the player weapon slot every time

addEventHandler ( "onClientRender", root, disableWeaponOnGodMod ) 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted
I used onClientRender method, it worked well. Thanks!

np.

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

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