• 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 Function onLogin , onDeath , onKill skull system

Qlimaxowy

New Member
Joined
Jul 3, 2013
Messages
22
Reaction score
3
I want to add that nothing is shown in the console now, you can enter the server.

OTX 2.x Engine
Protocol - 7.6-7.72

Config.lua
useFragHandler = false
worldType = "Hardcore"

How does this system work?
  • After 2 kills - the player gets a white skull permanently.
  • If he logs out and logs in again - the skull remains.
  • The skull cannot be removed by death or loss of PZ (pzone).
  • The number of kills is saved in storage, so it works even after restarting the server.

permanent_skull.lua it data/creaturescripts/scripts/

LUA:
local STORAGE_KILLS = 50000  -- ID storing the number of kills
local STORAGE_PERMA_SKULL = 50001  -- ID storing skull status
local KILL_THRESHOLD = 2  -- Kill count to get permanent white skull

-- A function that assigns a white skull after a kill
function onKill(cid, target, lastHit)
    if isPlayer(cid) and isPlayer(target) then
        local kills = getPlayerStorageValue(cid, STORAGE_KILLS)
        if kills < 0 then kills = 0 end

-- Kill Count Update
        kills = kills + 1
        setPlayerStorageValue(cid, STORAGE_KILLS, kills)

       -- Checks if player has reached kill limit
        if kills >= KILL_THRESHOLD then
            if getPlayerStorageValue(cid, STORAGE_PERMA_SKULL) ~= 1 then
                setPlayerStorageValue(cid, STORAGE_PERMA_SKULL, 1)  -- We mark a player as having a permanent skull
                doCreatureSetSkullType(cid, SKULL_WHITE)  -- Giving the skull a white color
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You got a permanent white skull for 2 kills!")
            end
        end
    end
    return true
end

-- Skull checker after login
function onLogin(cid)
    if getPlayerStorageValue(cid, STORAGE_PERMA_SKULL) == 1 then
        doCreatureSetSkullType(cid, SKULL_WHITE) -- White skull setting after login
    end
    return true
end

Then it records the event in
creaturescripts.xml
XML:
<event type="login" name="PermaSkullLogin" script="permanent_skull.lua"/>
<event type="kill" name="PermaSkullKill" script="permanent_skull.lua"/>

Then it adds the register to
Login.lua
LUA:
registerCreatureEvent(cid, "PermaSkullLogin")
registerCreatureEvent(cid, "PermaSkullKill")

What am I doing wrong?? Who can help me .
Consola + Video
 

Attachments

  • 51C852DC-9CE0-4CB6-918B-DCFCB983491B.webp
    51C852DC-9CE0-4CB6-918B-DCFCB983491B.webp
    28.1 KB · Views: 9 · VirusTotal
Last edited:
If you managed to solve the problem, then post the solution explaining how you did it so others with the same question can benefit. Since you found a solution, share it.
He posted also before and done the same thing by not posting the solution and Highsanta was mad at us that we bullied him(and we didn't)
 
I commented out some lines in player.cpp responsible for skulls.

suddenly when it is solved by me, everyone wants the solution.

there were people who wanted money and not small money...

Is this a requirement that I provide the solution on a plate?
 
Back
Top