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

Solved [c++]or [lua] tfs 0.4 Skulls yellow, green, white, red, etc

Felipe93

Ghost Member
Joined
Mar 21, 2015
Messages
1,990
Solutions
9
Reaction score
334
Location
Chile
Hello Otland

Well i have edited my source(player.cpp) to avoid get yellow skull or white in case you attack someone
also removed the condition of get red after x ammount of player kills and its working good

PS: you can check the changes in player.cpp or the lines that i have omitted searching for //WAR

https://ghostbin.com/paste/779ku
also im using this lua script to simulate the skull by range system
Lua:
local storage = 4321
function onKill(cid, target)
    local frags = getPlayerStorageValue(cid, storage)
    if(isPlayer(target)) then
        setPlayerStorageValue(cid, storage, frags+1)
        if(frags < 2) then
            doCreatureSetSkullType(cid, SKULL_YELLOW)
        elseif(frags < 4) then
            doCreatureSetSkullType(cid, SKULL_GREEN)
        elseif(frags < 6) then
            doCreatureSetSkullType(cid, SKULL_WHITE)
        elseif(frags > 7) then
            doCreatureSetSkullType(cid, SKULL_RED)
        end
    end
    return true
end

the issue that im having is that player are loosing skull when they log out or if they die

can someone provide me an script to avoid lost on log out?

cheers
 
Solution
@Felipe93
I don't think you will need this one: frag_reset_ondeath.lua
Só, change the skull_login.lua to:

Lua:
local storage = 4321
function onLogin(cid)
    local frags = getPlayerStorageValue(cid, storage)
    if(isPlayer(cid)) then
        if(frags == 1) then
            doCreatureSetSkullType(cid, SKULL_YELLOW)
        elseif(frags >= 2 and frags <= 4) then
            doCreatureSetSkullType(cid, SKULL_GREEN)
        elseif(frags >= 5 and frags <= 6) then
            doCreatureSetSkullType(cid, SKULL_WHITE)
        elseif(frags => 7) then
            doCreatureSetSkullType(cid, SKULL_RED)
        end
    end
    return true
end

And change skull_rewards.lua to:

Lua:
local storage = 4321
function onKill(cid, target)
    local...
if i do it onlogin won't affect the remove skull on death?
i found this but its not working ofc bcause its for tfs 1.2

Code:
local condition = createConditionObject(CONDITION_INFIGHT)
setConditionParam(condition, CONDITION_PARAM_TICKS, 3000)

function onLogin(cid)
player = Player(cid)
    if player:getStorageValue(4321) == 4 then
    doAddCondition(cid, condition)
        addEvent(function()player:setSkull(SKULL_YELLOW) end, 1300)
        end
    return true
end
EDIT
.....
PS: i understand now what u meant to tell me guys and i did this
Code:
local storage = 4321
function onLogin(cid)
    local frags = getPlayerStorageValue(cid, storage)
    if(isPlayer(target)) then
        setPlayerStorageValue(cid, storage, frags+1)
        if(frags < 2) then
            doCreatureSetSkullType(cid, SKULL_YELLOW)
        elseif(frags < 4) then
            doCreatureSetSkullType(cid, SKULL_GREEN)
        elseif(frags < 6) then
            doCreatureSetSkullType(cid, SKULL_WHITE)
        elseif(frags > 7) then
            doCreatureSetSkullType(cid, SKULL_RED)
        end
    end
    return true
end

EDITED
 
Last edited:
Your server is to lose the skull when dead and reset the frags? If so, onLogin will not affect that, if you put to check the frags when player login.
If don't, just remove the skull and keep the frags, well, I think will affect, because the player still have the frags, so the skull will be back.
 
Your server is to lose the skull when dead and reset the frags? If so, onLogin will not affect that, if you put to check the frags when player login.
If don't, just remove the skull and keep the frags, well, I think will affect, because the player still have the frags, so the skull will be back.
you do not have to add this part:
setPlayerStorageValue(cid, storage, frags+1)
I mean, this part will add one "kill" every login :p
okey guys i followed both ideas and its working but the skull is not being displayed instantly after log in the skull is displayed after the first kill and its no resseting storages, because if a char dies with example skull green when he comes back and kill another player he instantly gains the latest storaged skull that in this example was green.. what could be missing? a frag remover on die? on login
what could be done in this case? i have the server on if you wanna check what's going on because i don't explain myself in the best way i know
EDIT
PS : I ADDED A FRAG REMOVER ONDEATH BUT ITS NOT WORKING when players dies they loose its skull but when they come back and kill a player they instantly recieve the latest skull that they lost and not the first skull that they should gain
Code:
function onDeath(cid, corpse, deathList)
    if isPlayer(cid) then
        for i = 1, #deathList do
            if isPlayer(deathList[i]) then
                db.executeQuery("UPDATE `killers` SET `unjustified` = 0 WHERE `id` IN (SELECT `kill_id` FROM `player_killers` WHERE `player_id` = " .. getPlayerGUID(cid) .. ")")
                break
            end
        end
    end
    
    return true
