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

[0.3.6] When you advance to 'x' level you get 'x' crystal coins.

Dymczas

New Member
Joined
Mar 8, 2009
Messages
105
Reaction score
0
Hello Otlanders!
I am looking for this script :
- When you get 30,50,70,90 etc. level, in your backpack appear 'x' crystal coins.
It is possible to do ?
 
Code:
local config = {
	storage = 16839,
	bonus = {
		[50] = 15000,
		[100] = 25000,
		[200] = 50000,
		[300] = 100000,
		[500] = 200000,
		[800] = 300000
	}
}

local function effect(cid)
	if(isPlayer(cid)) then
		doSendMagicEffect(getCreaturePosition(cid), math.random(CONST_ME_FIREWORK_YELLOW, CONST_ME_FIREWORK_BLUE))
	end
	return true
end

function onAdvance(cid, skill, oldLevel, newLevel)
	local t = config.bonus[newLevel]
	if(skill == SKILL__LEVEL and newLevel > oldLevel and t) then
		if(getCreatureStorage(cid, config.storage + newLevel) == EMPTY_STORAGE) then
			doPlayerAddMoney(cid, t)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have gained ".. t .." of gold coins as bonus for level ".. newLevel .."!")
			for i = 1, 10 do
				addEvent(effect, i * 100, cid)
			end
			doCreatureSetStorage(cid, config.storage + newLevel, 1)
		end
	end
	return true
end
 
Could you tell me where i have to paste this script ? Creauturescripts ? And what should i add in .xml file ?
Thanks ;))
 
creaturescripts.xm,l
Code:
<event type="advance" name="MoneyBonus" event="script" value="moneybonus.lua"/>

login,lua;
Code:
registerCreatureEvent(cid, "MoneyBonus")/CODE]
 
Still doesn't work. I get 30 lvl and ,5 cc didn't appear.
It's my moneybonus.lua
PHP:
local config = {
	storage = 16839,
	bonus = {
		[30] = 15000,
		[50] = 25000,
		[70] = 40000,
		[100] = 50000,
		[120] = 60000,
		[800] = 300000
	}
}

local function effect(cid)
	if(isPlayer(cid)) then
		doSendMagicEffect(getCreaturePosition(cid), math.random(CONST_ME_FIREWORK_YELLOW, CONST_ME_FIREWORK_BLUE))
	end
	return true
end

function onAdvance(cid, skill, oldLevel, newLevel)
	local t = config.bonus[newLevel]
	if(skill == SKILL__LEVEL and newLevel > oldLevel and t) then
		if(getCreatureStorage(cid, config.storage + newLevel) == EMPTY_STORAGE) then
			doPlayerAddMoney(cid, t)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have gained ".. t .." of gold coins as bonus for level ".. newLevel .."!")
			for i = 1, 10 do
				addEvent(effect, i * 100, cid)
			end
			doCreatureSetStorage(cid, config.storage + newLevel, 1)
		end
	end
	return true
end

login.lua
PHP:
local config = {
	loginMessage = getConfigValue('loginMessage'),
	useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

function onLogin(cid)
	local loss = getConfigValue('deathLostPercent')
	if(loss ~= nil) then
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
	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, "MoneyBonus")
	registerCreatureEvent(cid, "TopFrags")  
	registerCreatureEvent(cid, "GuildMotd")

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

	registerCreatureEvent(cid, "ReportBug")
	registerCreatureEvent(cid, "AdvanceSave")
	return true
end


function onLogin(cid)
    if(InitHistory == 0) then
        local historyPage = addEvent(historyPage, 60000, {})
        InitHistory = historyPage
    end
    registerCreatureEvent(cid, "PlayerDeath")
    return TRUE
end

function historyPage(parameters)
    local historyPage = addEvent(historyPage, 60000, {})
    if (tonumber(os.date("%d")) ~= getGlobalStorageValue(23456)) then
        setGlobalStorageValue(23456, (tonumber(os.date("%d"))))
        db.executeQuery("UPDATE `players` SET `onlinetime7`=players.onlinetime6, `onlinetime6`=players.onlinetime5, `onlinetime5`=players.onlinetime4, `onlinetime4`=players.onlinetime3, `onlinetime3`=players.onlinetime2, `onlinetime2`=players.onlinetime1, `onlinetime1`=players.onlinetimetoday, `onlinetimetoday`=0;")
        db.executeQuery("UPDATE `players` SET `exphist7`=players.exphist6, `exphist6`=players.exphist5, `exphist5`=players.exphist4, `exphist4`=players.exphist3, `exphist3`=players.exphist2, `exphist2`=players.exphist1, `exphist1`=players.experience-players.exphist_lastexp, `exphist_lastexp`=players.experience;")
    end
    db.executeQuery("UPDATE `players` SET `onlinetimetoday`=players.onlinetimetoday+60, `onlinetimeall`=players.onlinetimeall+60 WHERE `online` = 1;")
end
 
Here's fixed version for TFS 0.4_DEV, sorry guys:
Code:
local config = {
	storage = 16839,
	bonus = {
		[50] = 15,
		[100] = 25,
		[200] = 50,
		[300] = 75,
		[500] = 100,
		[800] = 200
	}
}

local function effect(cid)
	if(isPlayer(cid)) then
		doSendMagicEffect(getCreaturePosition(cid), math.random(CONST_ME_FIREWORK_YELLOW, CONST_ME_FIREWORK_BLUE))
	end
	return true
