• 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 Dead Show

Ghazer

Member
Joined
Mar 13, 2009
Messages
350
Reaction score
6
I would like whenlook player show many deads and frags the player has


I have that for frags
Code:
local function getPlayerFrags(cid)
    local time = os.time()
    local times = {today = (time - 86400), week = (time - (7 * 86400))}

    local contents, result = {day = {}, week = {}, month = {}}, db.getResult("SELECT `pd`.`date`, `pd`.`level`, `p`.`name` FROM `player_killers` pk LEFT JOIN `killers` k ON `pk`.`kill_id` = `k`.`id` LEFT JOIN `player_deaths` pd ON `k`.`death_id` = `pd`.`id` LEFT JOIN `players` p ON `pd`.`player_id` = `p`.`id` WHERE `pk`.`player_id` = " .. getPlayerGUID(cid) .. " AND `k`.`unjustified` = 1 AND `pd`.`date` >= " .. (time - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC")
    if(result:getID() ~= -1) then
        repeat
            local content = {date = result:getDataInt("date")}
            if(content.date > times.today) then
                table.insert(contents.day, content)
            elseif(content.date > times.week) then
                table.insert(contents.week, content)
            else
                table.insert(contents.month, content)
            end
        until not result:next()
        result:free()
    end

    local size = {
        day = table.maxn(contents.day),
        week = table.maxn(contents.week),
        month = table.maxn(contents.month)
    }

    return size.day + size.week + size.month
end        
function onLook(cid, thing, position, lookDistance)
if isPlayer(thing.uid) then
doPlayerSetSpecialDescription(thing.uid, (getPlayerSex(thing.uid) == 0 and ".\nShe" or ".\nHe") .." has "..getPlayerFrags(thing.uid).." frags")
return true
end
end
 
dont like your script /:
is better this and short :p
Lua:
function onLook(cid, thing, position, lookDistance)
	if isPlayer(thing.uid) then
		doPlayerSetSpecialDescription(thing.uid, (getPlayerSex(thing.uid) == 0 and ".\nShe" or ".\nHe") .." has "..getPlayerFrags(thing.uid).." frags")	
	end
	return true
end
 
Ghazer, i think that the "show many deads's counter" isn't possible to make it, why not you use a script then this:
Lua:
function onLook(cid, thing, position, lookDistance)
if isPlayer(thing.uid) and getCreatureOutfit(thing.uid).lookType ~= 526 then
doPlayerSetSpecialDescription(thing.uid, (getPlayerSex(thing.uid) == 0 and "" or "") ..". Resident of "..getTownName(getPlayerTown(thing.uid)).."")
return true
end
return true
end
It shows the player's residence, example:
You see Ghazer. He is a sorcerer. Resident of Thais.

Also you can make a script with the frags and the player resident ! It's very nice
 
Ofc its possible todo and its pretty easy too, all you have to do is when someone is killed a table in your mysql will be updated and then at your look function you just make it check that table
 
Ghazer, i think that the "show many deads's counter" isn't possible to make it, why not you use a script then this:
Lua:
function onLook(cid, thing, position, lookDistance)
if isPlayer(thing.uid) and getCreatureOutfit(thing.uid).lookType ~= 526 then
doPlayerSetSpecialDescription(thing.uid, (getPlayerSex(thing.uid) == 0 and "" or "") ..". Resident of "..getTownName(getPlayerTown(thing.uid)).."")
return true
end
return true
end
It shows the player's residence, example:
You see Ghazer. He is a sorcerer. Resident of Thais.

Also you can make a script with the frags and the player resident ! It's very nice

What does this have anything to do what the OP requested? He wants to show frags & player deaths.. not their residency..

However @ the OP you shouldn't use sql queries because people with bots can flood the database. The way I would do it is setting storages on player kills & deaths and using onLook and getPlayerStorage to pull the numbers.
 
Synthetic is right. Do this:

if a player dies
set that player's storage value (ex 8000) to 1 more
if that player was pked
then set the pker's storave value (ex 8001) to 1 more

then, all you have to do is get the storage value (8000, and 8001) for that player to see how often he has been pked and how often he has pked some1. TADA!
 
like this? your scripts edited ;)
creaturescripts.xml
Lua:
<event type="login" name="registered" event="script" value="newlook.lua"/>
<event type="look" name="newlook" event="script" value="newlook.lua"/>
creaturescripts/scripts/newlook.lua
Lua:
function  getPlayerFrags(cid)
    local time = os.time()
    local times = {today = (time - 86400), week = (time - (7 * 86400))}
 
    local contents, result = {day = {}, week = {}, month = {}}, db.getResult("SELECT `pd`.`date`, `pd`.`level`, `p`.`name` FROM `player_killers` pk LEFT JOIN `killers` k ON `pk`.`kill_id` = `k`.`id` LEFT JOIN `player_deaths` pd ON `k`.`death_id` = `pd`.`id` LEFT JOIN `players` p ON `pd`.`player_id` = `p`.`id` WHERE `pk`.`player_id` = " .. getPlayerGUID(cid) .. " AND `k`.`unjustified` = 1 AND `pd`.`date` >= " .. (time - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC")
    if(result:getID() ~= -1) then
        repeat
            local content = {date = result:getDataInt("date")}
            if(content.date > times.today) then
                table.insert(contents.day, content)
            elseif(content.date > times.week) then
                table.insert(contents.week, content)
            else
                table.insert(contents.month, content)
            end
        until not result:next()
        result:free()
    end
 
    local size = {
        day = table.maxn(contents.day),
        week = table.maxn(contents.week),
        month = table.maxn(contents.month)
    } 
    return size.day + size.week + size.month
end 
 
function onLook(cid, thing, position, lookDistance)
    if isPlayer(thing.uid) and thing.uid ~= cid then
        doPlayerSetSpecialDescription(thing.uid,'\n[Lv: '..getPlayerLevel(thing.uid)..'] [Frags: '..getPlayerFrags(thing.uid)..']')
    end
    return true
end
 
function onLogin(cid)
    registerCreatureEvent(cid, "newlook")
    return true
end
 
Back
Top