• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

CreatureEvent [Advanced] Player points system, Reset System

Joined
Apr 17, 2008
Messages
1,922
Solutions
1
Reaction score
188
Location
Venezuela
Hello, here i'm releasing my newest script, Player Points System.

If you have played Mu-Online, then you know what i'm talking about. (This system works only with player max health, player max mana, weapon attack-defense)

These sytem contains a talk-action and creature-script. You can found the Talkaction Script Here -> http://otland.net/f81/advanced-player-points-system-reset-system-36131/#post364933

First of all, execute this with SQL if you have not done it yet.
Code:
ALTER TABLE `players` ADD `points` INT( 11 ) NOT NULL DEFAULT '0';
ALTER TABLE `players` ADD `resets` INT( 11 ) NOT NULL DEFAULT '0';

Then, add this to data/lib/function.lua if you have not done it yet.
Lua:
function getPlayerPoints(cid)
local Info = db.getResult("SELECT `points` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. " LIMIT 1")
	local p = Info:getDataInt("points")
	Info:free()
	return p
end

function doPlayerAddPoints(cid, points)
    local dif = getPlayerPoints(cid) + points
    if dif >= 0 then
        db.executeQuery("UPDATE `players` SET `points` = `points` + " .. points .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";")
        return TRUE
    end
    return FALSE
end

function doPlayerRemovePoints(cid, points)
    local dif = getPlayerPoints(cid) - points
    if dif >= 0 then
        db.executeQuery("UPDATE `players` SET `points` = `points` - " .. points .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";")
        return TRUE
    end
    return FALSE
end

function resetPlayer(cid, newLevel, newExp, newMag, newCap, newHealth, newMaxHealth, newMana, newMaxMana, newSex, posX, posY, posZ)

local playerGUID = getPlayerGUID(cid)

local skill =
{
	fist = getPlayerSkillLevel(cid, SKILL_FIST),
	club = getPlayerSkillLevel(cid, SKILL_CLUB),
	sword = getPlayerSkillLevel(cid, SKILL_SWORD),
	axe = getPlayerSkillLevel(cid, SKILL_AXE),
	distance = getPlayerSkillLevel(cid, SKILL_DISTANCE),
	shielding = getPlayerSkillLevel(cid, SKILL_SHIELD),
	fishing = getPlayerSkillLevel(cid, SKILL_FISHING)
}

	doRemoveCreature(cid)
	db.executeQuery("UPDATE `players` SET `level` = " .. newLevel .. ", `health` = " .. newHealth .. ", `healthmax` = " .. newMaxHealth .. ", `experience` = " .. newExp .. ", `maglevel` = " .. newMag .. ", `mana` = " .. newMana .. ", `manamax` = " .. newMaxMana .. ", `posx` = " .. posX .. ", `posy` = " .. posY .. ", `posz` = " .. posZ .. ", `cap` = " .. newCap .. ", `sex` = " .. newSex .. ", `resets` = `resets` + 1 WHERE `id` = " .. playerGUID .. ";")
	db.executeQuery("UPDATE `player_skills` SET `value` = " .. (skill.fist / 2) .. ", `count` = 0 WHERE `skillid` = 0 and `player_id` = " .. playerGUID .. ";")
	db.executeQuery("UPDATE `player_skills` SET `value` = " .. (skill.club / 2) .. ", `count` = 0 WHERE `skillid` = 1 and `player_id` = " .. playerGUID .. ";")
	db.executeQuery("UPDATE `player_skills` SET `value` = " .. (skill.sword / 2) .. ", `count` = 0 WHERE `skillid` = 2 and `player_id` = " .. playerGUID .. ";")
	db.executeQuery("UPDATE `player_skills` SET `value` = " .. (skill.axe / 2) .. ", `count` = 0 WHERE `skillid` = 3 and `player_id` = " .. playerGUID .. ";")
	db.executeQuery("UPDATE `player_skills` SET `value` = " .. (skill.distance / 2) .. ", `count` = 0 WHERE `skillid` = 4 and `player_id` = " .. playerGUID .. ";")
	db.executeQuery("UPDATE `player_skills` SET `value` = " .. (skill.shielding / 2) .. ", `count` = 0 WHERE `skillid` = 5 and `player_id` = " .. playerGUID .. ";")
	db.executeQuery("UPDATE `player_skills` SET `value` = " .. (skill.fishing / 2) .. ", `count` = 0 WHERE `skillid` = 6 and `player_id` = " .. playerGUID .. ";")
end

Later, create a file in creaturescripts and add this:
Lua:
local levelLimit = 400
local time = 30 --in seconds

function onAdvance(cid, skill, oldLevel, newLevel)

local pointsPerLevel = 5
local formula =
{
	newMag = getPlayerMagLevel(cid) / 2,
	newHealth = (getCreatureHealth(cid) / 6) + 200,
	newMaxHealth = (getCreatureMaxHealth(cid) / 6) + 200,
	newMana = (getCreatureMana(cid) / 6) + 200,
	newMaxMana = (getCreatureMaxMana(cid) / 6) + 200
}

	if(skill == SKILL__LEVEL) == TRUE then

		if getPlayerLevel(cid) >= levelLimit then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your character will be reset in " .. time .. " seconds.")
			addEvent(resetPlayer, (time * 1000), cid, 8, 4200, formula.newMag, 1000, formula.newHealth, formula.newMaxHealth, formula.newMana, formula.newMaxMana, getPlayerSex(cid), getTownTemplePosition(getPlayerTown(cid)).x, getTownTemplePosition(getPlayerTown(cid)).y, getTownTemplePosition(getPlayerTown(cid)).z)
			doPlayerAddPoints(cid, (newLevel - oldLevel) * pointsPerLevel)
			return TRUE
		end

		doPlayerAddPoints(cid, (newLevel - oldLevel) * pointsPerLevel)
		return TRUE
	end
end

Lua:
local levelLimit = 400 --level to be reseted.
local time = 30 --in seconds, after level 400, player will be disconected in 30 seconds to be reseted.

local pointsPerLevel = 5 --points that gain the player per level
local formula =
{
	newMag = getPlayerMagLevel(cid) / 2, --formula to new magic level, example: Player have ml 80, then after reset will have ml 40.
	newHealth = (getCreatureHealth(cid) / 6) + 200, --formula to new health
	newMaxHealth = (getCreatureMaxHealth(cid) / 6) + 200, --formula to new maxHealth
	newMana = (getCreatureMana(cid) / 6) + 200, --formula to new mana
	newMaxMana = (getCreatureMaxMana(cid) / 6) + 200 --formula to new maxmana
}

  • Info (Creature Script)
  • When player get level limit (400), he is disconected and reseted.
  • Player get level 8 again, teleported to him temple position
  • Player get 50% of Magic level, more health and mana that a player without resets and level 8.
  • For each level, player gain 5 points (You can edit it).

  • Info (Talkaction)
  • For each level, player gain 5 points (You can edit it).
    [*]If you add points to your health, your max health will increasem, example: !addpoints health, 10 (10 points), then player get 20 health points more to her max health (The same thing with the mana).[*]If you add points to attack-defense, the extra attack-defense of the weapon that you have equiped will increase (The limit of extra attack-defense is +15)

Enjoy
 
Last edited:
more infos please²


Edit...

I think I understand,

When player get "X" level, player back to level 1~8, and get 50% of you magic level/skills etc~


if this level X = 400,
and player get level 400 with ml 80,
player back to level 8 with ml 40 {50%} ;D
 
Wow pretty good script, Ive been actually working on something similar to this for a while but this is way more advanced than what Im doing :thumbup:

Havent tested it cause Im not home but still great idea and script! I might use some parts of it to improve the one Ive been doing ;)

