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.

YOU HAVE TO TRUST SOMEONE TO BE BETRAYED.I NEVER DID

Posted

What does "killer" return?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

It's quite obvious what he's trying to do: when a player kills a ped, give the player money.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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 
) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

try this

YOU HAVE TO TRUST SOMEONE TO BE BETRAYED.I NEVER DID

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.

F4MZM4.gif

Posted

The script I posted works perfectly fine, I tested it on my local server.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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 
) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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