• 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 [MOD] Reset/Reborn system + highscore V2.0

nclx

Member
Joined
Jul 18, 2009
Messages
554
Reaction score
15
I made this because i needed it for my server, I personally don't need any other feature, if you do, post it here and I'll add it.

What does this do?
- When you reach the level selected in the config (default is 400), you reborn to the level selected (default 1).
- Amount of resets will be shown at the website and when you look a player.

Commands
Player resets automatly when reach the level selected in the config, but you also could use any of these commands:
- /resetPlayer -- This will reset a player, just like if he have reached the reset level
- /setPlayerResets name, amount -- This wont reset a player, but it will set the amount of resets, specify the name of the player and the amount.

HOW TO INSTALL

MOD

mods/reset-system.xml

Lua:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Reset System" version="1.0" autor="nclx" contact="otland.net" enabled="yes">
	<config name="resetConfig"><![CDATA[
		local config = 
			{
				tPos = {x = 780, y = 699, z = 7}, -- Position after the reset
				startLevel = 1,
				experience = 0,
				hpMax = 150,
				manaMax = 0,
				capasity = 420
			}

		function getPlayerResets(name)
		   return db.getResult("SELECT resets FROM players WHERE name="..db.escapeString(name)..""):getDataInt("resets")
		end

		function doPlayerReset(name)
			db.executeQuery("UPDATE players SET resets=("..getPlayerResets(name).." + 1), level="..config.startLevel..", experience = "..config.experience..", manamax = "..config.manaMax..", mana = "..config.manaMax..", healthmax = "..config.hpMax..", health = "..config.hpMax..", cap="..config.capasity..", posx="..config.tPos.x..", posy="..config.tPos.y..", posz="..config.tPos.z.." WHERE name = "..db.escapeString(name).."")
		end

		function doPlayerSetResets(name, amount)
			db.executeQuery("UPDATE players SET resets="..amount.." WHERE name="..db.escapeString(name).."")
		end
	]]></config>

	<event type="login" name="resetEvents" event="script"><![CDATA[
	domodlib('resetConfig')

	function onLogin(cid)
		registerCreatureEvent(cid, "showResets")
		registerCreatureEvent(cid, "resetOnAdvance")
		return true
	end
	]]></event>

	<event type="look" name="showResets" event="script"><![CDATA[
	domodlib('resetConfig')

	function onLook(cid, thing, position, lookDistance)
		if(isPlayer(thing.uid)) then
			if getPlayerResets(getCreatureName(thing.uid)) < 1 then
				doPlayerSendTextMessage(cid, 20, ""..getCreatureName(thing.uid).." doesnt have any reset.")
			else
				doPlayerSendTextMessage(cid, 20, ""..getCreatureName(thing.uid).." has "..getPlayerResets(getCreatureName(thing.uid)).." resets")
			end
		end
		return true
	end
	]]></event>

	<event type="advance" name="resetOnAdvance" event="script"><![CDATA[
	domodlib('resetConfig')
	local resetLevel = 400

	function onAdvance(cid, skill, oldlevel, newlevel)
		playerName = getPlayerName(cid)
		if newlevel >= resetLevel then
			doRemoveCreature(cid)
			doPlayerReset(playerName)
		end
		return true
	end
	]]></event>

	<talkaction words="/resetPlayer" access="5" event="buffer"><![CDATA[
	domodlib('resetConfig')

		if(param == '') then

			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")

			return true

		end

		local pid = getPlayerByNameWildcard(param)

		if(not pid) then

			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. param .. " not found.")

			return true

		end
		
		doRemoveCreature(pid)
		doPlayerReset(param)

	return true
	]]></talkaction>

	<talkaction words="/setPlayerResets" access="5" event="buffer"><![CDATA[
	domodlib('resetConfig')

		if(param == '') then

			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")

			return true

		end

		local t = string.explode(param, ",")
		if(not t[2]) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Not enough params.")
			return true
		end

		local pid = getPlayerByNameWildcard(t[1])

		if(not pid) then

			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[1] .. " not found.")

			return true

		end
		
		doRemoveCreature(pid)
		doPlayerSetResets(t[1], t[2])

	return true
	]]></talkaction></mod>

HIGHSCORES.

