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

CreatureEvent Reset System [No Source Edit Needed]

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,858
Reaction score
96
Location
Brazil
The most part of OTs reset because of players reaching higher levels.
This way they will still have their power because of ML and skills intact.
The unique disadvantage of reset to players will be level for using spells.
But it will be a great advantage to your OT because it will create a new rank(resets) and no EXTREME power of players.
No more resets in houses, items, guilds ..

PS.: Reseting will not enable quests made to be done again. Because it makes no sense lol.

Code:
Features:
- Only players WITHOUT PzLocked or Skulls(White, Red or Black) can reset.
Example: If Player Example reach level 300(configurable) and got a skull or PzLocked then He/She will have to reach level 300(configurable) or higher WITHOUT PzLocked or skull.
- When reseting player will be teleported to temple, He/She will be removed battle state, He/She will back to level 8(configurable).


SQL:
ALTER TABLE `players` ADD `resets` INT( 11 ) NOT NULL DEFAULT '0';

data/creaturescripts/creaturescripts.xml
XML:
<event type="advance" name="addReset" event="script" value="reset.lua"/>

data/creaturescripts/scripts/reset.lua
Lua:
local function getPlayerResets(cid)
	local pid = getPlayerGUID(cid)
	local resetresult = db.getResult("SELECT `resets` FROM `players` WHERE `id` = "..pid.." ;")
	return resetresult:getID() ~= -1 and resetresult:getDataInt("resets") or false
end 
 
local function doPlayerAddResets(cid)
	local pid = getPlayerGUID(cid)
	local gr = getPlayerResets(cid)
	return = db.executeQuery("UPDATE `players` SET `resets` = ".. gr + 1 .." WHERE `id` ="..pid.."")
end
 
function onAdvance(cid, type, oldlevel, newlevel)
local config =
{
	blevel = 300 -- Level before reset
	alevel = 8 -- Level after reset
}
	if (oldlevel ~= newlevel and type == SKILL__LEVEL) then
		if (newlevel >= config.blevel) then
			if (not isPlayerPzLocked(cid)) then
				if ((getCreatureSkullType(cid) ~= SKULL_WHITE) or (getCreatureSkullType(cid) ~= SKULL_RED) or (getCreatureSkullType(cid) ~= SKULL_BLACK)) then
					doPlayerAddResets(cid)
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You have reached level 300 and you have been reseted.')
					doPlayerSetSpecialDescription(cid, (getPlayerSex(cid) == 0 and ".\nShe" or ".\nHe") .." have "..getPlayerResets(cid).." resets.")
					doPlayerAddExperience(cid, (getExperienceForLevel(config.alevel) - getPlayerExperience(cid)))
					doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
					doRemoveCondition(cid, CONDITION_INFIGHT)
				else
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You couldn\'t be reseted due you got a skull.')
				end
			else
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You couldn\'t be reseted due you got blood in your hands.')
			end
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You couldn\'t be reseted due you don\'t have enough level.')
		end
	end
	return true
end

The reason of:
Lua:
if (newlevel >= 300) then
Maybe you have higher exp/stages in your server so if a player jump level 300 he/she will reset anyway.
 
Last edited:
everytime when player uses look on other player or himself, script will send query to database, don't recommend this way
 
Last edited:
Getting a storage value from database is also made by sending a query.

however storage saves only on player logout(or when executes function save) and loads on player login, then there are just 2 queries... not 21736712398762198731923 queries
 
Last edited:
How can it be optimized if it uses queries?
 
How can I do not use queries? :(

- - - Updated - - -

It's max optimized as possible, dont it?
 
Ah, the unique problem is to construct the rank in web page.
In my case, I'm using MAAC and I don't know how to do an select (RANK) of storages :w00t:
 
SQL:
SELECT `player_storage`.*, `players`.* FROM `player_storage`
	LEFT JOIN `players` ON `players`.`id` = `player_storage`.`player_id` 
WHERE `player_storage`.`key` = YOUR_KEY
ORDER BY `player_storage`.`value` DESC
LIMIT 20
 
Last edited:
Back
Top