Jump to content

[HELP]Reward On Kill a ped


Recommended Posts

Posted

Hello, Im trying to make if you kill a ped they give to you some money, But...

Server:

addEventHandler ( "onPedWasted", root, function ( _, killer ) givePlayerMoney ( killer, 2000 ) end ) 

WARNING:rewardonkill\server.lua:1:Bad Argument @ 'givePlayerMoney'

And No money For me...

Some help please? thanks ! :D

Posted

you can check wiki :

function rewardOnWasted ( ammo, killer, killerweapon, bodypart ) 
    --if there is a killer, and that killer is not the same person as whoever died 
    if ( killer ) and ( killer ~= source ) then  
        givePlayerMoney ( killer, 1000 ) --reward the killer with 1000 cash. 
    end 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), rewardOnWasted ) - 

Check if you have defined killer ammo and that stuff.

Posted

Solid bro, Thats the code did you send me on skype But there is the error on debugscript, In a simple view i dont saw errors :c, help? thanks all

EDIT:

if i change givePlayerMoney For outputChatBox("lol") if you kill a ped the lol appear,Thats is strange

Posted

Works fine here.

addEventHandler ( "onPedWasted", root, 
    function ( _, killer ) 
        if ( getElementType ( killer ) == "player" ) then 
            givePlayerMoney ( killer, 2000 ) 
        end 
    end 
) 

Posted
addEventHandler ( "onPedWasted", root, 
    function ( ammo, killer, killerweapon, bodypart ) 
        if ( killer ) and ( killer ~= source ) then 
            givePlayerMoney ( killer, 2000 ) 
        end 
    end 
) 

try this

Posted
addEventHandler ( "onPedWasted", root, 
    function ( ammo, killer, killerweapon, bodypart ) 
        if ( killer ) and ( killer ~= source ) then 
            givePlayerMoney ( killer, 2000 ) 
        end 
    end 
) 

try this

Doesnt Work Bro, ;S

Posted
addEventHandler ( "onPedWasted", root, 
    function ( _, killer ) 
        if ( killer ) and ( getElementType ( killer ) == "player" ) then 
            givePlayerMoney ( killer, 2000 ) 
        end 
    end 
) 

'killer' returns false because the ped probably died not killed, so try this one.

Posted

Or if i made it clientside like:

client:

    addEventHandler ( "onPedWasted", root, 
        function ( _, killer ) 
            if ( getElementType ( killer ) == "player" ) then 
                triggerServerEvent ( "onPedReward", getLocalPlayer() ) 
            end 
        end 
    ) 

server:

    function reward( ) 
        givePlayerMoney ( localPlayer, 2000 ) 
    end 
    addEvent( "onPedReward", true ) 
    addEventHandler("onPedReward", root , reward)  

Posted
addEvent ( "onBotWasted", true ) 
addEventHandler ( "onBotWasted", root, 
    function ( _, killer ) 
        if ( getElementType ( killer ) == "player" ) then 
            givePlayerMoney ( killer, 2000 ) 
        end 
    end 
) 

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