Jump to content

Little Problem


Recommended Posts

Posted

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 ) 

"Get busy living or get busy dying"

Posted

the code is already server side and you are trying to use TriggerServerEvent. ???

Try to use "onClientPlayerWasted"

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

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 ) 

"Get busy living or get busy dying"

Posted
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 ) 

Posted
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 ) 

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

what do you mean by this

btw, onClientPlayerWasted is never safe.

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

  • Moderators
Posted

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.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

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