• 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 Script error

Bassam421

Lockout RPG/PVP Owner
Joined
Nov 8, 2008
Messages
359
Reaction score
7
Location
Sweden , Göteborg
[18/12/2012 17:31:04] [Error - CreatureScript Interface]
[18/12/2012 17:31:04] data/creaturescripts/scripts/honor.lua:eek:nLogin
[18/12/2012 17:31:04] Description:
[18/12/2012 17:31:04] data/creaturescripts/scripts/honor.lua:3: attempt to call global 'getPlayerhonor_points' (a nil value)
[18/12/2012 17:31:04] stack traceback:
[18/12/2012 17:31:04] data/creaturescripts/scripts/honor.lua:3: in function <data/creaturescripts/scripts/honor.lua:1>

And i'm using this script
Lua:
function onLogin(cid)
    registerCreatureEvent(cid, "honorlook")
     doPlayerSendTextMessage(cid, 19, "You have ".. getPlayerhonor_points(cid) .." honor's.")
    return true
end
function onLook(cid, thing, position, lookDistance)
    if isPlayer(thing.uid) and thing.uid ~= cid then
        doPlayerSetSpecialDescription(cid,'[Honor: '..getPlayerhonor_points(cid)..']')
        return true
    elseif thing.uid == cid then
        doPlayerSetSpecialDescription(cid,'[Honor: '..getPlayerhonor_points(cid)..']')
        local string = 'You see yourself.'
        if getPlayerFlagValue(cid, PLAYERFLAG_SHOWGROUPINSTEADOFVOCATION) then
            string = string..' You are '.. getPlayerGroupName(cid) ..'.'
        elseif getPlayerVocation(cid) ~= 0 then
            string = string..' You are '.. getPlayerVocationName(cid) ..'.'
        else
            string = string..' You have no vocation.'
        end
        string = string..getPlayerSpecialDescription(cid)..''
        if getPlayerNameByGUID(getPlayerPartner(cid), false, false) ~= nil then
            string = string..' You are '.. (getPlayerSex(cid) == 0 and 'wife' or 'husband') ..' of '.. getPlayerNameByGUID(getPlayerPartner(cid)) ..'.'
        end
        if getPlayerGuildId(cid) > 0 then 
            string = string..' You are ' .. (getPlayerGuildRank(cid) == '' and 'a member' or getPlayerGuildRank(cid)) ..' of the '.. getPlayerGuildName(cid)
            string = getPlayerGuildNick(cid) ~= '' and string..' ('.. getPlayerGuildNick(cid) ..').' or string..'.'
        end 
        if getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEECREATUREDETAILS) then
            string = string..'nHealth: ['.. getCreatureHealth(cid) ..' / '.. getCreatureMaxHealth(cid) ..'], Mana: ['.. getCreatureMana(cid) ..' / '.. getCreatureMaxMana(cid) ..'].'
            string = string..'nIP: '.. doConvertIntegerToIp(getPlayerIp(cid)) ..'.'
        end
        if getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEEPOSITION) then
            string = string..'nPosition: [X:'.. position.x..'] [Y:'.. position.y..'] [Z:'.. position.z..'].'
        end
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, string)  
        return false
    end
    return true
end
how do i do so it looks in the database for the player honor? i have a table called honor_points in my database
 
Last edited:
Lua:
function onLook(cid, thing, position, lookDistance)
function getHonorPoints(cid, type)
	local query,d = db.getResult("SELECT `player_id` FROM "..(tostring(type) == "kill" and "`honor_points`").." WHERE `player_id` = "..getPlayerGUID(cid)),0
		if (query:getID() ~= -1) then 
			repeat
				d = d+1
			until not query:next()
			query:free()
		end
	return d  
end
if isPlayer(thing.uid) then
doPlayerSetSpecialDescription(thing.uid, "\n"..(getPlayerSex(thing.uid) == 0 and "She" or "He").." has "..getHonorPoints(thing.uid, "kill").." honor points.\n")
end
return true
end -- Naaano201

Test it ...
 
Lua:
function onLook(cid, thing, position, lookDistance)
function getHonorPoints(cid, type)
	local query,d = db.getResult("SELECT `player_id` FROM "..(tostring(type) == "kill" and "`honor_points`").." WHERE `player_id` = "..getPlayerGUID(cid)),0
		if (query:getID() ~= -1) then 
			repeat
				d = d+1
			until not query:next()
			query:free()
		end
	return d  
end
if isPlayer(thing.uid) then
doPlayerSetSpecialDescription(thing.uid, "\n"..(getPlayerSex(thing.uid) == 0 and "She" or "He").." has "..getHonorPoints(thing.uid, "kill").." honor points.\n")
end
return true
end -- Naaano201

Test it ...

18:08 You see yourself. You are ranger.[Reborn: 0], and no errors in console
 
Depending on the version that extra description wont work if you look on yourself.
 
Back
Top