Bilal135 Posted May 17, 2015 Share Posted May 17, 2015 It should give 5xp on player kill, and 10 xp, on headshot. But it won't give any xp. function rewardOnWasted ( ammo, killer, killerweapon, bodypart ) if ( killer ) and ( killer ~= source ) then if bodypart == 9 then triggerServerEvent("addUserEXP", resourceRoot, killer, 10) else triggerServerEvent("addUserEXP", resourceRoot, killer, 5) end end end addEventHandler ( "onPlayerWasted", getRootElement(), rewardOnWasted ) Link to comment
Walid Posted May 17, 2015 Share Posted May 17, 2015 the code is already server side and you are trying to use TriggerServerEvent. ??? Try to use "onClientPlayerWasted" Link to comment
Bilal135 Posted May 17, 2015 Author Share Posted May 17, 2015 Well, I used onClientPlayerWasted, and still doesnt work. function rewardOnWasted ( ammo, killer, killerweapon, bodypart ) if ( killer ) and ( killer ~= source ) then if bodypart == 9 then triggerServerEvent("addUserEXP", resourceRoot, killer, 10) else triggerServerEvent("addUserEXP", resourceRoot, killer, 5) end end end addEventHandler ( "onClientPlayerWasted", getRootElement(), rewardOnWasted ) Link to comment
Bilal135 Posted May 17, 2015 Author Share Posted May 17, 2015 Nevermind, fixed my self. Link to comment
WhoAmI Posted May 17, 2015 Share Posted May 17, 2015 function rewardOnWasted ( killer, _, bodypart ) if ( killer ~= source ) then if bodypart == 9 then triggerServerEvent("addUserEXP", resourceRoot, killer, 10) else triggerServerEvent("addUserEXP", resourceRoot, killer, 5) end end end addEventHandler ( "onClientPlayerWasted", root, rewardOnWasted ) Link to comment
Walid Posted May 17, 2015 Share Posted May 17, 2015 Well, I used onClientPlayerWasted, and still doesnt work. onClientPlayerWasted there is no ammo argument. function rewardOnWasted (killer, weapon, bodypart ) if (killer and isElement(killer) and getElementType(killer) == "player" and killer ~= source ) then if bodypart == 9 then triggerServerEvent("addUserEXP", resourceRoot, killer, 10) else triggerServerEvent("addUserEXP", resourceRoot, killer, 5) end end end addEventHandler ( "onClientPlayerWasted", getLocalPlayer(), rewardOnWasted ) Link to comment
Bilal135 Posted May 17, 2015 Author Share Posted May 17, 2015 Nevermind, fixed my self. btw, onClientPlayerWasted is never safe. Link to comment
Walid Posted May 17, 2015 Share Posted May 17, 2015 what do you mean by this btw, onClientPlayerWasted is never safe. Link to comment
Moderators IIYAMA Posted May 19, 2015 Moderators Share Posted May 19, 2015 He means that clientside code is running on the players their pc, so it is edit able. Yet, I haven't seen any hackers successfully do anything with it. But: Using onPlayerWasted serverside would be more effective because it uses less bandwidth. 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