• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Someone Fix my script please

darknelson

Member
Joined
Jun 19, 2011
Messages
190
Solutions
1
Reaction score
15
Hi, i recently add into my ot server the rebirth function system, its work nice, but i have onlook description another who count frags.

Anyway the script for my rebirth look is

Code:
function onLook(cid, thing, position, lookDistance)
    if(isPlayer(thing.uid) and thing.uid ~= cid and getCreatureStorage(thing.uid, 85987) ~= -1) then
        doPlayerSetSpecialDescription(thing.uid, (getPlayerSex(thing.uid) == PLAYERSEX_FEMALE and ".\nShe" or ".\nHe") .. " has prestiged " .. getCreatureStorage(thing.uid, 85987) .. " " .. (getCreatureStorage(thing.uid, 85987) == 1 and "time" or "times"))
    elseif(thing.uid == cid and getCreatureStorage(cid, 85987) ~= -1) then
        local message = "You see yourself."
        if(getPlayerFlagValue(cid, PLAYERFLAG_SHOWGROUPINSTEADOFVOCATION)) then
            message = message .. " You are " .. getPlayerGroupName(cid) .. "."
        elseif(getPlayerVocation(cid) ~= 0) then
            message = message .. " You are a " .. getPlayerVocationName(cid):lower() .. "."
        else
            message = message .. " You have no vocation."
        end
        if(getPlayerNameByGUID(getPlayerPartner(cid), false, false) ~= nil) then
            message = message .. " You are " .. (getPlayerSex(cid) == PLAYERSEX_FEMALE and "wife" or "husband") .. " of " .. getPlayerNameByGUID(getPlayerPartner(cid)) .. "."
        end
        if(getPlayerGuildId(cid) > 0) then
            message = message .. " You are " .. (getPlayerGuildRank(cid) == "" and "a member" or getPlayerGuildRank(cid)) .. " of the " .. getPlayerGuildName(cid)
            message = getPlayerGuildNick(cid) ~= "" and message .. " (" .. getPlayerGuildNick(cid) .. ")." or message .. "."
        end
        if(getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEECREATUREDETAILS)) then
            message = message .. "\nHealth: [" .. getCreatureHealth(cid) .. " / " .. getCreatureMaxHealth(cid) .. "], Mana: [" .. getCreatureMana(cid) .. " / " .. getCreatureMaxMana(cid) .. "]."
            message = message .. "\nIP: " .. doConvertIntegerToIp(getPlayerIp(cid)) .. ", Client: " .. getClientVersion(cid) .. "."
        end
        if(getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEEPOSITION)) then
            message = message .. "\nPosition: [X: " .. position.x .. "] [Y: " .. position.y .. "] [Z: " .. position.z .. "]."
        end
        return false, doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, message .. " \nYou have prestiged " .. getCreatureStorage(cid, 85987) .. " " .. (getCreatureStorage(cid, 85987) == 1 and "time." or "times."))
    end
    return true
end


But i think is too much code, and provoke some bugs on console. So i figured i can change my other script, who look on frags and set the global storage value and this is what i got

Code:
function onLook(cid, thing, position, lookDistance)
function getDeathsAndKills(cid, type) -- by vodka
  local query,d = db.getResult("SELECT `player_id` FROM "..(tostring(type) == "kill" and "`player_killers`" or "`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) and thing.uid ~= cid and getCreatureStorage(thing.uid, 85987) ~= -1) then
doPlayerSetSpecialDescription(thing.uid, "\n"..(getPlayerSex(thing.uid) == 0 and "Ella" or "El").." a matado: ["..getDeathsAndKills(thing.uid, "kill").."] Players.\n"..(getPlayerSex(thing.uid) == 0 and "Y" or "Y").." ha muerto: ["..getDeathsAndKills(thing.uid, "death").."] veces")
end
return true
end

i add this part, and doesnt bug the code on run start, but it was impossible to mee add this part on description:
Code:
 if(isPlayer(thing.uid) and thing.uid ~= cid and getCreatureStorage(thing.uid, 85987) ~= -1) then

Code:
" has prestiged " .. getCreatureStorage(thing.uid, 85987) .. " " .. (getCreatureStorage(thing.uid, 85987) == 1 and "time" or "times"))


Must be a rookie issue, please if someone can add it into my second script, i will be greatfull for life :D


Here is the script i use for frag look, on the first time, without any edit

Code:
function onLook(cid, thing, position, lookDistance)
function getDeathsAndKills(cid, type) -- by vodka
   local query,d = db.getResult("SELECT `player_id` FROM "..(tostring(type) == "kill" and "`player_killers`" or "`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) then
doPlayerSetSpecialDescription(thing.uid, "\n"..(getPlayerSex(thing.uid) == 0 and "Ella" or "El").." a matado: ["..getDeathsAndKills(thing.uid, "kill").."] Players.\n"..(getPlayerSex(thing.uid) == 0 and "Y" or "Y").." ha muerto: ["..getDeathsAndKills(thing.uid, "death").."] veces")
end
return true
end
 
Back
Top