Skip to content

Instantly share code, notes, and snippets.

MonsterLimits = {}
Global_Monster_Limit = 3
local startup = CreatureEvent("MonsterLimitStartup")
function startup.onLogin(player)
local guid = player:getGuid()
if not MonsterLimits[guid] then
MonsterLimits[guid] = {}
player:registerEvent("MonsterKillCounter")
@Znote
Znote / cherrypick-event-to-otbr.md
Created November 12, 2020 23:55
This is a failed attempt at merging otland Event Callbacks into OTBR
git clone git@github.com:opentibiabr/otservbr-global.git .
git remote add otland git@github.com:otland/forgottenserver.git
git remote -v
origin  git@github.com:opentibiabr/otservbr-global.git (fetch)
origin  git@github.com:opentibiabr/otservbr-global.git (push)
otland  git@github.com:otland/forgottenserver.git (fetch)
@Znote
Znote / highscores.php
Last active August 18, 2020 10:02
Adapt experience group to accommodate resets
<?php require_once 'engine/init.php'; include 'layout/overall/header.php';
if ($config['log_ip']) {
znote_visitor_insert_detailed_data(3);
}
// Fetch highscore type
$type = (isset($_GET['type'])) ? (int)getValue($_GET['type']) : 7;
if ($type > 9) $type = 7;
@Znote
Znote / characterprofile.php
Created July 12, 2020 15:47
Marriage system addition in characterprofile.php for Znote AAC
<?php
/*
CREATE TABLE marriage_system (
id INTEGER NOT NULL,
player_id INTEGER NOT NULL,
partner INTEGER NOT NULL,
marriage_date INTEGER NOT NULL,
PRIMARY KEY ( id )
);
*/
@Znote
Znote / resetplayer.php
Last active June 26, 2020 12:39
Player reset page for Znote AAC
<?php require_once 'engine/init.php'; protect_page(); include 'layout/overall/header.php';
// Player storagevalue that keeps track of the resets
$playerStorage_reset = 378378;
// Get player List from logged in account, with extra data to see resets, if they can reset, level requirement for their reset.
function getSpecialPlayerList($account_id, $playerStorage_reset, $player_id = 0) {
$account_id = (int)$account_id;
$playerStorage_reset = (int)$playerStorage_reset;
$player_id = (int)$player_id;
@Znote
Znote / getPlayerDatabaseInfo.lua
Last active June 12, 2020 23:18
TFS 1.3 function that queries for player information from the database, returns a table of useful information if success, false if player doesn't exist.
function getPlayerDatabaseInfo(name_or_guid)
local sql_where = ""
if type(name_or_guid) == 'string' then
sql_where = "WHERE `p`.`name`=" .. db.escapeString(name_or_guid) .. ""
elseif type(name_or_guid) == 'number' then
sql_where = "WHERE `p`.`id`='" .. name_or_guid .. "'"
else
return false
end
@Znote
Znote / znoteshop.lua
Last active February 5, 2021 08:49
Add otservBR tibia coin support on Znote AAC shop
-- <globalevent name="Znote Shop" interval="30000" script="znoteshop.lua"/>
-- Znote Auto Shop v2.1 for Znote AAC on TFS 1.2+
function onThink(interval, lastExecution)
local orderQuery = db.storeQuery([[
SELECT
MIN(`po`.`player_id`) AS `player_id`,
`shop`.`id`,
`shop`.`type`,
`shop`.`itemid`,
`shop`.`count`
@Znote
Znote / git_colab_on_fork
Created March 11, 2020 23:31
Checkout a forked branch, modify it into your own new branch, and send it to the forks branch as a pull request.
2087 git remote add nekiro https://github.com/nekiro/forgottenserver.git
2088 git remote -v
2089 git fetch nekiro
2090 git checkout nekiro/7.72-downgrade
2092 git checkout -b 7.72-spells-fix
2095 git status
2096 git add data/spells/scripts/runes/envenom_rune.lua
2097 git add data/spells/scripts/runes/fireball_rune.lua
2098 git add data/spells/scripts/runes/sudden_death_rune.lua
2099 git add data/spells/spells.xml
@Znote
Znote / cache.php
Created February 11, 2020 07:38
APCu cache for Znote AAC
<?php
class Cache_apc
{
protected $_key = false;
protected $_lifespan = 0;
protected $_content;
/**
* @param string $key
* @access public
@Znote
Znote / ondroploot.lua
Last active January 27, 2020 07:38
Monster:onDropLoot(corpse) - if player is premium, remove gold coins from loot and transfer them directly to bank https://otland.net/threads/gold-coin-rate-and-gold-coin-to-bank.268224/#post-2589426
function Monster:onDropLoot(corpse)
if configManager.getNumber(configKeys.RATE_LOOT) == 0 then
return
end
local currencies = {
2148 = 1,
2152 = 100,
2160 = 10000
}