highscores.php at your website folder:
Code:
<?PHP
$list = $_REQUEST['list'];
$page = $_REQUEST['page'];
switch($list)
{
  case "fist":
   $id = 0;
   $list_name = 'Fist Fighting';
   break;
  case "club":
   $id = 1;
   $list_name = 'Club Fighting';
   break;
  case "sword":
   $id = 2;
   $list_name = 'Sword Fighting';
   break;
  case "axe":
   $id = 3;
   $list_name = 'Axe Fighting';
   break;
  case "distance":
   $id = 4;
   $list_name = 'Distance Fighting';
   break;
  case "shield":
   $id = 5;
   $list_name = 'Shielding';
   break;
  case "fishing":
   $id = 6;
   $list_name = 'Fishing';
   break;
}
if(!isset($id))
	if($list == "magic")
		$list_name = "Magic Level";
	elseif($list == "resets")
		$list_name = "Resets";
	else
	{
		$list_name = 'Experience';
		$list = 'experience';
	}
if(count($config['site']['worlds']) > 1)
{
	$worlds .= '<i>Select world:</i> ';
	foreach($config['site']['worlds'] as $idd => $world_n)
	{
		if($idd == (int) $_GET['world'])
		{
			$world_id = $idd;
			$world_name = $world_n;
		}
	}
}
		if($idd == (int) $_GET['world'])
		{
			$world_id = $idd;
			$world_name = $world_n;
		}
if(!isset($world_id))
{
	$world_id = 0;
	$world_name = $config['server']['serverName'];
}
$offset = $page * 100;
if(isset($id))
	$skills = $SQL->query('SELECT name,online,value,level,vocation,promotion FROM players,player_skills WHERE players.world_id = '.$world_id.' AND players.deleted = 0 AND players.group_id < '.$config['site']['players_group_id_block'].' AND players.id = player_skills.player_id AND player_skills.skillid = '.$id.' ORDER BY value DESC, count DESC LIMIT 101 OFFSET '.$offset);
elseif($list == "magic")
	$skills = $SQL->query('SELECT name,online,maglevel,level,vocation,promotion FROM players WHERE players.world_id = '.$world_id.' AND players.deleted = 0 AND players.group_id < '.$config['site']['players_group_id_block'].' AND name != "Account Manager" ORDER BY maglevel DESC, manaspent DESC LIMIT 101 OFFSET '.$offset);
elseif($list == "resets")
	$skills = $SQL->query('SELECT name,online,resets,level,vocation,promotion FROM players WHERE players.world_id = '.$world_id.' AND players.deleted = 0 AND players.group_id < '.$config['site']['players_group_id_block'].' AND name != "Account Manager" ORDER BY resets DESC LIMIT 101 OFFSET '.$offset);
elseif($list == "experience")
	$skills = $SQL->query('SELECT name,online,level,experience,vocation,promotion FROM players WHERE players.world_id = '.$world_id.' AND players.deleted = 0 AND players.group_id < '.$config['site']['players_group_id_block'].' AND name != "Account Manager" ORDER BY level DESC, experience DESC LIMIT 101 OFFSET '.$offset);

//wyswietlanie wszystkiego
$main_content .= '<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%><TR><TD><IMG SRC="'.$layout_name.'/images/general/blank.gif" WIDTH=10 HEIGHT=1 BORDER=0></TD><TD><CENTER><H2>Ranking for '.$list_name.' on '.$world_name.'</H2></CENTER><BR>';
	$main_content .= '<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%><TR><TD></TD><TD>
