Jump to content

Why doesn't this work?


Recommended Posts

function equi() 
    setPedStat(source, 75, 500) 
end 
addEventHandler("onPlayerJoin", root, equi) 
  
addEventHandler ( "onPlayerWasted", root, function ( _, source ) 
    if ( source ) then 
        local current = getPedStat ( source, 75 ) 
        setPedStat ( source, 75, current + 100 ) 
    else return end 
end ) 

Link to comment
function equi() 
    setPedStat(source, 75, 500) 
end 
addEventHandler("onPlayerJoin", root, equi) 
  
addEventHandler ( "onPlayerWasted", root, function ( _, source ) 
    if ( source ) then 
        local current = getPedStat ( source, 75 ) 
        setPedStat ( source, 75, current + 100 ) 
    else return end 
end ) 

The "else return" part is unnecessary since that side of the code is never being executed and would automatically return end if source wasn't true.

Link to comment
@MADEXX It says attempt to perform arithmetic in the line 9. and it says is bad the line 8 too
function equi() 
    setPedStat(source, 75, 500) 
end 
addEventHandler("onPlayerJoin", root, equi) 
  
addEventHandler ( "onPlayerWasted", root, function ( _, source ) 
    if ( source ) then 
        local current = getPedStat ( source, 75 ) 
        local new = current + 100 
        setPedStat ( source, 75, new ) 
    else return end 
end ) 

try this.

Link to comment
@MADEXX It says attempt to perform arithmetic in the line 9. and it says is bad the line 8 too
function equi() 
    setPedStat(source, 75, 500) 
end 
addEventHandler("onPlayerJoin", root, equi) 
  
addEventHandler ( "onPlayerWasted", root, function ( _, source ) 
    if ( source ) then 
        local current = getPedStat ( source, 75 ) 
        local new = current + 100 
        setPedStat ( source, 75, new ) 
    else return end 
end ) 

try this.

It doesn't work yet it gives error in the line of "local current" and "local new". Local new error is arithmetic.

Link to comment
function equi ( ) 
    setPedStat ( source, 75, 500 ) 
end 
addEventHandler ( "onPlayerJoin", root, equi ) 
  
addEventHandler ( "onPlayerWasted", root, 
    function ( _, killer ) 
        if ( killer and getElementType ( killer ) == "player" ) then 
            local current = getPedStat ( killer, 75 ) 
            setPedStat ( killer, 75, ( current + 100 ) ) 
        end 
    end 
) 

Link to comment
function equi() 
    setPedStat(source, 75, 500) 
end 
addEventHandler("onPlayerJoin", root, equi) 
  
function playerDeath(ammo, killer) 
    if (killer) then 
        if (getElementType(killer) == "player") then 
            local old = getPedStat(killer, 75) 
            local new = oldstat + 100 
            setPedStat(killer, 75, new) 
        end 
    end 
end 
addEventHandler("onPlayerWasted", root, playerDeath) 

Try this...

Link to comment
It doesn't work yet. This is what debugscript 3 said me:

Bad argument @ 'getElementType' [Expected element at argument 1, got number '28']

My script has to work, copy it exactly like I posted.

@V.Krumins: That's the same thing as my script.

Link to comment
function equi() 
    setPedStat(source, 75, 500) 
end 
addEventHandler("onPlayerJoin", root, equi) 
  
function playerDeath(ammo, killer) 
    if (killer) then 
        if (getElementType(killer) == "player") then 
            local old = getPedStat(killer, 75) 
            local new = oldstat + 100 
            setPedStat(killer, 75, new) 
        end 
    end 
end 
addEventHandler("onPlayerWasted", root, playerDeath) 

Try this...

oldstat = ?

Link to comment
It doesn't work yet. This is what debugscript 3 said me:

Bad argument @ 'getElementType' [Expected element at argument 1, got number '28']

My script has to work, copy it exactly like I posted.

@V.Krumins: That's the same thing as my script.

Thanks it works! Oh and u know it how to do it also when u kill zombies?

Link to comment

It doesn't work.

addEventHandler ( "onZombieWasted", root, 
    function ( _, killer ) 
        if ( killer and getElementType ( killer ) == "player" ) then 
            local current = getPedStat ( killer, 75 ) 
            setPedStat ( killer, 75, ( current + 100 ) ) 
        end 
    end 
) 
addEvent ("onZombieWasted" 

Link to comment

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