• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction In-game !skills playername

Snafu01

New Member
Joined
Oct 14, 2013
Messages
12
Reaction score
1
Offline check added.

Code:
function onSay(cid, words, param, channel)
   if (param == '') then
   doPlayerSendCancel(cid, "You must type !skills playername")
return true
else
   if (isPlayer(getPlayerByNameWildcard(param))) then
     local player = getPlayerByNameWildcard(param)
     local text1 = "[PLAYER INFORMATION]\n \n[ONLINE]\n[HEALTH]: "..getCreatureMaxHealth(player).."/"..getPlayerHeath(player).."\n[MANA]: "..getCreatureMaxMana(player).."/"..getPlayerMana(player).."\n[LEVEL]: "..getPlayerLevel(player).."\n[SKILL MAGIC]: "..getPlayerMagLevel(player).."\n[EXPERIANCE]: "..getPlayerExperience(player).."\n [GUILD]: "..getPlayerGuildName(player).."\n \n[SKILL FIST]: "..getPlayerSkillLevel(player, SKILL_FIST).."\n[SKILL CLUB]: "..getPlayerSkillLevel(player, SKILL_CLUB).."\n[SKILL SWORD]: "..getPlayerSkillLevel(player, SKILL_SWORD).."\n[SKILL AXE]: "..getPlayerSkillLevel(player, SKILL_AXE).."\n[SKILL DISTANCE]: "..getPlayerSkillLevel(player, SKILL_DISTANCE).."\n[SKILL SHIELD]: "..getPlayerSkillLevel(player, SKILL_SHIELD).."\n[SKILL FISHING]: "..getPlayerSkillLevel(player, SKILL_FISHING)
     doShowTextDialog(cid, 2157, text1)
   return true
   else
   if getOfflinePlayerName(getPlayerByNameWildCard(param)) then
     local player = getOfflinePlayerName(getPlayerByNameWildcard(param))
     local text = "[OFFLINE]\n[HEALTH]: "..getOfflinePlayerMaxHeath(player).."/"..getOfflinePlayerHeath(player).."\n[MANA]: "..getOfflinePlayerMaxMana(player).."/"..getOfflinePlayerMana(player).."\n[MAGIC LEVEL]: "..getOfflinePlayerMagLevel(player).."\n[LEVEL]: "..getOfflinePlayerLevel(player).."\n[EXPERIANCE]: "..getOfflinePlayerExperiance(player)
     doShowTextDialog(cid, 2157, text1)
   else
     doPlayerSendCancel(cid, "This is not a player.")
   return false
   end
   end
end
return true
end

You will need these functions in 50-functions or global file.

Code:
function getOfflinePlayerVocation(cid)
local result = db.getResult("SELECT `vocation` FROM `players` WHERE `name` = "..cid)
if result:getID() ~= -1 then
  local vocation = result:getDataInt('vocation')
  return vocation
end
end

function getOfflinePlayerLevel(cid)
local result = db.getResult("SELECT `level` FROM `players` WHERE `name` = "..cid)
if result:getID() ~= -1 then
  local level = result:getDataInt('level')
  return level
end
end

function getOfflinePlayerHeathMax(cid)
local result = db.getResult("SELECT `healthmax` FROM `players` WHERE `name` = "..cid)
if result:getID() ~= -1 then
  local healthmax = result:getDataInt('healthmax')
  return healthmax
end
end

function getOfflinePlayerManaMax(cid)
local result = db.getResult("SELECT `manamax` FROM `players` WHERE `name` = "..cid)
if result:getID() ~= -1 then
  local manamax = result:getDataInt('manamax')
  return manamax
end
end

function getOfflinePlayerExperiance(cid)
local result = db.getResult("SELECT `experience` FROM `players` WHERE `name` = "..cid)
if result:getID() ~= -1 then
  local experience = result:getDataInt('experience')
  return experience
end
end

function getOfflinePlayerMagLevel(cid)
local result = db.getResult("SELECT `maglevel` FROM `players` WHERE `name` = "..cid)
if result:getID() ~= -1 then
  local maglevel = result:getDataInt('maglevel')
  return maglevel
end
end

function getOfflinePlayerMana(cid)
local result = db.getResult("SELECT `mana` FROM `players` WHERE `name` = "..cid)
if result:getID() ~= -1 then
  local mana = result:getDataInt('mana')
  return mana
end
end

function getOfflinePlayerHealth(cid)
local result = db.getResult("SELECT `health` FROM `players` WHERE `name` = "..cid)
if result:getID() ~= -1 then
  local health = result:getDataInt('health')
  return health
end
end

function setPlayerName(cid, name)
local result = db.getResult("INSERT INTO `players` SET `name` = "..name.." WHERE `name` = "..cid)
  return db.executeQuery(query)
end

function getOfflinePlayerName(cid)
local result = db.getResult('SELECT name FROM `players` WHERE `name` ='..cid)
if result:getID() ~= -1 then
  local name = result:getDataString('name')
  return name
end
end

Code:
!skills playername

EDIT: Made it so you can see offline player information. Doesn't show skills though. Also changed the way the script is set up so it is a little nicer
 
Last edited:
That is not how queries work.
Code:
local result = db.getResult('SELECT name, vocation FROM `players` WHERE <CONDITION>')
if result:getID() ~= -1 then
  -- get your values
  local name = result:getDataString('name')
  local voc = result:getDataInt('vocation')
else
  -- query failed, no data
end

Also remember to escape data you insert into query strings, even if it is only a talkaction it can be abused by corrupt gms etc.
 
Back
Top