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

TalkAction [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 CreatureScript Here -> http://otland.net/f82/advanced-player-points-system-reset-system-36134/#post364937

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';

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, levelLimit, 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)
}

	if getPlayerLevel(cid) >= levelLimit then
		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 .. ";")
	else
	return LUA_ERROR
	end
end

Later, create a file in talkactions and add this:
Lua:
function onSay(cid, words, param, channel)

local t = string.explode(param, ",")

local params = 
{
	player = 
	{
		["health"] = {set = setCreatureMaxHealth, get = getCreatureMaxHealth},
		["mana"] = {set = setCreatureMaxMana, get = getCreatureMaxMana}
	},
	item =
	{
		["weaponattack"] = {set = setItemExtraAttack, get = getItemExtraAttack, msg = "attack"},
		["weapondefense"] = {set = setItemExtraDefense, get = getItemExtraDefense, msg = "defense"}
	}
}

	if(words == "!getpoints") then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have " .. getPlayerPoints(cid).. " points.")
		return TRUE
	end

	if(words == "!addpoints") then
		if(params.player[t[1]]) then

			local m = tonumber(t[2])

			if(not m) then
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "No point specified.")
				return TRUE
			end

			if(getPlayerPoints(cid) < m) then
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do not have enought points.")
				return TRUE
			end

			m = math.abs(m)
			doPlayerRemovePoints(cid, m)
			params.player[t[1]].set(cid, params.player[t[1]].get(cid) + (m * 2))
			return TRUE

		elseif(params.item[t[1]]) then

			local m = tonumber(t[2])

			if(not m) then
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "No point specified.")
				return TRUE
			end

			if(getPlayerPoints(cid) < m) then
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do not have enought points.")
				return TRUE
			end

			local weapon = getPlayerWeapon(cid, TRUE)
			local extraLimit = 15

			if(weapon.itemid == 0) then
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do not any weapon equiped.")
				return TRUE
			end

			local weaponAttribute = params.item[t[1]].get(weapon.uid)

			if (m > extraLimit) or ((weaponAttribute + m) > extraLimit) then
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You only can add " .. extraLimit .. " extra " .. params.item[t[1]].msg .. " points to your weapon.")
				return TRUE
			end

			if(weaponAttribute >= extraLimit) then
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot add more extra " .. params.item[t[1]].msg .. " to this weapon.")
				return TRUE
			end

			m = math.abs(m)
			doPlayerRemovePoints(cid, m)
			params.item[t[1]].set(weapon.uid, weaponAttribute + m)
			return TRUE
		else
			return TRUE
		end
	end
end

Add this to talkactions.xml
Lua:
	<talkaction log="yes" words="!getpoints" event="script" value="points.lua" />
	<talkaction log="yes" words="!addpoints" event="script" value="points.lua" />

Lua:
local extraLimit = 15 --Limit of extra attack-defense that can have the weapon

  • 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:
Well, I think it's a usefull script.
Don't tested it yet, but I think it works.
 
No credits to Pitufo for

Code:
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

??
 
Lol! haha made my functions based in these functions but.. i dind't know that these fucntios are from Pitufo xD
 
Lua:
!addpoints weaponattack, 5 --5 extra attack points.
!addpoints weapondefense, 5 --5 extra defense points.
 
You must repair script ;f
Use command:
!addpoints weaponattack , -100000
the same is with hp or mana : /
 
Qeels is right.
Also i dunno if others has it but my points always change for 800+ mana and its doesnt matter if i use 800 points or just 1 point, its always add 800 mana.
Someone know how to fix those issues? :S
 
PHP:
						  <tr><td BGCOLOR="'.$config['site']['darkborder'].' align="left"><b>Player Resets:</b></td><td BGCOLOR="'.$config['site']['darkborder'].' align="left">'.$player->getCustomField('resets').'</td></tr>
 
Back
Top