Darad
New Member
- Joined
- Jun 23, 2009
- Messages
- 119
- Reaction score
- 1
Couldn't get it in a mod, so here's some scraps of code!
What does it do?
This script keeps players at a certain level. Creating a max level on your server. For every level they gain over the max they get a point. This points can be used in a shop or whatever you like.
Script includes a talkaction "!getpoints" that will give players a message of how many points they have.
Add this to player table.
levelcap.lua
Add to creaturescripts.xml
Add to login.lua
Add to lib/function.lua
Add to talkactions.xml
talkactions/scripts/getpoints.lua
What does it do?
This script keeps players at a certain level. Creating a max level on your server. For every level they gain over the max they get a point. This points can be used in a shop or whatever you like.
Script includes a talkaction "!getpoints" that will give players a message of how many points they have.
Add this to player table.
Code:
ALTER TABLE players ADD cap_points int(11) DEFAULT 0
levelcap.lua
Lua:
local config = {
levelcap = 100000
}
function onAdvance(cid, skill, oldlevel, newlevel)
if skill == SKILL__LEVEL then
if newlevel > config.levelcap then
doPlayerAddExperience(cid, -(getExperienceForLevel(getPlayerLevel(cid)) - getExperienceForLevel(config.levelcap)))
local points = newlevel - config.levelcap
setPlayerPoints(cid, points)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You gained ' .. points .. ' points.')
return FALSE
end
end
return TRUE
end
Add to creaturescripts.xml
Code:
<event type="advance" name="levelup" script="levelcap.lua"/>
Add to login.lua
Lua:
registerCreatureEvent(cid, "levelup")
Add to lib/function.lua
Lua:
function setPlayerPoints(cid, points)
db.executeQuery("UPDATE `players` SET `cap_points` = `cap_points` +" .. points .. " WHERE `name` = '" .. getPlayerName(cid) .. "'")
end
function getPlayerPoints(cid)
local result = db.getResult("SELECT `cap_points` FROM `players` WHERE `name` = '" .. getPlayerName(cid) .. "'")
return result:getDataInt("cap_points")
end
Add to talkactions.xml
Code:
<talkaction words="!getpoints" event="script" hide="yes" value="getpoints.lua"/>
talkactions/scripts/getpoints.lua
Lua:
function onSay(cid, words, param, channel)
local points = getPlayerPoints(cid)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have " .. points .. " points available.")
return true
end