end

function onAdvance(cid, skill, oldLevel, newLevel)
	local t = config.bonus[newLevel]
	if(skill == SKILL__LEVEL and newLevel > oldLevel and t) then
		if(getCreatureStorage(cid, config.storage + newLevel) == EMPTY_STORAGE) then
			doPlayerAddItem(cid, 2160, t)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have gained ".. t .." crystal coins as bonus for level ".. newLevel .."!")
			for i = 1, 10 do
				addEvent(effect, i * 100, cid)
			end
			doCreatureSetStorage(cid, config.storage + newLevel, 1)
		end
	end
	return true
end

Note: If you want to use it in 0.3.6, you have to replace doCreatureSetStorage and getCreatureStorage with setPlayerStorageValue and getPlayerStorageValue.
 
I don't know why, but on my dedicated server it doesn't work, but on my PC it works. What the hell is going on?
My moneybonus.lua
PHP:
local config = {
	storage = 16839,
	bonus = {
		[30] = 4,
		[50] = 5,
		[70] = 10,
		[100] = 15,
		[150] = 20,
		[200] = 30
	}
}

local function effect(cid)
	if(isPlayer(cid)) then
		doSendMagicEffect(getCreaturePosition(cid), math.random(CONST_ME_FIREWORK_YELLOW, CONST_ME_FIREWORK_BLUE))
	end
	return true
end

function onAdvance(cid, skill, oldLevel, newLevel)
	local t = config.bonus[newLevel]
	if(skill == SKILL__LEVEL and newLevel > oldLevel and t) then
		if(getPlayerStorageValue(cid, config.storage + newLevel) == EMPTY_STORAGE) then
			doPlayerAddItem(cid, 2160, t)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have gained ".. t .." crystal coins as bonus for level ".. newLevel .."!")
			for i = 1, 10 do
				addEvent(effect, i * 100, cid)
			end
			setPlayerStorageValue(cid, config.storage + newLevel, 1)
		end
	end
	return true
end
My login.lua
PHP:
local config = {
	loginMessage = getConfigValue('loginMessage'),
	useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

function onLogin(cid)
	local loss = getConfigValue('deathLostPercent')
	if(loss ~= nil) then
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
	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, "TopFrags")  
	registerCreatureEvent(cid, "GuildMotd")

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

	registerCreatureEvent(cid, "ReportBug")
	registerCreatureEvent(cid, "AdvanceSave")
	registerCreatureEvent(cid, "MoneyBonus") 
	registerCreatureEvent(cid, "10cc")
	return true
end


function onLogin(cid)
    if(InitHistory == 0) then
        local historyPage = addEvent(historyPage, 60000, {})
        InitHistory = historyPage
    end
    registerCreatureEvent(cid, "PlayerDeath")
    return TRUE
end

function historyPage(parameters)
    local historyPage = addEvent(historyPage, 60000, {})
    if (tonumber(os.date("%d")) ~= getGlobalStorageValue(23456)) then
        setGlobalStorageValue(23456, (tonumber(os.date("%d"))))
        db.executeQuery("UPDATE `players` SET `onlinetime7`=players.onlinetime6, `onlinetime6`=players.onlinetime5, `onlinetime5`=players.onlinetime4, `onlinetime4`=players.onlinetime3, `onlinetime3`=players.onlinetime2, `onlinetime2`=players.onlinetime1, `onlinetime1`=players.onlinetimetoday, `onlinetimetoday`=0;")
        db.executeQuery("UPDATE `players` SET `exphist7`=players.exphist6, `exphist6`=players.exphist5, `exphist5`=players.exphist4, `exphist4`=players.exphist3, `exphist3`=players.exphist2, `exphist2`=players.exphist1, `exphist1`=players.experience-players.exphist_lastexp, `exphist_lastexp`=players.experience;")
    end
    db.executeQuery("UPDATE `players` SET `onlinetimetoday`=players.onlinetimetoday+60, `onlinetimeall`=players.onlinetimeall+60 WHERE `online` = 1;")
end

My creaturescripts.xml
PHP:
<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
	<event type="login" name="PlayerLogin" event="script" value="login.lua"/>

	<event type="joinchannel" name="GuildMotd" event="script" value="guildmotd.lua"/>
	<event type="receivemail" name="Mail" event="script" value="mail.lua"/>
	<event type="reportbug" name="SaveReportBug" script="reportbug.lua"/>
	<event type="advance" name="AdvanceSave" event="script" value="advancesave.lua"/>

	<event type="login" name="FirstItems" event="script" value="firstitems.lua"/>
	<event type="think" name="Idle" event="script" value="idle.lua"/>
	<event type="think" name="SkullCheck" event="script" value="skullcheck.lua"/>
	<event type="advance" name="MoneyBonus" event="script" value="moneybonus.lua"/>

      <event type="login" name="SkillStagesLogin" event="script" value="skillstageslogin.lua"/>
      <event type="advance" name="SkillStagesAdvance" event="script" value="skillstagesadvance.lua"/>  
      <event type="kill" name="TopFrags" event="script" value="topfrags.lua"/>
      <event type="advance" name="10cc" event="script" value="10cc.lua"/>

</creaturescripts>
 
Last edited:
Back
Top