• 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 Skull systems for frag rank TFS 1.2

War-Ots

New Member
Joined
Feb 17, 2016
Messages
29
Reaction score
2
Hello on more time

I know alot of people have asked things like that and I have already read their post and cound not find a solution for me so here it is:
in login.lua on function onLogin(player) I tried to add something like this to test if the skulls were setted correctly, but when I log in nothing happens
Code:
    local frags = player:getStorageValue(fragStor)
    print("say elo"..frags.."in if")
                        if frags >= 3 and frags < 4 then
                        player:setSkull(SKULL_YELLOW)
                    elseif frags >= 5  and frags < 6 then
                        player:setSkull(SKULL_GREEN)
                    elseif frags >= 7 and frags < 8 then
                        player:setSkull(SKULL_WHITE)
                    elseif frags >= 9 and frags < 10 then
                        player:setSkull(SKULL_RED)
                    elseif frags > 11 then
                        player:setSkull(SKULL_BLACK)
            end
(added the prints to see if frags were counted correctly and yes they were)

Then I tried to do it on onKill function and I did something like this:

Code:
.
more code
.
local frags = player:getStorageValue(fragStor)
print("see frags"..frags.."end print frags)
if frags <100 then
print("entered inside of if")
player:setSkull(SKULL_GREEN)
print("leaving if)
end
.
.
more code

Every prints were donne correctly but nothing happens, I am afraid that function setSkull is not working or I am not using it correctly.

Any help? Thanks!
 
It don't work like that; You need to set skull time, or modify sources to just load skull ignoring time.
 
I added this skullTimer and I have an error
Code:
data/creaturescripts/scripts/login.lua:onLogin
data/creaturescripts/scripts/login.lua:5: attempt to call method 'setSkullTimer' (a nil value)
stack traceback:
        [C]: in function 'setSkullTimer'
        data/creaturescripts/scripts/login.lua:5: in function <data/creaturescripts/scripts/login.lua:1>
seems it cant be used
 
Updated!!

Code:
local frags = player:getStorageValue(fragStor)
    print("say elo"..frags.."in if")
                        if frags >= 3 and frags < 4 then
                        player:setSkull(SKULL_YELLOW)
            player:setSkullTime(-1)
            print("teste1")
                    elseif frags >= 5  and frags < 6 then
                        player:setSkull(SKULL_GREEN)
            player:setSkullTime(-1)
            print("teste2")
                    elseif frags >= 7 and frags < 8 then
                        player:setSkull(SKULL_WHITE)
            player:setSkullTime(-1)
            print("teste3")
                    elseif frags >= 9 and frags < 10 then
                        player:setSkull(SKULL_RED)
            player:setSkullTime(-1)
            print("teste4")
                    elseif frags > 11 then
                        player:setSkull(SKULL_BLACK)
            player:setSkullTime(-1)
            print("teste5")
            end

Did this, prints are donne correctly but, nothing happens again, player still have no skull.
Any Ideia?
 
It's setSkullTime(value), hmm this way would work as well, but requires you to update player's skull on login/think or just set skull time for 10 year.
 
Code:
local skulls = {
    [{3,4}] = SKULL_YELLOW,
    [{5,6}] = SKULL_GREEN,
    [{7,8}] = SKULL_WHITE,
    [{9,10}] = SKULL_RED,
    [{10, 1000}] = SKULL_BLACK
    }
   
local fragStor = 100000
local refreshTimer = 60000

function giveSkull(p)
    local player = Player(p)
    local frags = player:getStorageValue(fragStor)
    for pos, val in ipairs(skulls) do
        if frags >= pos[1] and frags <= pos[2] then
            player:setSkull(val)
            player:setSkullTimer(refreshTimer+1000)
            addEvent(giveSkull, refreshTimer, p)
        end
    end
end
try this
 
It is giving me errors I am have tried alot of way.. ah and by the way its player:setSkullTime(refreshTimer+1000) not player:setSkullTimer(refresTimer+1000) ^^

Soon I will post here new ways I tried and my error's, but still if any have new ideias tell me here! :)
 
Not sure if this is what you want, but try this script. It uses @Zothion function and it's executed onKill, check the script before test, I wrote in on phone so I'm sure it might not work cuz I always mess up XD
Test this:

Code:
local function giveSkull(p)
    local skulls = {
    [{3,4}] = SKULL_YELLOW,
    [{5,6}] = SKULL_GREEN,
    [{7,8}] = SKULL_WHITE,
    [{9,10}] = SKULL_RED,
    [{10, 1000}] = SKULL_BLACK
    }

    local fragStor = 100000
    local refreshTimer = 60000
    local player = Player(p)
    local frags = player:getStorageValue(fragStor)
    for pos, val in pairs(skulls) do
        if frags >= pos[1] and frags <= pos[2] then
            player:setSkull(val)
            player:setSkullTime(refreshTimer+1000)
            addEvent(giveSkull, refreshTimer, p)
        end
    end
end

function onKill(cid, target, lastHit)
    if not target:isPlayer() then
        print("TEST: target is not player")
    return true
    end

    giveSkull(player:getGuid())
    print("TEST: script executed?")
return true
end

P.S: don't forget to remove the prints if the script works :p
 
i dont think it will work with giveSkull(player:getGuid()) afaik, needs to be giveSkull(player:getId()), since Player(player:getGuid()) doesnt give userdata
 
Found what was wrong. I turned my server to PVP and the last script I made worked. When server is PVP-E it dont work, skulls are not given to the players.

Any ideas to solve this problem? Maybe I need to change something in sources, but where?
 
does frag count on pvp-e? then that is the problem
Well not sure but I have a script that when I look a player it says the frags it have so I guess it is counting 16:28 You see Bumm (Level 665). He is a master sorcerer. Kills: 19 Deaths: 32

But I think that the problem is in the souces, I guess that exists a function that if(!world_type_pvp) return (so it does not give a skull to a player) but I am not sure where but I guess I saw it once
 
Update

When my char dies it losses all equipments and revive with 40 hp (black skull punishments) so it is giving the skull but it is not showing up the skull
 
are you using the standard 1.2 dist from github?
edit: yeah, it seems like it doesnt work setting skull on pvp-e with lua
 
Last edited:
I need to change something in sources but I dont know where... Can someone tell me? Ussualy I know hot to do my changes bu my problem is to find where they should be donne...
 
Well not sure but I have a script that when I look a player it says the frags it have so I guess it is counting 16:28 You see Bumm (Level 665). He is a master sorcerer. Kills: 19 Deaths: 32

But I think that the problem is in the souces, I guess that exists a function that if(!world_type_pvp) return (so it does not give a skull to a player) but I am not sure where but I guess I saw it once
This does not require a source edit if it is for 1.2, you just need to modify onLook in events to display kills and deaths.
 
Back
Top