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

Frags onlook yourself!

Skillionaire

New Member
Joined
Aug 10, 2013
Messages
20
Reaction score
0
Hello, i want a script that show your frags looking yourself!

I use this one that shows players frags onlook:

function onLook(cid, thing, position, lookDistance)
if isPlayer(thing.uid) then
doPlayerSetSpecialDescription(thing.uid, (getPlayerSex(thing.uid) == 0 and ".\nShe" or ".\nHe") .." has "..getPlayerPoints(thing.uid).." frags and "..getPlayerDeaths(thing.uid).." deaths")
return true
end
return true
end

Please if you can, edit me this script to show yourself frags and players frags.
 
try this:
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 onLogin(cid)
registerCreatureEvent(cid, "fraglook")
return true
end
 
function onLook(cid, thing, position, lookDistance)
if isPlayer(thing.uid) and thing.uid ~= cid then
doPlayerSetSpecialDescription(thing.uid,' [Frags: '..getPlayerFrags(thing.uid)..', Deaths: '..getPlayerDeaths(thing.uid)..']')
return true
elseif thing.uid == cid then
doPlayerSetSpecialDescription(cid,' [Frags: '..getPlayerFrags(cid)..', Deaths: '..getPlayerDeaths(thing.uid)..']')
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
 
Thanks! it works!!

But i want a small script like this:
function onLook(cid, thing, position, lookDistance)
if(thing.uid == cid) then
doPlayerSetSpecialDescription(cid,' [Frags: '..getPlayerPoints(thing.uid)..', Deaths: '..getPlayerDeaths(thing.uid)..']')
return true
end
return true
end

Can you help me editing?
 
Last edited:
Lua:
function onLook(cid, thing, position, lookDistance)
if isPlayer(thing.uid) == false then
return true
end
doPlayerSetSpecialDescription(thing.uid," Frags : ["..getPlayerPoints(thing.uid)..", Deaths: ["..getPlayerDeaths(thing.uid).."]")
return true
end

Idk if it works, give it a try
 
Lua:
function onLook(cid, thing, position, lookDistance)
if isPlayer(thing.uid) == false then
return true
end
doPlayerSetSpecialDescription(thing.uid," Frags : ["..getPlayerPoints(thing.uid)..", Deaths: ["..getPlayerDeaths(thing.uid).."]")
return true
end

Idk if it works, give it a try

It shows only other players frags, it dont show myself frags like: You have X frags and X deaths.
 
try this
Lua:
function onLook(cid, thing, position, lookDistance)
if isPlayer(thing.uid) == false then
return true
end
doPlayerSetSpecialDescription(getPlayerSex(thing.uid) == 0 and ".\nShe" or ".\nHe") .." has "..getPlayerFrags(thing.uid).."frags and "..getPlayerDeaths(thing.uid).." deaths")
return true
end
 
Last edited:
@Cronox

I think you dont understand i want that script to show my frags when i look to myself like: You see yourself. You have X frags and X deaths.

NOT other players frags -> He has X Frags and X deaths <- NOT THIS!
 
Time he are deaD?
Lua:
function onLook(cid, thing, position, lookDistance)
function getDeathsAndKills(cid, type)
	local query,d = db.getResult("SELECT `player_id` FROM "..(tostring(type) == "kill" "`player_deaths`").." 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) == false then
return true
end
doPlayerSetSpecialDescription(getPlayerSex(thing.uid) == 0 and ".\nShe" or ".\nHe") .." has "..getPlayerFrags(thing.uid).."frags and "..getDeathsAndKills(thing.uid).." deaths")
return true
end
 
This is what you are looking for:

Lua:
local function getPlayerKills(cid) -- function by Amir
	local Info = db.getResult("SELECT `frags` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. " LIMIT 1")
	local frags= Info:getDataInt("frags")
		return frags
	end
end

local function getPlayerDeaths(cid) -- function by Amir
	local Info = db.getResult("SELECT `deaths` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. " LIMIT 1")
	local deaths= Info:getDataInt("deaths")
		return deaths
	end
end

function onLook(cid, thing, position, lookDistance)
	local KDR = (getKillsPlayer(thing.uid) / getDeathsPlayer(thing.uid))
	if isPlayer(thing.uid) then
		if cid ~= thing.uid then
			doPlayerSetSpecialDescription(thing.uid, (getPlayerSex(thing.uid) == 0 and "\nShe" or "\nHe") .. " has fragged: [" .. getPlayerKills(thing.uid) .. "] players. " .. (getPlayerSex(thing.uid) == 0 and "\nShe" or "\nHe") .. " has been killed: [" .. getPlayerDeaths(thing.uid) .. "] times.\nKill to Death Ratio: [" .. KDR .. "].")
		else
			doPlayerSetSpecialDescription(thing.uid, "You have fragged: [" .. getPlayerKills(thing.uid) .. "] players. You have died [" .. getPlayerDeaths(thing.uid) .. "] times. \nYour Kill to Death Ratio: [" .. KDR .. "].")
		end
	end
	return true
end
It's untested but should work. I just put it together using bits and pieces I found on the forum. If you have any issues send me a PM.
 
Last edited:
Back
Top