Kenix Posted February 24, 2011 Share Posted February 24, 2011 Here's the script when you touch a knife they give you 1 point kill and another 1 point in death. script does not work. function addTabStaticsInfect ( attacker, weapon, bodypart, loss ) if ( weapon == 4 ) then if attacker then if attacker ~= source then -- killer killed victim getElementData(attacker, "kills" + 1) outputChatBox ("1") getElementData(source, "deaths" + 1) outputChatBox ("2") end end end end addEventHandler ( "onPlayerDamage", getRootElement (), addTabStaticsInfect ) Link to comment
proracer Posted February 24, 2011 Share Posted February 24, 2011 Try this.. function addTabStaticsInfect ( attacker, weapon, bodypart, loss ) if weapon == 4 then local getElementKills = getElementData ( attacker, "data.kills" ) or 0 local getElementDeaths = getElementData ( source, "data.deaths" ) or 0 setElementData ( attacker, "data.kills", getElementKills + 1 ) setElementData ( source, "data.deaths", getElementDeaths + 1 ) end end addEventHandler ( "onPlayerDamage", root, addTabStaticsInfect ) Link to comment
Kenix Posted February 24, 2011 Author Share Posted February 24, 2011 Try this.. function addTabStaticsInfect ( attacker, weapon, bodypart, loss ) if weapon == 4 then local getElementKills = getElementData ( attacker, "data.kills" ) or 0 local getElementDeaths = getElementData ( source, "data.deaths" ) or 0 setElementData ( attacker, "data.kills", getElementKills + 1 ) setElementData ( source, "data.deaths", getElementDeaths + 1 ) end end addEventHandler ( "onPlayerDamage", root, addTabStaticsInfect ) I need to use existing elementData kills and deaths. Link to comment
Kenix Posted February 25, 2011 Author Share Posted February 25, 2011 What do you mean? I want this script for a loss of the knife mended point in (getElementData) but the script does not work Link to comment
Moderators Citizen Posted February 25, 2011 Moderators Share Posted February 25, 2011 If you want to keep yours elementData, try this: function addTabStaticsInfect ( attacker, weapon, bodypart, loss ) if attacker then if attacker ~= source then if ( weapon == 4 ) then -- killer killed victim with a knife local playerKills = getElementData(attacker, "kills" ) or 0 local playerDeaths = getElementData(source, "deaths" ) or 0 playerKills = playerKills+1 playerDeaths = playerDeaths+1 setElementData( attacker, "kills", playerKills ) setElementData( source, "deaths", playerDeaths ) outputChatBox( "Killer's kills:"..playerKills.." | player's deaths: "..playerDeaths ) end end end end addEventHandler ( "onPlayerDamage", getRootElement (), addTabStaticsInfect ) It should work I think. EDIT: I tested it and there was an error. Now this script works very well, you juste have to copy-paste Link to comment
proracer Posted February 25, 2011 Share Posted February 25, 2011 It is same as mine ... Link to comment
Castillo Posted February 25, 2011 Share Posted February 25, 2011 It is not, yours uses data.kills, data.deaths as element data, and his use kills and deaths. Link to comment
Kenix Posted February 25, 2011 Author Share Posted February 25, 2011 If you want to keep yours elementData, try this: function addTabStaticsInfect ( attacker, weapon, bodypart, loss ) if attacker then if attacker ~= source then if ( weapon == 4 ) then -- killer killed victim with a knife local playerKills = getElementData(attacker, "kills" ) or 0 local playerDeaths = getElementData(source, "deaths" ) or 0 playerKills = playerKills+1 playerDeaths = playerDeaths+1 setElementData( attacker, "kills", playerKills ) setElementData( source, "deaths", playerDeaths ) outputChatBox( "Killer's kills:"..playerKills.." | player's deaths: "..playerDeaths ) end end end end addEventHandler ( "onPlayerDamage", getRootElement (), addTabStaticsInfect ) It should work I think. EDIT: I tested it and there was an error. Now this script works very well, you juste have to copy-paste it works thank you very much we (: Link to comment
Moderators Citizen Posted February 25, 2011 Moderators Share Posted February 25, 2011 No problem volk-rus ! See you soon 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