• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Global formula/string (8.6 TFS)

FYzx

New Member
Joined
Jan 2, 2015
Messages
7
Reaction score
2
Well this is something simple. For a bunch of weapons and spells I'm making I use the same damage calculation formula for all of them with very slight tweaks. So can I somehow make that formula a global string?

I've tried making it a function in 050-function.lua
Code:
function onGetDamage(cid, level, skill, attack, factor)
  min = - ((1 + getPlayerSkillLevel(cid, 4)/100) * 0.5
  max = min * 2
  return min, max
end

and then simply using in the weapons
Code:
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetDamage")

but it doesn't work. Well it actually does work, but for only one weapon; all other weapons return this error:
Code:
Warning: [CallBack::loadCallBack] Event onGetDamage not found.

Is this possible or am I wasting my time?

Thanks in advance.
 
Every callback for the combat should have it's own function, so just add the functions in the weapon Lua script.
 
I realize that. My question is: is there no way of making it so every weapon shares the same function? For example, by making the formula a global string or something along those lines?

I ask because if I have 20+ weapons using the same function and I want to make a tiny tweak I'd have to go through every one of them making that tiny modification which I assume will get very annoying later on.
 
You could make an extra function, use the parameters from that function and let it return the min, max, so you have the extra function inside the callback function.
 
Back
Top