Jump to content

toggle on/off


villr

Recommended Posts

i got a code here,its serversided but i want make a toogle for it but idk how i gonna make it.

anybody that can help me?

function damageCheck(attacker, weapon) 
    local playeraccount = getPlayerAccount ( attacker ) 
    if ( playeraccount ) and not isGuestAccount(playeraccount) then 
    if getAccountData ( playeraccount, "carshow" ) then 
        if(weapon == 5)then 
        setElementPosition(source,1891.14,-1881.70,13.47) 
    else 
      
    end 
    end 
    end 
    end 
    addEventHandler( "onPlayerDamage", getRootElement(), damageCheck ) 
  

Link to comment
function damageCheck(attacker, weapon) 
local playeraccount = getPlayerAccount ( attacker ) 
    if ( playeraccount ) and not isGuestAccount(playeraccount) then 
        if getAccountData ( playeraccount, "carshow" ) then 
            if(weapon == 5)then 
                  setElementPosition(source,1891.14,-1881.70,13.47) 
            else 
            end 
        end 
    end 
end 
  
local dmg = false 
  
function toggleDMG (thePlayer) 
    if (dmg == false) then 
        addEventHandler( "onPlayerDamage", root, damageCheck ) 
    else 
        removeEventHandler( "onPlayerDamage", root, damageCheck ) 
    end 
end 
bindKey ( element, "F1", "down", toggleDMG ) 
  

change element to the player you want bindKey for him or any way you will use you can edit the code..

Link to comment
function damageCheck(attacker, weapon) 
local playeraccount = getPlayerAccount ( attacker ) 
    if ( playeraccount ) and not isGuestAccount(playeraccount) then 
        if getAccountData ( playeraccount, "carshow" ) then 
            if(weapon == 5)then 
                  setElementPosition(source,1891.14,-1881.70,13.47) 
            else 
            end 
        end 
    end 
end 
  
local dmg = false 
  
function toggleDMG (thePlayer) 
    if (dmg == false) then 
        addEventHandler( "onPlayerDamage", root, damageCheck ) 
    else 
        removeEventHandler( "onPlayerDamage", root, damageCheck ) 
    end 
end 
bindKey ( element, "F1", "down", toggleDMG ) 
  

change element to the player you want bindKey for him or any way you will use you can edit the code..

dident work to turn it off,error : line:98 addEventHandler: 'onPlayerDamage' with this function is already handled

Link to comment
function damageCheck(attacker, weapon) 
local playeraccount = getPlayerAccount ( attacker ) 
    if ( playeraccount ) and not isGuestAccount(playeraccount) then 
        if getAccountData ( playeraccount, "carshow" ) then 
            if(weapon == 5)then 
                  setElementPosition(source,1891.14,-1881.70,13.47) 
            else 
            end 
        end 
    end 
end 
  
local dmg = false 
  
function toggleDMG (thePlayer) 
    if (dmg == false) then 
        addEventHandler( "onPlayerDamage", root, damageCheck ) 
        dmg = true 
    else 
        dmg = false  
        removeEventHandler( "onPlayerDamage", root, damageCheck ) 
    end 
end 
bindKey ( element, "F1", "down", toggleDMG ) 

He omitted to make dmg actually change. But you could have easily fixed this yourself, although I guess it's easier to say "pls help"

Link to comment
function damageCheck(attacker, weapon) 
local playeraccount = getPlayerAccount ( attacker ) 
    if ( playeraccount ) and not isGuestAccount(playeraccount) then 
        if getAccountData ( playeraccount, "carshow" ) then 
            if(weapon == 5)then 
                  setElementPosition(source,1891.14,-1881.70,13.47) 
            else 
            end 
        end 
    end 
end 
  
local dmg = false 
  
function toggleDMG (thePlayer) 
    if (dmg == false) then 
        addEventHandler( "onPlayerDamage", root, damageCheck ) 
        dmg = true 
    else 
        dmg = false  
        removeEventHandler( "onPlayerDamage", root, damageCheck ) 
    end 
end 
bindKey ( element, "F1", "down", toggleDMG ) 

He omitted to make dmg actually change. But you could have easily fixed this yourself, although I guess it's easier to say "pls help"

thank you.

yea but im not so good on this parts of scripting so how could i know it? ...

Link to comment
function damageCheck(attacker, weapon) 
if not ( attacker ) then return end 
local playeraccount = getPlayerAccount ( attacker ) 
    if ( playeraccount ) and not isGuestAccount(playeraccount) then 
        if getAccountData ( playeraccount, "carshow" ) then 
            if(weapon == 5)then 
                  setElementPosition(source,1891.14,-1881.70,13.47) 
            else 
            end 
        end 
    end 
end 
  
local dmg = false 
  
function toggleDMG (thePlayer) 
    if (dmg == false) then 
        addEventHandler( "onPlayerDamage", root, damageCheck ) 
        dmg = true 
    else 
        dmg = false 
        removeEventHandler( "onPlayerDamage", root, damageCheck ) 
    end 
end 
bindKey ( element, "F1", "down", toggleDMG ) 

Link to comment
function damageCheck(attacker, weapon) 
if not ( attacker ) then return end 
local playeraccount = getPlayerAccount ( attacker ) 
    if ( playeraccount ) and not isGuestAccount(playeraccount) then 
        if getAccountData ( playeraccount, "carshow" ) then 
            if(weapon == 5)then 
                  setElementPosition(source,1891.14,-1881.70,13.47) 
            else 
            end 
        end 
    end 
end 
  
local dmg = false 
  
function toggleDMG (thePlayer) 
    if (dmg == false) then 
        addEventHandler( "onPlayerDamage", root, damageCheck ) 
        dmg = true 
    else 
        dmg = false 
        removeEventHandler( "onPlayerDamage", root, damageCheck ) 
    end 
end 
bindKey ( element, "F1", "down", toggleDMG ) 

thank you TAPL this works very fine you're my hero xD

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