Jump to content

onPlayerWasted problems


DRW

Recommended Posts

Posted

I'm making a mercenary script, the mercenary has to kill people and get money for it, if he dies, he will lose 2k dollars, but if he has less than that, then he won't lose anything, if it kills, he'll get 1k, if the wasted player has less than 500 dollars, then the wasted player won't lose any money. Now... what's wrong with this? It does not work.

addEventHandler ("onPlayerWasted",getRootElement(),function(killer,weapon,bodypart) 
if killer then 
if getElementData (killer,"hacedm") then 
outputChatBox ("En zonas de DM las recompensas de Mercenario están canceladas.",killer) 
  
return end 
if getElementData (killer,"oficiomercenario") then 
if getPlayerMoney(source)<500 then 
setPlayerMoney (killer,getPlayerMoney(killer)+1000) 
outputChatBox ("¡Has matado a alguien y has recibido 1000$!",killer,255,0,0) 
return end 
local naombre = getPlayerName (source) 
setPlayerMoney (source,getPlayerMoney(source)-500) 
setPlayerMoney (killer,getPlayerMoney(killer)+1000) 
outputChatBox ("¡Has matado a alguien y has recibido 1000$!",killer,255,0,0) 
  
elseif getElementData (source,"oficiomercenario") then 
if getPlayerMoney (source)<2000 then  
setPlayerMoney (killer,getPlayerMoney(killer)+1000) 
return end 
setPlayerMoney (source,getPlayerMoney(source)-2000) 
setPlayerMoney (killer,getPlayerMoney(killer)+1000) 
  
end 
end 
end) 

tJ5zeFm.gif

Proud owner and developer of ZNEXT: Aftermath.

Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience.

Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. 

Español, Pусский, Türk, عربى, Polski, Português

IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB

Posted

It doesn't work? Any errors in debugscript? At least tabulate your code.

addEventHandler ("onPlayerWasted",getRootElement(), 
    function(killer,weapon,bodypart) 
        if killer then 
            if getElementData (killer,"hacedm") then 
                outputChatBox ("En zonas de DM las recompensas de Mercenario están canceladas.",killer) 
                return 
            end 
            if getElementData (killer,"oficiomercenario") then 
                if getPlayerMoney(source)<500 then 
                    setPlayerMoney (killer,getPlayerMoney(killer)+1000) 
                    outputChatBox ("¡Has matado a alguien y has recibido 1000$!",killer,255,0,0) 
                    return 
                end 
                local naombre = getPlayerName (source) 
                setPlayerMoney (source,getPlayerMoney(source)-500) 
                setPlayerMoney (killer,getPlayerMoney(killer)+1000) 
                outputChatBox ("¡Has matado a alguien y has recibido 1000$!",killer,255,0,0) 
          
            elseif getElementData (source,"oficiomercenario") then 
                if getPlayerMoney (source)<2000 then 
                    setPlayerMoney (killer,getPlayerMoney(killer)+1000) 
                    return 
                end 
                setPlayerMoney (source,getPlayerMoney(source)-2000) 
                setPlayerMoney (killer,getPlayerMoney(killer)+1000) 
            end 
        end 
    end 
) 

Give full code.

Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS.

Developer and owner of

https://projectbea.st - Project Beast
Posted
It doesn't work? Any errors in debugscript? At least tabulate your code.
addEventHandler ("onPlayerWasted",getRootElement(), 
    function(killer,weapon,bodypart) 
        if killer then 
            if getElementData (killer,"hacedm") then 
                outputChatBox ("En zonas de DM las recompensas de Mercenario están canceladas.",killer) 
                return 
            end 
            if getElementData (killer,"oficiomercenario") then 
                if getPlayerMoney(source)<500 then 
                    setPlayerMoney (killer,getPlayerMoney(killer)+1000) 
                    outputChatBox ("¡Has matado a alguien y has recibido 1000$!",killer,255,0,0) 
                    return 
                end 
                local naombre = getPlayerName (source) 
                setPlayerMoney (source,getPlayerMoney(source)-500) 
                setPlayerMoney (killer,getPlayerMoney(killer)+1000) 
                outputChatBox ("¡Has matado a alguien y has recibido 1000$!",killer,255,0,0) 
          
            elseif getElementData (source,"oficiomercenario") then 
                if getPlayerMoney (source)<2000 then 
                    setPlayerMoney (killer,getPlayerMoney(killer)+1000) 
                    return 
                end 
                setPlayerMoney (source,getPlayerMoney(source)-2000) 
                setPlayerMoney (killer,getPlayerMoney(killer)+1000) 
            end 
        end 
    end 
) 

Give full code.

The rest of the code has like 400 lines, but there is a part that sets the elementdata "oficiomercenario" to the player, with that should be enough for the player to be able to get the money and all those things, also, no debugscript problems.

tJ5zeFm.gif

Proud owner and developer of ZNEXT: Aftermath.

Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience.

Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. 

Español, Pусский, Türk, عربى, Polski, Português

IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB

Posted

Debug your code.

addEventHandler ("onPlayerWasted",getRootElement(), 
    function(killer,weapon,bodypart) 
        if killer then 
            outputDebugString"killer found" 
            if getElementData (killer,"hacedm") then 
                outputChatBox ("En zonas de DM las recompensas de Mercenario están canceladas.",killer) 
                return 
            end 
            if getElementData (killer,"oficiomercenario") then 
                outputDebugString"mercenary data set for killer" 
                if getPlayerMoney(source)<500 then 
                    setPlayerMoney (killer,getPlayerMoney(killer)+1000) 
                    outputChatBox ("¡Has matado a alguien y has recibido 1000$!",killer,255,0,0) 
                    return 
                end 
                local naombre = getPlayerName (source) 
                setPlayerMoney (source,getPlayerMoney(source)-500) 
                setPlayerMoney (killer,getPlayerMoney(killer)+1000) 
                outputChatBox ("¡Has matado a alguien y has recibido 1000$!",killer,255,0,0) 
          
            elseif getElementData (source,"oficiomercenario") then 
                outputDebugString"data set for killed mercenary" 
                if getPlayerMoney (source)<2000 then 
                    setPlayerMoney (killer,getPlayerMoney(killer)+1000) 
                    outputDebugString"less than 2000 money" 
                    return 
                end 
                setPlayerMoney (source,getPlayerMoney(source)-2000) 
                setPlayerMoney (killer,getPlayerMoney(killer)+1000) 
                outputDebugString"money set" 
            end 
        end 
    end 
) 

Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS.

Developer and owner of

https://projectbea.st - Project Beast
Posted

Got it! Forgot to add totalAmmo behind killer, sorry for bothering you, thanks!

tJ5zeFm.gif

Proud owner and developer of ZNEXT: Aftermath.

Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience.

Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. 

Español, Pусский, Türk, عربى, Polski, Português

IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB

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