<FORM ACTION="?subtopic=highscores" METHOD=get><INPUT TYPE=hidden NAME=subtopic VALUE=highscores><INPUT TYPE=hidden NAME=list VALUE=experience>
<TABLE WIDTH=100% BORDER=0 CELLSPACING=1 CELLPADDING=4><TR><TD BGCOLOR="'.$config['site']['vdarkborder'].'" CLASS=white><B>World Selection</B></TD></TR><TR><TD BGCOLOR="'.$config['site']['lightborder'].'">
    <TABLE BORDER=0 CELLPADDING=1><TR><TD>World: </TD><TD><SELECT SIZE="1" NAME="world"><OPTION VALUE="" SELECTED>(choose world)</OPTION>';
	foreach($config['site']['worlds'] as $id => $world_n)
{
	$main_content .= '<OPTION VALUE="'.$id.'">'.$world_n.'</OPTION>';
}
	$main_content .= '</SELECT> </TD><TD><INPUT TYPE=image NAME="Submit" ALT="Submit" SRC="'.$layout_name.'/images/buttons/sbutton_submit.gif" BORDER=0 WIDTH=120 HEIGHT=18>
        </TD></TR></TABLE></TABLE></FORM></TABLE><br><br><TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100%></TABLE><TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100%><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD WIDTH=10% CLASS=whites><B>Rank</B></TD><TD WIDTH=75% CLASS=whites><B>Name</B></TD><TD WIDTH=15% CLASS=whites><b><center>Level</center></B></TD>';
if($list == "experience")
	$main_content .= '<TD CLASS=whites><b><center>Points</center></B></TD>';
$main_content .= '</TR><TR>';
foreach($skills as $skill)
{
$player = $ots->createObject('Player');
$player->find($skill['name']);
$account = $player->getAccount();
$ban = '';
if($account->isBanned())
$ban = '<font color="red"> [Banished]</font>';
	if($number_of_rows < 100)
	{
		if($list == "magic")
			$skill['value'] = $skill['maglevel'];
		if($list == "resets")
			$skill['value'] = $skill['resets'];
		if($list == "experience")
			$skill['value'] = $skill['level'];
		if(!is_int($number_of_rows / 2)) { $bgcolor = $config['site']['darkborder']; } else { $bgcolor = $config['site']['lightborder']; } $number_of_rows++;
		$main_content .= '<tr bgcolor="'.$bgcolor.'"><td>'.($offset + $number_of_rows).'.</td><td><a href="?subtopic=characters&name='.urlencode($skill['name']).'">'.($skill['online']>0 ? "<font color=\"green\">".$skill['name']."</font>" : "<font color=\"red\">".$skill['name']."</font>").'</a> '.$ban.'<br><small>'.$skill['level'].' '.$vocation_name[$world_id][$skill['promotion']][$skill['vocation']].'</small></td><td><center>'.$skill['value'].'</center></td>';
		if($list == "experience")
			$main_content .= '<td><center>'.$skill['experience'].'</center></td>';
		$main_content .= '</tr>';
	}
	else
		$show_link_to_next_page = TRUE;
}
$main_content .= '</TABLE><TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100%>';
if($page > 0)
	$main_content .= '<TR><TD WIDTH=100% ALIGN=right VALIGN=bottom><A HREF="?subtopic=highscores&list='.$list.'&page='.($page - 1).'" CLASS="size_xxs">Previous Page</A></TD></TR>';
if($show_link_to_next_page)
	$main_content .= '<TR><TD WIDTH=100% ALIGN=right VALIGN=bottom><A HREF="?subtopic=highscores&list='.$list.'&page='.($page + 1).'" CLASS="size_xxs">Next Page</A></TD></TR>';
$main_content .= '</TABLE></TD><TD WIDTH=5%><IMG SRC="'.$layout_name.'/images/general/blank.gif" WIDTH=1 HEIGHT=1 BORDER=0></TD><TD WIDTH=15% VALIGN=top ALIGN=right><TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1><TR BGCOLOR="'.$config['site']['vdarkborder'].'"><TD CLASS=whites><B>Choose a skill</B></TD></TR><TR BGCOLOR="'.$config['site']['lightborder'].'"><TD><A HREF="?subtopic=highscores&list=experience&world='.$world_id.'" CLASS="size_xs">Experience</A><BR><A HREF="?subtopic=highscores&list=magic&world='.$world_id.'" CLASS="size_xs">Magic</A><BR><A HREF="?subtopic=highscores&list=shield&world='.$world_id.'" CLASS="size_xs">Shielding</A><BR><A HREF="?subtopic=highscores&list=distance&world='.$world_id.'" CLASS="size_xs">Distance</A><BR><A HREF="?subtopic=highscores&list=club&world='.$world_id.'" CLASS="size_xs">Club</A><BR><A HREF="?subtopic=highscores&list=sword&world='.$world_id.'" CLASS="size_xs">Sword</A><BR><A HREF="?subtopic=highscores&list=axe&world='.$world_id.'" CLASS="size_xs">Axe</A><BR><A HREF="?subtopic=highscores&list=fist&world='.$world_id.'" CLASS="size_xs">Fist</A><BR><A HREF="?subtopic=highscores&list=fishing&world='.$world_id.'" CLASS="size_xs">Fishing</A><BR><A HREF="?subtopic=highscores&list=resets&world='.$world_id.'" CLASS="size_xs">Resets</A><BR></TD></TR></TABLE></TD><TD><IMG SRC="'.$layout_name.'/images/general/blank.gif" WIDTH=10 HEIGHT=1 BORDER=0></TD></TR></TABLE>';

