• 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!

Lua attempt to call global 'getPlayerWeapon' (a nil value)

Joined
Jul 25, 2007
Messages
382
Reaction score
38
Lua:
function setDamage(cid, skill, damage)
	local skill = getPlayerSkill(cid, 4)

	local damage = getItemAttack(getPlayerWeapon(cid).uid)
	
	local min = (skill * damage * .09 * 2) * -1
	local max = (skill * damage * .09 * 2) * -1
    return min, max
end

Wrote this for the damage formula of a spell, could anyone help me out?
 
So, if I understood properly,
Your server is printing "attempt to call global 'getPlayerWeapon' (a nil value)"?
In that case, your distribution does NOT have a function that goes by the name "getPlayerWeapon".
It has nothing to do with your damage formula.
 
It does the same thing for my formula using getPlayerMagicLevel(cid). Which I know is there. I'm using TFS 0.2.15. I'm completely mind boggled lol.

Here is an entire spell script.
Lua:
local combat = createCombatObject()

arr = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}






}
local area = createCombatArea(arr)
setCombatArea(combat, area)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_FIREATTACK)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)

function setDamage(cid)
	local skill = getPlayerMagicLevel(cid)
	local min = 50 + (skill * 2) * -1
	local max = 50 + (skill * 1.8) * -1
    return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "setDamage")

function onCastSpell(cid, var)
	return doCombat(cid, combat, var)
end
 
@Limos I got it working thanks

Kind of off-topic but I don't want to make a new thread. I noticed the most recently released subversion is missing some of the functions I've run across. Are these available with w/e is released with donator status? Specifically getItemAttack, getPlayerWeapon?
 
Are you speaking about 0.2.15?
That distribution is a "Stability>Options" type of thing.
You will find much more missing functions than those two.
You may not use mods.
You may not use a "lib" folder.

EDIT: That's AFAIK ofcourse. I do not use 0.2.15, so I may be mislead.
 
Oh, I've haven't been around in a long time so I'm kinda hazy on whats been going on. Which version would you recommend that is "stable" and still has those options, I don't care as long as it's 9.6+
 
Ah super lame. Looks like I'm going to have to cough up the dough because my project is pretty much kaput if I can't create formulas that tie in weapon damage. Thanks for the help man.
 
You still can add weapon damage without those functions.
It just won't be as easy.
I can help you if you want, but not here on the forums.
If you have a Skype, PM me it.
If you don't, make one.
 
Back
Top