end

regards
 
Last edited:
@Felipe93
Look at my comment in the script
Lua:
local storage = 4321
function onLogin(cid)
    local frags = getPlayerStorageValue(cid, storage)
    if(isPlayer(target)) then -- did you changed this part to 'cid' after the test?
        setPlayerStorageValue(cid, storage, frags+1)
        if(frags < 2) then
            doCreatureSetSkullType(cid, SKULL_YELLOW)
        elseif(frags < 4) then -- and here will cause conflite, because you said if have less than 4 frags, the skull is yellow, so, if you have 1 frag, can be yellow too. You need to put like: elseif(frags > 2 and frags < 4) then
            doCreatureSetSkullType(cid, SKULL_GREEN)
        elseif(frags < 6) then -- here too
            doCreatureSetSkullType(cid, SKULL_WHITE)
        elseif(frags > 7) then
            doCreatureSetSkullType(cid, SKULL_RED)
        end
    end
    return true
end
 
@Felipe93
Look at my comment in the script
Lua:
local storage = 4321
function onLogin(cid)
    local frags = getPlayerStorageValue(cid, storage)
    if(isPlayer(target)) then -- did you changed this part to 'cid' after the test?
        setPlayerStorageValue(cid, storage, frags+1)
        if(frags < 2) then
            doCreatureSetSkullType(cid, SKULL_YELLOW)
        elseif(frags < 4) then -- and here will cause conflite, because you said if have less than 4 frags, the skull is yellow, so, if you have 1 frag, can be yellow too. You need to put like: elseif(frags > 2 and frags < 4) then
            doCreatureSetSkullType(cid, SKULL_GREEN)
        elseif(frags < 6) then -- here too
            doCreatureSetSkullType(cid, SKULL_WHITE)
        elseif(frags > 7) then
            doCreatureSetSkullType(cid, SKULL_RED)
        end
    end
    return true
end
nope i didn't ill test it now, thanks

now that i did that , the players are not loosing their skull when they log in or either when they die
@gabriel28
 
@Felipe93
So, what left now? Lose the skull when die? If so, you can make onDeath script to set the storage value to 0, so the player will need kill again to get the skulls back.
 
lost skull on die
something like this should work?

Code:
local storage = 4321
function onDeath(cid)
    local frags = getPlayerStorageValue(cid, storage)
    if(isPlayer(cid)) then -- did you changed this part to 'cid' after the test?
        setPlayerStorageValue(cid, storage, frags+0)  -- changed 1 to 0
        if(frags < 2) then
            doCreatureSetSkullType(cid, SKULL_YELLOW)
        elseif(frags < 4) then
            doCreatureSetSkullType(cid, SKULL_GREEN)
        elseif(frags < 6) then
            doCreatureSetSkullType(cid, SKULL_WHITE)
        elseif(frags > 7) then
            doCreatureSetSkullType(cid, SKULL_RED)
        end
    end
    return true
end
@gabriel28
 
@Felipe93
Something like that:
Code:
local storage = 4321
function onDeath(cid)
    if(isPlayer(cid)) then
        setPlayerStorageValue(cid, storage, 0)
    end
return true
end

So, in total, you will need 3 creatureevents.
onKill to incress the storage value every time the player kill another player.
onLogin to check the storage value and set the skull to don't lose after logout.
onDeath to set the storage to 0, so the player will don't recieve any skulls when login, only when reach the storage needed.
 
@Felipe93
Something like that:
Code:
local storage = 4321
function onDeath(cid)
    if(isPlayer(cid)) then
        setPlayerStorageValue(cid, storage, 0)
    end
return true
end

So, in total, you will need 3 creatureevents.
onKill to incress the storage value every time the player kill another player.
onLogin to check the storage value and set the skull to don't lose after logout.
onDeath to set the storage to 0, so the player will don't recieve any skulls when login, only when reach the storage needed.
ill test hopefully this will be finally working, thanks
 
Okey its working but its not reseting the skull 100% its resets the skull to yellow skull
im using 4 scripts the ones that you guys gave me
creaturescripts.xml
Code:
<event type="death" name="WarSkull" event="script" value="remove_skull_die.lua"/>
    <event type="login" name="SkullLogin" event="script" value="skull_login.lua"/>
    <event type="death" name="FragReset" event="script" value="frag_reset_ondeath.lua"/>
    <event type="kill" name="SkullReward" event="script" value="skull_rewards.lua"/>
login.lua
Code:
registerCreatureEvent(cid, "WarSkull")
    registerCreatureEvent(cid, "SkullLogin")
    registerCreatureEvent(cid, "FragReset")
    registerCreatureEvent(cid, "SkullReward")