?>
 
Last edited:
Thats not nice to tell players not to use it! But i do enjoy your honesty, all n all good job tho. :peace:
 
Let's see.. you're doing it wrong!

Lua:
return 1 and 2
> 2

return 1, 2
> 1	2
 
Ahh... but i tested and worked o_O =(, ty for right way xd

Can LUA return if too?, shorter version, like c++...

return (isThisPosible() ? yes : no).

@Sync
Can use, at ur own risk.
 
Last edited:
Code:
doPlayerSetStorageValue(cid, config.storage, (getPlayerStorageValue(cid, config.storage)

What if we don't have any reset (storage -1)?
After reset player will get 0 reset count.

Code:
name = \""..config.name.."\"
Code:
name = '"..config.name.."'


Code:
			doPlayerSendTextMessage(cid, 20, ""..getCreatureName(thing.uid).." doesn\'t have any reset.")
		else
			doPlayerSendTextMessage(cid, 20, ""..getCreatureName(thing.uid).." have "..getPlayerStorageValue(thing.uid, storage).." resets."
Code:
			doPlayerSendTextMessage(cid, 20, getCreatureName(thing.uid).." doesn't have any reset.")
		else
			doPlayerSendTextMessage(cid, 20, getCreatureName(thing.uid).." have "..getPlayerStorageValue(thing.uid, storage).." resets."
 
@Chojrak
I forgot the login.lua part ;s ill edit it now, about the ' or \", i think is up to your style.
 
Last edited:
Cykotitan style: (not fake or skam oki)
Code:
local config =  {
	tPos = {x = 780, y = 699, z = 7},
	storage = 3000,
	resetLevel = 350,
	startLevel = 8,
	experience = 4600,
	hpMax = 185,
	manaMax = 35
}
function onAdvance(cid, skill, oldlevel, newlevel)
   if(newlevel >= config.resetLevel) then 
		return
			doPlayerSetStorageValue(cid, config.storage, getPlayerStorageValue(cid, config.storage) + 1),
			doTeleportThing(cid, config.tPos),
			doRemoveCreature(cid),
			db.executeQuery("UPDATE players SET level = " .. config.startLevel .. ", experience = " .. config.experience .. ", manamax = " .. config.manaMax .. ", mana = " .. config.manaMax .. ", healthmax = " .. config.hpMax .. ", health = " .. config.hpMax .. " WHERE name = '" .. escapeString(getCreatureName(cid)) .. "'")
	end
	return true
end
Code:
local storage = 3000
function onLook(cid, thing, position, lookDistance)
	if(isPlayer(thing.uid)) then
		doPlayerSendTextMessage(cid, 20, 
			getPlayerStorageValue(cid, storage) < 1 and
				getCreatureName(thing.uid) .. " " .. ("doesnt have any reset.")
			or
				getCreatureName(thing.uid) .. " has " .. getPlayerStorageValue(thing.uid, storage) .. " resets."
			)
	end
	return true
end
haha z0mg no work ded r0x

i make rox's
 
Last edited:
For some reason return 1, 2 is not working here only return 1 and 2 xd (i've tested already), the onLook workd, ill use it here.
 
For some reason return 1, 2 is not working here only return 1 and 2 xd (i've tested already), the onLook workd, ill use it here.
lol u shouldnt return 1 and 2 :SS:S but doPlayerSetStorageValue(... etc instead ;s

or you just make funy of my examples?? xd

return 1 and 2 shouldn't work :S test here ok: http://www.lua.org/cgi-bin/demo
 
Last edited:
ya i know but have reverse effect on the ot o_O xD works with "and", tfs 0.3.5pl1, u can join test serv xd

Added show resets in characters.php xdd
 
Last edited:
aaa but you need escape string in playerAdvance.lua else it'll be vulnerable :S
Code:
WHERE name = '" .. escapeString(getCreatureName(cid)) .. "'")
 
luascript.cpp
Code:
int32_t LuaScriptInterface::luaEscapeString(lua_State* L)
{
	//escapeString(str)
	std::string str = popString(L);
	lua_pushstring(L, [B]Database::escapeString[/B](str).c_str());
	return 1;
}
database.cpp
Code:
std::string _Database::escapeString(const std::string &s)
{
	#if defined __USE_MYSQL__ && defined __USE_SQLITE__
	if(g_config.getNumber(ConfigManager::SQLTYPE) == SQL_TYPE_MYSQL)
		return escapeString(s.c_str(), s.size());
	else
	{
		std::string r = std::string(s);
		escape_string(r);
		return r;
	}
	#elif defined __USE_MYSQL__
	return escapeString(s.c_str(), s.size());
	#elif defined __USE_SQLITE__
	std::string r = std::string(s);
	escape_string(r);
	return r;
	#endif
}
Code:
// probably the mysql_escape_string version should be dropped as it's less generic
// but i'm keeping it atm
std::string _Database::escapeString(const char* s, unsigned long size)
{
	if(s == NULL)
		return std::string("");

	std::string r;
	#if defined __USE_MYSQL__ && defined __USE_SQLITE__
		if(g_config.getNumber(ConfigManager::SQLTYPE) == SQL_TYPE_MYSQL)
		{
			char* output = new char[size * 2 + 1];
			mysql_escape_string(output, s, size);
			r = std::string(output);
			delete[] output;
		}
		else
		{
			r = std::string(s);
			escape_string(r);
		}
	#elif defined __USE_MYSQL__
		char* output = new char[size * 2 + 1];
		mysql_escape_string(output, s, size);
		r = std::string(output);
		delete[] output;
	#elif defined __USE_SQLITE__
		r = std::string(s);
		escape_string(r);
	#endif
	return r;
}
 
Ahhh... rox, script is no longer vulnerable then =D ill leave the warning anyway.
 
You should place config before the main function
Code:
local config = {
	tPos = {x = 780, y = 699, z = 7},
	storage = 3000,
	resetLevel = 350,
	startLevel = 8,
	experience = 4600,
	hpMax = 185,
	manaMax = 35
}
function onAdvance(cid, skill, oldlevel, newlevel)
	local name = getPlayerName(cid),
 
Code:
WHERE name = "..db.escapeString([B][COLOR="Red"]config.[/COLOR][/B]name)[B][COLOR="Red"]..""[/COLOR][/B]))
Variable name is no longer part of table config, please fix.
Also, `..""` can be ommited.

returning with more kool in he:
Code:
function onAdvance(cid, skill, oldlevel, newlevel)
return
	newlevel >= config.resetLevel and
	(
		doPlayerSetStorageValue(cid, config.storage, getPlayerStorageValue(cid, config.storage) + 1) and
		doTeleportThing(cid, config.tPos) and
		doRemoveCreature(cid) and
		db.executeQuery("UPDATE players SET level = "..config.startLevel..", experience = "..config.experience..", manamax = "..config.manaMax..", mana = "..config.manaMax..", healthmax = "..config.hpMax..", health = "..config.hpMax.." WHERE name = "..db.escapeString(getPlayerName(cid)))
	)
	or false
end
 
Last edited:
Ah, i fixed in MOD and forgot to fix in LUA ;s...

All return in LUA, no returns in MOD =P (because i have no idea how good/bad in performance return is, also I think I would have problem with that in MODs)
 
well thats not the point, but you can do it... just set the HP/MP that you want to have when reset at the config...


Code:
local config = {
	tPos = {x = 780, y = 699, z = 7},
	storage = 3000,
	resetLevel = 350,
	startLevel = 8,
	experience = 4600,
[B]	hpMax = 185,
	manaMax = 35[/B]
}
 
Back
Top