+Rep for ya.

PS: Btw does it work with TFS 0.3.2? And as a suggestion you could try making it so like every reset needs a higher lvl to be done, to keep the challenge going, like:

1st reset is at lvl 400, 2nd reset is at lvl 430, 3rd at 460 and so on every 30 lvls (or w/e value placed on the script's config). And maybe make an NPC for that so the next resets are not automatic but optional so the player can choose if he wants to keep leveling or get reseted again at 430, 460, etc.

Just some random ideas :p

Cheers~
 
Last edited:
Then, after "pointsPerLevel = 5" add:
Lua:
local levelAdded = 30 --30 levels more each reset (1st reset level 400, 2nd 430, 3rd 460...)

Change
Lua:
if getPlayerLevel(cid) >= levelLimit
To:
Lua:
if getPlayerLevel(cid) >= (levelLimit + (getPlayerResets(cid) * levelAdded))  then

And add this function to your server:
Lua:
function getPlayerResets(cid)
local Info = db.getResult("SELECT `resets` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. " LIMIT 1")
	local rst = Info:getDataInt("resets")
	Info:free()
	return rst
end
 
Then, after "pointsPerLevel = 5" add:
Lua:
local levelAdded = 30 --30 levels more each reset (1st reset level 400, 2nd 430, 3rd 460...)

Change
Lua:
if getPlayerLevel(cid) >= levelLimit
To:
Lua:
if getPlayerLevel(cid) >= (levelLimit + (getPlayerResets(cid) * levelAdded))  then

And add this function to your server:
Lua:
function getPlayerResets(cid)
local Info = db.getResult("SELECT `resets` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. " LIMIT 1")
	local rst = Info:getDataInt("resets")
	Info:free()
	return rst
end

Thank ya bro Id give you rep again if I could :thumbup:

Poder venezolano, lol. Yo tambien estoy aprendiendo lua ahi mas o menos cuando tengo el chance haciendo cosas simples y eso, ojala un dia de estos pueda hacer vainas mas complejas como tu ;)

Saludos.
 
It works with TFS 0.3.4?
Cuz for me it doesnt :S nothing happen when i get "XX" level.

Just points script work well.
Any suggestions?
 
Last edited:
No work to me on 0.3.6pl1 =/ I reach level 401 and the character not be reseted.

Sorry for my bad english.
 
Back
Top