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

Action Buy levels

Eazy M

Developer
Joined
Oct 17, 2010
Messages
911
Reaction score
61
Location
.
Hi, i was bored so i created this basic script.

Remove X cash and add X levels.

actions\scripts\buylevels.lua:
Lua:
local config = {
	addLevels = 2,
	costAmount = 15000,
	maxLevel = 300,
}

local bought = {
	boughtMessage = 'You just bought '.. config.addLevels ..' levels for '.. config.costAmount ..' gold coins.',
	cancelMessage = 'You need '.. config.costAmount ..' gold coins to buy '.. config.addLevels.. ' levels.',
	maxlevelMessage = 'You are too high level to use this.',
}

function onUse(cid, item, fromPosition, itemEx, toPosition) -- Rasmus75
if getPlayerLevel(cid) < config.maxLevel then
	if(doPlayerRemoveMoney(cid, config.costAmount)) then
			doPlayerAddLevel(cid, config.addLevels)
			doPlayerSendTextMessage(cid, 27, bought.boughtMessage)
	else
		doPlayerSendTextMessage(cid, 27, bought.cancelMessage)
	end
else
	doPlayerSendTextMessage(cid, 27, bought.maxlevelMessage)
end
	return true
end
actions.xml:
XML:
	<action actionid="41444" event="script" value="buylevels.lua"/>


Remember to change the config.



Rep++? :rolleyes: Post here what you think about the script. Haters gonna hate :$

/R
 
Last edited:
I'm glad to see you're at least learning Lua. This community needs people who are willing to learn new things to support themselves and others.

Good job.
 
Could you make it cost anything else then gold? For example an item? :p Would be really good imo :)
 
Could you make it cost anything else then gold? For example an item? :p Would be really good imo :)

Lua:
local config = {
	addLevels = 2,
	costId = 2160,
	costAmount = 1,
	maxLevel = 300,
}

local bought = {
	boughtMessage = 'You just bought '.. config.addLevels ..' levels.',
	cancelMessage = 'You need XX to buy '.. config.addLevels.. ' levels.', -- change XX lol
	maxlevelMessage = 'You are too high level to use this.',
}

function onUse(cid, item, fromPosition, itemEx, toPosition) -- Rasmus75
if getPlayerLevel(cid) < config.maxLevel then
	if doPlayerRemoveItem(cid, config.costId, config.costAmount) then
			doPlayerAddLevel(cid, config.addLevels)
			doPlayerSendTextMessage(cid, 27, bought.boughtMessage)
	else
		doPlayerSendTextMessage(cid, 27, bought.cancelMessage)
	end
else
	doPlayerSendTextMessage(cid, 27, bought.maxlevelMessage)
end
	return true
end
 
Nice learned a bit of lua from looking at that script too i might use as a item from a quest :) rep++
 
Back
Top