• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

Spell Costing Health

Lightning Blade

BETA Tester
I was bored and though of the class expire wanted to make, and i though of the health cost, and it found a way to do it.



I will admit this is not the best way to do it, but it's not the worst either :S.

UPDATE: i tried another way too.



IMPORTANT: BOTH SCRIPTS ARE UN TESTED.
 
Last edited:

Rochet2

Moderator / Eluna Dev
The second script wont work due to rather obvious reasons ;3
(IE; player not defined outside of the function)
 

Mathias

Exalted Member
I would guess this is how rochet2 ment it should be now they all can use player:
Code:
function HealthCostingSpell(event, player, spell, spellcheck)    
local SpellID = 100 -- Spell ID
local damage = 1000
local caster = spell:GetCaster()  
local spell = spell:GetEntry()    
local health = player:GetHealth()    
local healthCost = health - damage


        if(spell == SpellID) then
             player:DealDamage(player, healthCost)
end
end

- - - Updated - - -

Also i think the rules says that you should test the scripts first
 

Foereaper

Founder
You are calling player outside the function whenever you try to localize a variable outside of the function by using a player method.
 

Tommy

Founder
I corrected your script, since the variables were kinda pointless since you don't have but only one place to use them. Also, if you look at the server hook on "PLAYER_EVENT_ON_SPELL_CAST", the spell variable is pushing the actual spell class, not the spellId. Also, you can't use the same variable names.

Code:
function HealthCostingSpell(event, player, spell, spellcheck)
   if(spell:GetEntry() == 10000) then -- Change SpellId
       player:DealDamage(player, player:GetHealth() - 1000) -- Possible fail if the player's health isn't over 1000 since we're using - 1000?
   end
end

You should test your script before releasing;

Anyways they should work. ^^

Isn't the words of a tester. XD

Nonetheless, thanks for trying and sharing.
 
Last edited:

Tommy

Founder
Well your code didn't work whatsoever, so it would be irrelevant if someone gave you thanks for bad code. No need to be mad, you have to learn to test everything before releasing.
 

Lightning Blade

BETA Tester
I'm not mad at all, and my first script should work. Indeed i have to learn. But nothing is worse than releasing something trying to learn and then, someone who is top expert whos making the lua engine gets the credits. But whatever, thanks for fixing the code.
 
Top