DRW Posted July 27, 2015 Share Posted July 27, 2015 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) Link to comment
GTX Posted July 27, 2015 Share Posted July 27, 2015 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. Link to comment
DRW Posted July 28, 2015 Author Share Posted July 28, 2015 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. Link to comment
GTX Posted July 28, 2015 Share Posted July 28, 2015 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 ) Link to comment
DRW Posted July 28, 2015 Author Share Posted July 28, 2015 Got it! Forgot to add totalAmmo behind killer, sorry for bothering you, thanks! Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now