villr Posted October 3, 2011 Share Posted October 3, 2011 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
TAPL Posted October 3, 2011 Share Posted October 3, 2011 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
villr Posted October 3, 2011 Author Share Posted October 3, 2011 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
BinSlayer1 Posted October 3, 2011 Share Posted October 3, 2011 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
villr Posted October 3, 2011 Author Share Posted October 3, 2011 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
villr Posted October 3, 2011 Author Share Posted October 3, 2011 the script works but it does outpout this errors sometimes, server.lua:83: bad argument @ 'getPlayerAccount' excepted element at argument1,got nil Link to comment
TAPL Posted October 3, 2011 Share Posted October 3, 2011 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
villr Posted October 3, 2011 Author Share Posted October 3, 2011 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 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