• 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 Rebirth On Look

Trader

New Member
Joined
Aug 12, 2009
Messages
219
Reaction score
2
Hello,

When you double click a player, I want is to say

17:48 You see Dream (Level 8). He is a knight. [Rebirths: 1]

Can anyone help me with this?
I've looked around on forums and found one that doesn't work :/ with one below

Code:
function getPlayerReset(cid) 
        local name = getCreatureName(cid) 
        local Query = db.getResult("SELECT `resets` FROM `players` WHERE `name` = '"..name.."';") 
        return Query:getDataInt("resets") 
end 

function onLook(cid, thing, position, lookDistance) 
    if isPlayer(thing.uid) == false then 
        return true 
    end 
         
    local name = getCreatureName(thing.uid) 
    local level = getPlayerLevel(thing.uid) 
    local sex = getPlayerSex(thing.uid) 
    local vocation = getPlayerVocationName(thing.uid) 
    local resets = getPlayerReset(thing.uid) 
    local gmsg = "" 
    if sex==0 then sex="She" else sex="He" end 
    local msg = "You see "..name.." (Level "..level.."). "..sex.." is a "..vocation..". ["..resets.." resets]." 
    if getPlayerGuildId(thing.uid) > 0 then 
        local gname = getPlayerGuildName(thing.uid) 
        local grank = getPlayerGuildRank(thing.uid) 
        local gnick = getPlayerGuildNick(thing.uid) 
        gmsg = " "..sex.." is "..grank.." of the "..gname.." ("..gnick..")." 
    end 
    local echo = msg .. gmsg 
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, echo) 
     
    return false 
end

Would be great if someone could fix this and tell me where to place it etc,
Thank you very much!
 
remove 'doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, echo)'
and replace 'return false' to
'return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, echo)'
I think that should fix it!
 
Doesn't work :/

Maybe I'm putting the script in the wrong place or edited my XML file wrong. Can you give me a walkthrough :D

That would be awesome :wub:
 
did you register that script on the login.lua file, located in data/creaturescript/scripts/login.lua?
if not, then open the file then scroll down till you see other lines that have something written like this ' registerCreatureEvent(cid, "Look") '<--copy that and paste it with the rest and save.
 
Doesn't give any error's

I'm using TFS 0.3.6 and an NPC that rebirths you
I need the character to show that he/she has 'x' amounts of rebirths but nothing is working so far :/

I did everything you told me to and nothing :(
 
Code:
function getPlayerReset(cid) 
        local name = getCreatureName(cid) 
        local Query = db.getResult("SELECT `resets` FROM `players` WHERE `name` = '"..name.."';") 
        return Query:getDataInt("resets") 
end 

function onLook(cid, thing, position, lookDistance) 
    if isPlayer(thing) == false then 
        return true 
    end 
         
    local name = getCreatureName(thing) 
    local level = getPlayerLevel(thing) 
    local sex = getPlayerSex(thing) 
    local vocation = getPlayerVocationName(thing) 
    local resets = getPlayerReset(thing) 
    local gmsg = "" 
    if sex==0 then sex="She" else sex="He" end 
    local msg = "You see "..name.." (Level "..level.."). "..sex.." is a "..vocation..". ["..resets.." resets]." 
    if getPlayerGuildId(thing.uid) > 0 then 
        local gname = getPlayerGuildName(thing) 
        local grank = getPlayerGuildRank(thing) 
        local gnick = getPlayerGuildNick(thing) 
        gmsg = " "..sex.." is "..grank.." of the "..gname.." ("..gnick..")." 
    end 
    local echo = msg .. gmsg 
     
    return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, echo)  
end
try this, if it does not work and nobody helps you tomorrow then send me a private message and I'll help you extensively but right now I'm tired and going to sleep.
 
Nope, not working
The script is probably fine, maybe I'm doing it wrong somewhere else. Thanks for all the help, I'll PM you tomorrow?

Thanks man :thumbup:
 
Try this functions:
Code:
function getPlayerReset(cid) 
	local value = 1
	local pid = getPlayerGUID(cid)
	local Query = db.getResult("SELECT `resets` FROM `players` WHERE `player_id` = "..pid..";") 
	local id = Query:getID()
	if (player == false) then
		error("Player not found!")
	end
	if (id > 0) then
		value = Query:getDataInt("resets")
	end
	return value		
end
 
afaik you can write something in your sources to add it to player description easily.
But I guess you're using a query in PMA, not storage values, so I can't help you a lot.

Red
 
How can I do it the easy way, screw SQL query
I think it lags up my SQL

And I heard about doing it by storage values also from Cykotitan
 
How can I do it the easy way, screw SQL query
I think it lags up my SQL

And I heard about doing it by storage values also from Cykotitan

Chojrak coded mine, unfortunately for you he's banned off OTland.

Red
 
Yes, Cybershot! You can help me :p

I need a script that tells you how many rebirths a player has when you click on them. The best way would probably be by storage?

Help please? Thanks!
Or can you fix the script I posted?
 
Back
Top