remove_skull_die.lua

Code:
local storage = 4321
function onDeath(cid)
    if(isPlayer(cid)) then
        setPlayerStorageValue(cid, storage, 0)
    end
return true
end

skull_login.lua
Code:
local storage = 4321
function onLogin(cid)
    local frags = getPlayerStorageValue(cid, storage)
    if(isPlayer(cid)) then -- did you changed this part to 'cid' after the test?
        setPlayerStorageValue(cid, storage, frags+1)
        if(frags < 0) then
            doCreatureSetSkullType(cid, SKULL_NONE) --- i added that because i thought it was going to help me to remove to the storage to the skull_none (it doesn't worked)
        elseif(frags < 2) then
            doCreatureSetSkullType(cid, SKULL_YELLOW)
        elseif(frags < 4) then
            doCreatureSetSkullType(cid, SKULL_GREEN)
        elseif(frags < 6) then
            doCreatureSetSkullType(cid, SKULL_WHITE)
        elseif(frags > 7) then
            doCreatureSetSkullType(cid, SKULL_RED)
        end
    end
    return true
end

frag_reset_ondeath.lua
Code:
function onDeath(cid, corpse, deathList)
    if isPlayer(cid) then
        for i = 1, #deathList do
            if isPlayer(deathList[i]) then
                db.executeQuery("UPDATE `killers` SET `unjustified` = 0 WHERE `id` IN (SELECT `kill_id` FROM `player_killers` WHERE `player_id` = " .. getPlayerGUID(cid) .. ")")
                break
            end
        end
    end
    
    return true
end
skull_rewards.lua
Code:
local storage = 4321
function onKill(cid, target)
    local frags = getPlayerStorageValue(cid, storage)
    if(isPlayer(target)) then
        setPlayerStorageValue(cid, storage, frags+1)
        if(frags < 2) then
            doCreatureSetSkullType(cid, SKULL_YELLOW)
        elseif(frags < 4) then
            doCreatureSetSkullType(cid, SKULL_GREEN)
        elseif(frags < 6) then
            doCreatureSetSkullType(cid, SKULL_WHITE)
        elseif(frags > 7) then
            doCreatureSetSkullType(cid, SKULL_RED)
        end
    end
    return true
end

what could be missing or wrong in the lua scripts?


thanks a lot for the help guys this is the first time that im pretty near to achieve this into old tfs
 
@Felipe93
I don't think you will need this one: frag_reset_ondeath.lua
Só, change the skull_login.lua to:

Lua:
local storage = 4321
function onLogin(cid)
    local frags = getPlayerStorageValue(cid, storage)
    if(isPlayer(cid)) then
        if(frags == 1) then
            doCreatureSetSkullType(cid, SKULL_YELLOW)
        elseif(frags >= 2 and frags <= 4) then
            doCreatureSetSkullType(cid, SKULL_GREEN)
        elseif(frags >= 5 and frags <= 6) then
            doCreatureSetSkullType(cid, SKULL_WHITE)
        elseif(frags => 7) then
            doCreatureSetSkullType(cid, SKULL_RED)
        end
    end
    return true
end

And change skull_rewards.lua to:

Lua:
local storage = 4321
function onKill(cid, target)
    local frags = getPlayerStorageValue(cid, storage)
    if(isPlayer(target)) then
        setPlayerStorageValue(cid, storage, frags+1)
        if(frags == 1) then
            doCreatureSetSkullType(cid, SKULL_YELLOW)
        elseif(frags >= 2 and frags <= 4) then
            doCreatureSetSkullType(cid, SKULL_GREEN)
        elseif(frags >= 5 and frags <= 6) then
            doCreatureSetSkullType(cid, SKULL_WHITE)
        elseif(frags => 7) then
            doCreatureSetSkullType(cid, SKULL_RED)
        end
    end
    return true
end
 
Solution
LOL IM compiling with new source editions, let me test your editions without the source editions hopefully it will works :D
thanks mate
Code:
    pzLocked = false;
            if(skull < SKULL_YELLOW)//WAR  //ANTES ERA SKULL_RED
                if (skull < SKULL_GREEN)
                    if (skull < SKULL_WHITE)
                        if (skull < SKULL_RED)
                setSkull(SKULL_NONE);

            g_game.updateCreatureSkull(this);
            break;
        }
 
[1:22:40.864] >>> Loading creaturescripts... [Error - LuaInterface::loadFile] data/creaturescripts/scripts/skull_login.lua:11: ')' expected near '='
[1:22:40.870] [Error - Event::checkScript] Cannot load script (data/creaturescripts/scripts/skull_login.lua)
[1:22:40.873] data/creaturescripts/scripts/skull_login.lua:11: ')' expected near '='
with the newest lua files
@gabriel28
 
Back
Top