• 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 Skull System

seleo

Active Member
Joined
Jun 6, 2012
Messages
498
Reaction score
33
Location
Egypt
hello
im using this script as a skull system configuration in my server

Code:
local storage = 9000
 
function onKill(cid, target, lastHit)
	if isPlayer(target) and cid ~= target then
		local frags = math.max(0, getCreatureStorage(cid, storage)) + 1
		setPlayerStorageValue(cid, storage, frags)
		if frags >= 50 then
			doCreatureSetSkullType(cid, SKULL_GREEN)
		elseif frags >= 100 then
			doCreatureSetSkullType(cid, SKULL_WHITE)
		elseif frags >= 200 then
			doCreatureSetSkullType(cid, SKULL_YELLOW)
		elseif frags >= 400 then
			doCreatureSetSkullType(cid, SKULL_RED)
		elseif frags >= 500 then
			doCreatureSetSkullType(cid, SKULL_BLACK)
		end
	end
	return true
end

the problem is when player dies or logout he lost his skull
anyone knows how i can fix that ?
 
LUA:
local frags = getPlayerStorageValue(cid, 9000)
        if frags >= 50 then
            doCreatureSetSkullType(cid, SKULL_GREEN)
        elseif frags >= 100 then
            doCreatureSetSkullType(cid, SKULL_WHITE)
        elseif frags >= 200 then
            doCreatureSetSkullType(cid, SKULL_YELLOW)
        elseif frags >= 400 then
            doCreatureSetSkullType(cid, SKULL_RED)
        elseif frags >= 500 then
            doCreatureSetSkullType(cid, SKULL_BLACK)
        end

creaturescripts/login.lua
 
Last edited:
That should work for all of them now on login, I just woke up. Don't even have my glasses on, I'll be back after I have a cup of coffee if things aren't working.
 
alright i will test it now

- - - Updated - - -

Server Crashed :D
isnt there anyway to save the storage when the players logs out and in ?
 
Do you have this block in login.lua?
LUA:
    if(config.useFragHandler) then
        registerCreatureEvent(cid, "SkullCheck")
    end

& useFragHandler = true set in config.lua?

& this should be your skullcheck.lua:
LUA:
function onThink(cid, interval)
    if(not isCreature(cid)) then
        return
    end

    local skull, skullEnd = getCreatureSkull(cid), getPlayerSkullEnd(cid)
    if(skullEnd > 0 and skull > SKULL_WHITE and os.time() > skullEnd and not getCreatureCondition(cid, CONDITION_INFIGHT)) then
        doPlayerSetSkullEnd(cid, 0, skull)
    end
end
 
this is my login.lua file
Code:
local config = {
	loginMessage = getConfigValue('loginMessage'),
	useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}


function onLogin(cid)
	local loss = getConfigValue('deathLostPercent')
	if(loss ~= nil) then
	if getPlayerName(cid) ~= "Account Manager" then
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
		doPlayerAddBlessing(cid, 1)
		doPlayerAddBlessing(cid, 2)
		doPlayerAddBlessing(cid, 3)
		doPlayerAddBlessing(cid, 4)
		doPlayerAddBlessing(cid, 5)
		doPlayerAddPremiumDays(cid, 2)
		doPlayerSetPromotionLevel(cid, 1)
	end
end

	local accountManager = getPlayerAccountManager(cid)
	if(accountManager == MANAGER_NONE) then
		local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
		if(lastLogin > 0) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
			str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
		else
			str = str .. " Please choose your outfit."
			doPlayerSendOutfitWindow(cid)
		end

		doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
	elseif(accountManager == MANAGER_NAMELOCK) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
	elseif(accountManager == MANAGER_ACCOUNT) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
	end

	if(not isPlayerGhost(cid)) then
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
	end

	registerCreatureEvent(cid, "Mail")
	registerCreatureEvent(cid, "GuildMotd")

	registerCreatureEvent(cid, "Idle")
	if(config.useFragHandler) then
		registerCreatureEvent(cid, "SkullCheck")
	end

	registerCreatureEvent(cid, "ReportBug")
	registerCreatureEvent(cid, "AdvanceSave")
	registerCreatureEvent(cid, "FragReward")
	registerCreatureEvent(cid, "firstitems")
	registerCreatureEvent(cid, "ZombieAttack")
	registerCreatureEvent(cid, "lol")
	registerCreatureEvent(cid, "SullSystem")

	return true
end

and thats my skullcheck file

Code:
function onThink(cid, interval)
	if(not isCreature(cid)) then
		return
	end

	local skull, skullEnd = getCreatureSkull(cid), getPlayerSkullEnd(cid)
	if(skullEnd > 0 and skull > SKULL_WHITE and os.time() > skullEnd and not getCreatureCondition(cid, CONDITION_INFIGHT)) then
		doPlayerSetSkullEnd(cid, 0, skull)
	end
end
 
im using fraghandler
and the skull system script working good
but the problem is when the player logs out he losses the skull
is there anyway to save that ?
 
this is my login.lua file
Code:
local config = {
	loginMessage = getConfigValue('loginMessage'),
	useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}


function onLogin(cid)
	local loss = getConfigValue('deathLostPercent')
	if(loss ~= nil) then
	if getPlayerName(cid) ~= "Account Manager" then
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
		doPlayerAddBlessing(cid, 1)
		doPlayerAddBlessing(cid, 2)
		doPlayerAddBlessing(cid, 3)
		doPlayerAddBlessing(cid, 4)
		doPlayerAddBlessing(cid, 5)
		doPlayerAddPremiumDays(cid, 2)
		doPlayerSetPromotionLevel(cid, 1)
	end
end

	local accountManager = getPlayerAccountManager(cid)
	if(accountManager == MANAGER_NONE) then
		local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
		if(lastLogin > 0) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
			str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
		else
			str = str .. " Please choose your outfit."
			doPlayerSendOutfitWindow(cid)
		end

		doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
	elseif(accountManager == MANAGER_NAMELOCK) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
	elseif(accountManager == MANAGER_ACCOUNT) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
	end

	if(not isPlayerGhost(cid)) then
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
	end

	registerCreatureEvent(cid, "Mail")
	registerCreatureEvent(cid, "GuildMotd")

	registerCreatureEvent(cid, "Idle")
	if(config.useFragHandler) then
		registerCreatureEvent(cid, "SkullCheck")
	end

	registerCreatureEvent(cid, "ReportBug")
	registerCreatureEvent(cid, "AdvanceSave")
	registerCreatureEvent(cid, "FragReward")
	registerCreatureEvent(cid, "firstitems")
	registerCreatureEvent(cid, "ZombieAttack")
	registerCreatureEvent(cid, "lol")
	registerCreatureEvent(cid, "SullSystem")

	return true
end

and thats my skullcheck file

Code:
function onThink(cid, interval)
	if(not isCreature(cid)) then
		return
	end

	local skull, skullEnd = getCreatureSkull(cid), getPlayerSkullEnd(cid)
	if(skullEnd > 0 and skull > SKULL_WHITE and os.time() > skullEnd and not getCreatureCondition(cid, CONDITION_INFIGHT)) then
		doPlayerSetSkullEnd(cid, 0, skull)
	end
end

Maybe it is SkullSystem and not SullSystem:
registerCreatureEvent(cid, "SullSystem")
 
thanks for seeing that
but its already Sullsystem in my creatureevents.xml file

Code:
	<event type="kill" name="SullSystem" event="script" value="skull.lua"/>
 
Back
Top