Various optimization to config.php and LUA scripts

* Update config.php
* spaces to tabs and new line at eof
* updated playerdeath.lua to match latest one from master
This commit is contained in:
Evil Puncker 2020-05-29 16:40:28 -03:00 committed by GitHub
parent a78d26b103
commit e056898f31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 404 additions and 397 deletions

View File

@ -45,33 +45,33 @@ function onLogin(cid)
if getPlayerVocation(cid) == 1 then if getPlayerVocation(cid) == 1 then
-- Sorcerer -- Sorcerer
for i = 1, table.getn(sorcItems), 1 do for i = 1, table.getn(sorcItems), 1 do
doPlayerAddItem(cid, sorcItems[i], 1, FALSE) doPlayerAddItem(cid, sorcItems[i], 1, false)
end end
elseif getPlayerVocation(cid) == 2 then elseif getPlayerVocation(cid) == 2 then
-- Druid -- Druid
for i = 1, table.getn(druidItems), 1 do for i = 1, table.getn(druidItems), 1 do
doPlayerAddItem(cid, druidItems[i], 1, FALSE) doPlayerAddItem(cid, druidItems[i], 1, false)
end end
elseif getPlayerVocation(cid) == 3 then elseif getPlayerVocation(cid) == 3 then
-- Paladin -- Paladin
for i = 1, table.getn(pallyItems), 1 do for i = 1, table.getn(pallyItems), 1 do
doPlayerAddItem(cid, pallyItems[i], 1, FALSE) doPlayerAddItem(cid, pallyItems[i], 1, false)
end end
-- 8 arrows -- 8 arrows
doPlayerAddItem(cid, 2544, 8, FALSE) doPlayerAddItem(cid, 2544, 8, false)
elseif getPlayerVocation(cid) == 4 then elseif getPlayerVocation(cid) == 4 then
-- Knight -- Knight
for i = 1, table.getn(kinaItems), 1 do for i = 1, table.getn(kinaItems), 1 do
doPlayerAddItem(cid, kinaItems[i], 1, FALSE) doPlayerAddItem(cid, kinaItems[i], 1, false)
end end
end end
-- Common for all -- Common for all
doPlayerAddItem(cid, 2674, 5, FALSE) -- 5 apples doPlayerAddItem(cid, 2674, 5, false) -- 5 apples
doPlayerAddItem(cid, 2120, 1, FALSE) -- 1 rope doPlayerAddItem(cid, 2120, 1, false) -- 1 rope
end end
return true return true
end end

View File

@ -38,13 +38,13 @@ function onSay(cid, words, param)
-- ORDER TYPE 1 (Regular item shop products) -- ORDER TYPE 1 (Regular item shop products)
if q_type == 1 then if q_type == 1 then
served = true served = true
-- Get wheight -- Get weight
local playerCap = getPlayerFreeCap(cid) local playerCap = getPlayerFreeCap(cid)
local itemweight = getItemWeight(q_itemid, q_count) local itemweight = getItemWeight(q_itemid, q_count)
if playerCap >= itemweight then if playerCap >= itemweight then
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";") db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
doPlayerAddItem(cid, q_itemid, q_count) doPlayerAddItem(cid, q_itemid, q_count)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have recieved ".. q_count .." "..getItemName(q_itemid).."(s)!") doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have received ".. q_count .." "..getItemName(q_itemid).."(s)!")
else else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Need more CAP!") doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Need more CAP!")
end end

View File

@ -45,33 +45,33 @@ function onLogin(cid)
if getPlayerVocation(cid) == 1 then if getPlayerVocation(cid) == 1 then
-- Sorcerer -- Sorcerer
for i = 1, table.getn(sorcItems), 1 do for i = 1, table.getn(sorcItems), 1 do
doPlayerAddItem(cid, sorcItems[i], 1, FALSE) doPlayerAddItem(cid, sorcItems[i], 1, false)
end end
elseif getPlayerVocation(cid) == 2 then elseif getPlayerVocation(cid) == 2 then
-- Druid -- Druid
for i = 1, table.getn(druidItems), 1 do for i = 1, table.getn(druidItems), 1 do
doPlayerAddItem(cid, druidItems[i], 1, FALSE) doPlayerAddItem(cid, druidItems[i], 1, false)
end end
elseif getPlayerVocation(cid) == 3 then elseif getPlayerVocation(cid) == 3 then
-- Paladin -- Paladin
for i = 1, table.getn(pallyItems), 1 do for i = 1, table.getn(pallyItems), 1 do
doPlayerAddItem(cid, pallyItems[i], 1, FALSE) doPlayerAddItem(cid, pallyItems[i], 1, false)
end end
-- 8 arrows -- 8 arrows
doPlayerAddItem(cid, 2544, 8, FALSE) doPlayerAddItem(cid, 2544, 8, false)
elseif getPlayerVocation(cid) == 4 then elseif getPlayerVocation(cid) == 4 then
-- Knight -- Knight
for i = 1, table.getn(kinaItems), 1 do for i = 1, table.getn(kinaItems), 1 do
doPlayerAddItem(cid, kinaItems[i], 1, FALSE) doPlayerAddItem(cid, kinaItems[i], 1, false)
end end
end end
-- Common for all -- Common for all
doPlayerAddItem(cid, 2674, 5, FALSE) -- 5 apples doPlayerAddItem(cid, 2674, 5, false) -- 5 apples
doPlayerAddItem(cid, 2120, 1, FALSE) -- 1 rope doPlayerAddItem(cid, 2120, 1, false) -- 1 rope
end end
return true return true
end end

View File

@ -39,7 +39,7 @@ function onSay(cid, words, param)
-- ORDER TYPE 1 (Regular item shop products) -- ORDER TYPE 1 (Regular item shop products)
if q_type == 1 then if q_type == 1 then
served = true served = true
-- Get wheight -- Get weight
local playerCap = getPlayerFreeCap(cid) local playerCap = getPlayerFreeCap(cid)
local itemweight = getItemWeightById(q_itemid, q_count) local itemweight = getItemWeightById(q_itemid, q_count)
if playerCap >= itemweight and getTileInfo(getCreaturePosition(cid)).protection then if playerCap >= itemweight and getTileInfo(getCreaturePosition(cid)).protection then
@ -50,7 +50,7 @@ function onSay(cid, words, param)
local received = doAddContainerItem(getPlayerSlotItem(cid, 3).uid, q_itemid,q_count) local received = doAddContainerItem(getPlayerSlotItem(cid, 3).uid, q_itemid,q_count)
if(received ~= false) then if(received ~= false) then
db.executeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";") db.executeQuery("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have recieved ".. q_count .." "..getItemNameById(q_itemid).."(s)!") doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have received ".. q_count .." "..getItemNameById(q_itemid).."(s)!")
gotItem = true gotItem = true
end end
end end

View File

@ -1,17 +1,16 @@
-- With Rookgaard -- With Rookgaard
--[[ --[[
local firstItems = {2050, 2382} local firstItems = {2050, 2382} -- torch and club
function onLogin(cid) function onLogin(player)
local player = Player(cid)
if player:getLastLoginSaved() <= 0 then if player:getLastLoginSaved() <= 0 then
for i = 1, #firstItems do for i = 1, #firstItems do
player:addItem(firstItems[i], 1) player:addItem(firstItems[i], 1)
end end
player:addItem(player:getSex() == 0 and 2651 or 2650, 1) player:addItem(player:getSex() == 0 and 2651 or 2650, 1) -- coat
player:addItem(1987, 1) player:addItem(ITEM_BAG, 1)
player:addItem(2674, 1) player:addItem(2674, 1) -- red apple
end end
return true return true
end end
@ -19,34 +18,33 @@ end
-- Without Rookgaard -- Without Rookgaard
local config = { local config = {
[1] = { [1] = { -- Sorcerer
--equipment spellbook, wand of vortex, magician's robe, mage hat, studded legs, leather boots, scarf -- equipment: spellbook, wand of vortex, magician's robe, mage hat, studded legs, leather boots, scarf
items = {{2175, 1}, {2190, 1}, {8819, 1}, {8820, 1}, {2468, 1}, {2643, 1}, {2661, 1}}, items = {{2175, 1}, {2190, 1}, {8819, 1}, {8820, 1}, {2468, 1}, {2643, 1}, {2661, 1}},
--container rope, shovel, mana potion -- container: rope, shovel, mana potion
container = {{2120, 1}, {2554, 1}, {7620, 1}} container = {{2120, 1}, {2554, 1}, {7620, 1}}
}, },
[2] = { [2] = { -- Druid
--equipment spellbook, snakebite rod, magician's robe, mage hat, studded legs, leather boots scarf -- equipment: spellbook, snakebite rod, magician's robe, mage hat, studded legs, leather boots, scarf
items = {{2175, 1}, {2182, 1}, {8819, 1}, {8820, 1}, {2468, 1}, {2643, 1}, {2661, 1}}, items = {{2175, 1}, {2182, 1}, {8819, 1}, {8820, 1}, {2468, 1}, {2643, 1}, {2661, 1}},
--container rope, shovel, mana potion -- container: rope, shovel, mana potion
container = {{2120, 1}, {2554, 1}, {7620, 1}} container = {{2120, 1}, {2554, 1}, {7620, 1}}
}, },
[3] = { [3] = { -- Paladin
--equipment dwrven shield, 5 spear, ranger's cloak, ranger legs scarf, legion helmet -- equipment: dwarven shield, 5 spear, ranger's cloak, ranger legs, scarf, legion helmet
items = {{2525, 1}, {2389, 5}, {2660, 1}, {8923, 1}, {2643, 1}, {2661, 1}, {2480, 1}}, items = {{2525, 1}, {2389, 5}, {2660, 1}, {8923, 1}, {2643, 1}, {2661, 1}, {2480, 1}},
--container rope, shovel, health potion, bow, 50 arrow -- container: rope, shovel, health potion, bow, 50 arrow
container = {{2120, 1}, {2554, 1}, {7618, 1}, {2456, 1}, {2544, 50}} container = {{2120, 1}, {2554, 1}, {7618, 1}, {2456, 1}, {2544, 50}}
}, },
[4] = { [4] = { -- Knight
--equipment dwarven shield, steel axe, brass armor, brass helmet, brass legs scarf -- equipment: dwarven shield, steel axe, brass armor, brass helmet, brass legs, scarf
items = {{2525, 1}, {8601, 1}, {2465, 1}, {2460, 1}, {2478, 1}, {2643, 1}, {2661, 1}}, items = {{2525, 1}, {8601, 1}, {2465, 1}, {2460, 1}, {2478, 1}, {2643, 1}, {2661, 1}},
--container jagged sword, daramian mace, rope, shovel, health potion -- container jagged sword, daramanian mace, rope, shovel, health potion
container = {{8602, 1}, {2439, 1}, {2120, 1}, {2554, 1}, {7618, 1}} container = {{8602, 1}, {2439, 1}, {2120, 1}, {2554, 1}, {7618, 1}}
} }
} }
function onLogin(cid) function onLogin(player)
local player = Player(cid)
local targetVocation = config[player:getVocation():getId()] local targetVocation = config[player:getVocation():getId()]
if not targetVocation then if not targetVocation then
return true return true

View File

@ -32,8 +32,11 @@ local function sendWarStatus(guildId, enemyGuildId, warId, playerName, killerNam
end end
end end
function onDeath(cid, corpse, killer, mostDamage, unjustified, mostDamage_unjustified) function onDeath(player, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
local player = Player(cid) local playerId = player:getId()
if nextUseStaminaTime[playerId] then
nextUseStaminaTime[playerId] = nil
end
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You are dead.") player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You are dead.")
if not deathListEnabled then if not deathListEnabled then
@ -41,27 +44,25 @@ function onDeath(cid, corpse, killer, mostDamage, unjustified, mostDamage_unjust
end end
local byPlayer = 0 local byPlayer = 0
local killerCreature = Creature(killer) local killerName
if not killerCreature then if killer then
if killer:isPlayer() then
byPlayer = 1
else
local master = killer:getMaster()
if master and master ~= killer and master:isPlayer() then
killer = master
byPlayer = 1
end
end
killerName = killer:getName()
else
killerName = "field item" killerName = "field item"
else
if killerCreature:isPlayer() then
byPlayer = 1
else
local master = killerCreature:getMaster()
if master and master ~= killerCreature and master:isPlayer() then
killerCreature = master
byPlayer = 1
end
end
killerName = killerCreature:isMonster() and killerCreature:getType():getNameDescription() or killerCreature:getName()
end end
local byPlayerMostDamage = 0 local byPlayerMostDamage = 0
if mostDamage == 0 then local mostDamageKillerName
mostDamageName = "field item" if mostDamageKiller then
else
local mostDamageKiller = Creature(mostDamage)
if mostDamageKiller:isPlayer() then if mostDamageKiller:isPlayer() then
byPlayerMostDamage = 1 byPlayerMostDamage = 1
else else
@ -71,7 +72,9 @@ function onDeath(cid, corpse, killer, mostDamage, unjustified, mostDamage_unjust
byPlayerMostDamage = 1 byPlayerMostDamage = 1
end end
end end
mostDamageName = mostDamageKiller:isMonster() and mostDamageKiller:getType():getNameDescription() or mostDamageKiller:getName() mostDamageName = mostDamageKiller:getName()
else
mostDamageName = "field item"
end end
local playerGuid = player:getGuid() local playerGuid = player:getGuid()
@ -89,18 +92,18 @@ function onDeath(cid, corpse, killer, mostDamage, unjustified, mostDamage_unjust
result.free(resultId) result.free(resultId)
end end
while deathRecords > maxDeathRecords do local limit = deathRecords - maxDeathRecords
db.query("DELETE FROM `player_deaths` WHERE `player_id` = " .. playerGuid .. " ORDER BY `time` LIMIT 1") if limit > 0 then
deathRecords = deathRecords - 1 db.asyncQuery("DELETE FROM `player_deaths` WHERE `player_id` = " .. playerGuid .. " ORDER BY `time` LIMIT " .. limit)
end end
if byPlayer == 1 then if byPlayer == 1 then
local targetGuild = player:getGuild() local targetGuild = player:getGuild()
targetGuild = targetGuild and targetGuild:getId() or 0 targetGuild = targetGuild and targetGuild:getId() or 0
if targetGuild ~= 0 then if targetGuild ~= 0 then
local killerGuild = killerCreature:getGuild() local killerGuild = killer:getGuild()
killerGuild = killerGuild and killerGuild:getId() or 0 killerGuild = killerGuild and killerGuild:getId() or 0
if killerGuild ~= 0 and targetGuild ~= killerGuild and isInWar(cid, killerCreature) then if killerGuild ~= 0 and targetGuild ~= killerGuild and isInWar(playerId, killer:getId()) then
local warId = false local warId = false
resultId = db.storeQuery("SELECT `id` FROM `guild_wars` WHERE `status` = 1 AND ((`guild1` = " .. killerGuild .. " AND `guild2` = " .. targetGuild .. ") OR (`guild1` = " .. targetGuild .. " AND `guild2` = " .. killerGuild .. "))") resultId = db.storeQuery("SELECT `id` FROM `guild_wars` WHERE `status` = 1 AND ((`guild1` = " .. killerGuild .. " AND `guild2` = " .. targetGuild .. ") OR (`guild1` = " .. targetGuild .. " AND `guild2` = " .. killerGuild .. "))")
if resultId ~= false then if resultId ~= false then
@ -110,7 +113,7 @@ function onDeath(cid, corpse, killer, mostDamage, unjustified, mostDamage_unjust
if warId ~= false then if warId ~= false then
local playerName = player:getName() local playerName = player:getName()
db.query("INSERT INTO `guildwar_kills` (`killer`, `target`, `killerguild`, `targetguild`, `time`, `warid`) VALUES (" .. db.escapeString(killerName) .. ", " .. db.escapeString(playerName) .. ", " .. killerGuild .. ", " .. targetGuild .. ", " .. os.time() .. ", " .. warId .. ")") db.asyncQuery("INSERT INTO `guildwar_kills` (`killer`, `target`, `killerguild`, `targetguild`, `time`, `warid`) VALUES (" .. db.escapeString(killerName) .. ", " .. db.escapeString(playerName) .. ", " .. killerGuild .. ", " .. targetGuild .. ", " .. os.time() .. ", " .. warId .. ")")
addEvent(sendWarStatus, 1000, killerGuild, targetGuild, warId, playerName, killerName) addEvent(sendWarStatus, 1000, killerGuild, targetGuild, warId, playerName, killerName)
end end
end end

View File

@ -1,7 +1,6 @@
1. Add below line to XML file: data/creaturescripts/creaturescripts.xml 1. Add below line to XML file: data/creaturescripts/creaturescripts.xml
<event type="login" name="znote_syncoutfits" script="syncoutfit.lua" /> <event type="login" name="znote_syncoutfits" script="syncoutfit.lua" />
2. Register event in login.lua: data/creaturescripts/scripts/login.lua 2. Register event in login.lua: data/creaturescripts/scripts/login.lua
player:registerEvent("znote_syncoutfits") player:registerEvent("znote_syncoutfits")

View File

@ -2,7 +2,7 @@
-- can be added to data/global.lua if you want to use eternal storage for another purpose than this. -- can be added to data/global.lua if you want to use eternal storage for another purpose than this.
-- Regular TFS global storage values get reset every time server reboots. This does not. -- Regular TFS global storage values get reset every time server reboots. This does not.
local function getEternalStorage(key, parser) local function getEternalStorage(key, parser)
local value = result.getDataString(db.storeQuery("SELECT `value` FROM `znote_global_storage` WHERE `key` = ".. key .. ";"), "value") local value = result.getString(db.storeQuery("SELECT `value` FROM `znote_global_storage` WHERE `key` = ".. key .. ";"), "value")
if not value then if not value then
if parser then if parser then
return false return false
@ -22,6 +22,36 @@ local function setEternalStorage(key, value)
return true return true
end end
-- SQL Query to execute: --
--[[
ALTER TABLE `znote_players` ADD `exphist_lastexp` BIGINT(255) NOT NULL DEFAULT '0',
ADD `exphist1` BIGINT(255) NOT NULL DEFAULT '0',
ADD `exphist2` BIGINT(255) NOT NULL DEFAULT '0',
ADD `exphist3` BIGINT(255) NOT NULL DEFAULT '0',
ADD `exphist4` BIGINT(255) NOT NULL DEFAULT '0',
ADD `exphist5` BIGINT(255) NOT NULL DEFAULT '0',
ADD `exphist6` BIGINT(255) NOT NULL DEFAULT '0',
ADD `exphist7` BIGINT(255) NOT NULL DEFAULT '0',
ADD `onlinetimetoday` BIGINT(20) NOT NULL DEFAULT '0',
ADD `onlinetime1` BIGINT(20) NOT NULL DEFAULT '0',
ADD `onlinetime2` BIGINT(20) NOT NULL DEFAULT '0',
ADD `onlinetime3` BIGINT(20) NOT NULL DEFAULT '0',
ADD `onlinetime4` BIGINT(20) NOT NULL DEFAULT '0',
ADD `onlinetime5` BIGINT(20) NOT NULL DEFAULT '0',
ADD `onlinetime6` BIGINT(20) NOT NULL DEFAULT '0',
ADD `onlinetime7` BIGINT(20) NOT NULL DEFAULT '0',
ADD `onlinetimeall` BIGINT(20) NOT NULL DEFAULT '0';
]]--
-- after that execute: --
--[[
UPDATE `znote_players` AS `z` INNER JOIN `players` AS `p` ON `p`.`id`=`z`.`player_id` SET `z`.`exphist_lastexp`=`p`.`experience`;
]]--
-- TFS 1.X (data/globalevents.xml)
-- <!-- Power Gamers -->
-- <globalevent name="PowerGamers" interval="60000" script="powergamers.lua"/>
function onThink(interval, lastExecution, thinkInterval) function onThink(interval, lastExecution, thinkInterval)
if tonumber(os.date("%d")) ~= getEternalStorage(23856) then if tonumber(os.date("%d")) ~= getEternalStorage(23856) then
setEternalStorage(23856, (tonumber(os.date("%d")))) setEternalStorage(23856, (tonumber(os.date("%d"))))
@ -31,31 +61,3 @@ function onThink(interval, lastExecution, thinkInterval)
db.query("UPDATE `znote_players` SET `onlinetimetoday` = `onlinetimetoday` + 60, `onlinetimeall` = `onlinetimeall` + 60 WHERE `player_id` IN (SELECT `player_id` FROM `players_online` WHERE `players_online`.`player_id` = `znote_players`.`player_id`)") db.query("UPDATE `znote_players` SET `onlinetimetoday` = `onlinetimetoday` + 60, `onlinetimeall` = `onlinetimeall` + 60 WHERE `player_id` IN (SELECT `player_id` FROM `players_online` WHERE `players_online`.`player_id` = `znote_players`.`player_id`)")
return true return true
end end
-- TFS 1.0 (globalevents.xml)
-- <!-- Power Gamers -->
-- <globalevent name="PowerGamers" interval="60000" script="powergamers.lua"/>
-- SQL (remember to remove all (--) before executing)--
--ALTER TABLE `znote_players` ADD `exphist_lastexp` BIGINT( 255 ) NOT NULL DEFAULT '0',
--ADD `exphist1` BIGINT( 255 ) NOT NULL DEFAULT '0',
--ADD `exphist2` BIGINT( 255 ) NOT NULL DEFAULT '0',
--ADD `exphist3` BIGINT( 255 ) NOT NULL DEFAULT '0',
--ADD `exphist4` BIGINT( 255 ) NOT NULL DEFAULT '0',
--ADD `exphist5` BIGINT( 255 ) NOT NULL DEFAULT '0',
--ADD `exphist6` BIGINT( 255 ) NOT NULL DEFAULT '0',
--ADD `exphist7` BIGINT( 255 ) NOT NULL DEFAULT '0',
--ADD `onlinetimetoday` BIGINT( 20 ) NOT NULL DEFAULT '0',
--ADD `onlinetime1` BIGINT( 20 ) NOT NULL DEFAULT '0',
--ADD `onlinetime2` BIGINT( 20 ) NOT NULL DEFAULT '0',
--ADD `onlinetime3` BIGINT( 20 ) NOT NULL DEFAULT '0',
--ADD `onlinetime4` BIGINT( 20 ) NOT NULL DEFAULT '0',
--ADD `onlinetime5` BIGINT( 20 ) NOT NULL DEFAULT '0',
--ADD `onlinetime6` BIGINT( 20 ) NOT NULL DEFAULT '0',
--ADD `onlinetime7` BIGINT( 20 ) NOT NULL DEFAULT '0',
--ADD `onlinetimeall` BIGINT( 20 ) NOT NULL DEFAULT '0';
---------------
-- after that execute --
-- UPDATE `znote_players` AS `z` INNER JOIN `players` AS `p` ON `p`.`id`=`z`.`player_id` SET `z`.`exphist_lastexp`=`p`.`experience`

View File

@ -1 +0,0 @@
<globalevent name="Znote Shop" interval="30000" script="znoteshop.lua"/>

View File

@ -1,3 +1,4 @@
-- <globalevent name="Znote Shop" interval="30000" script="znoteshop.lua"/>
-- Znote Auto Shop v2.1 for Znote AAC on TFS 1.2+ -- Znote Auto Shop v2.1 for Znote AAC on TFS 1.2+
function onThink(interval, lastExecution) function onThink(interval, lastExecution)
local orderQuery = db.storeQuery([[ local orderQuery = db.storeQuery([[
@ -27,11 +28,11 @@ function onThink(interval, lastExecution)
"Instant house purchase" "Instant house purchase"
} }
repeat repeat
local player_id = result.getDataInt(orderQuery, 'player_id') local player_id = result.getNumber(orderQuery, 'player_id')
local orderId = result.getDataInt(orderQuery, 'id') local orderId = result.getNumber(orderQuery, 'id')
local orderType = result.getDataInt(orderQuery, 'type') local orderType = result.getNumber(orderQuery, 'type')
local orderItemId = result.getDataInt(orderQuery, 'itemid') local orderItemId = result.getNumber(orderQuery, 'itemid')
local orderCount = result.getDataInt(orderQuery, 'count') local orderCount = result.getNumber(orderQuery, 'count')
local served = false local served = false
local player = Player(player_id) local player = Player(player_id)
@ -50,7 +51,7 @@ function onThink(interval, lastExecution)
if orderType == 1 then if orderType == 1 then
served = true served = true
local itemType = ItemType(orderItemId) local itemType = ItemType(orderItemId)
-- Get wheight -- Get weight
if player:getFreeCapacity() >= itemType:getWeight(orderCount) then if player:getFreeCapacity() >= itemType:getWeight(orderCount) then
local backpack = player:getSlotItem(CONST_SLOT_BACKPACK) local backpack = player:getSlotItem(CONST_SLOT_BACKPACK)
-- variable = (condition) and (return if true) or (return if false) -- variable = (condition) and (return if true) or (return if false)
@ -59,7 +60,7 @@ function onThink(interval, lastExecution)
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. orderId .. ";") db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. orderId .. ";")
player:addItem(orderItemId, orderCount) player:addItem(orderItemId, orderCount)
player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received " .. orderCount .. "x " .. ItemType(orderItemId):getName() .. "!") player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received " .. orderCount .. "x " .. ItemType(orderItemId):getName() .. "!")
print("Process complete. [".. player:getName() .."] has recieved " .. orderCount .. "x " .. ItemType(orderItemId):getName() .. ".") print("Process complete. [".. player:getName() .."] has received " .. orderCount .. "x " .. ItemType(orderItemId):getName() .. ".")
else -- not enough slots else -- not enough slots
player:sendTextMessage(MESSAGE_STATUS_WARNING, "Your main backpack is full. You need to free up "..needslots.." available slots to get " .. orderCount .. " " .. ItemType(orderItemId):getName() .. "!") player:sendTextMessage(MESSAGE_STATUS_WARNING, "Your main backpack is full. You need to free up "..needslots.." available slots to get " .. orderCount .. " " .. ItemType(orderItemId):getName() .. "!")
print("Process canceled. [".. player:getName() .."] need more space in his backpack to get " .. orderCount .. "x " .. ItemType(orderItemId):getName() .. ".") print("Process canceled. [".. player:getName() .."] need more space in his backpack to get " .. orderCount .. "x " .. ItemType(orderItemId):getName() .. ".")
@ -91,7 +92,7 @@ function onThink(interval, lastExecution)
player:addOutfit(outfitId) player:addOutfit(outfitId)
player:addOutfitAddon(outfitId, orderCount) player:addOutfitAddon(outfitId, orderCount)
player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received a new outfit!") player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received a new outfit!")
print("Process complete. [".. player:getName() .."] has recieved outfit: ["..outfitId.."] with addon: ["..orderCount.."]") print("Process complete. [".. player:getName() .."] has received outfit: ["..outfitId.."] with addon: ["..orderCount.."]")
else -- Already has outfit else -- Already has outfit
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You already have this outfit and addon!") player:sendTextMessage(MESSAGE_STATUS_WARNING, "You already have this outfit and addon!")
print("Process canceled. [".. player:getName() .."] already have outfit: ["..outfitId.."] with addon: ["..orderCount.."].") print("Process canceled. [".. player:getName() .."] already have outfit: ["..outfitId.."] with addon: ["..orderCount.."].")
@ -107,7 +108,7 @@ function onThink(interval, lastExecution)
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. orderId .. ";") db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. orderId .. ";")
player:addMount(orderItemId) player:addMount(orderItemId)
player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received a new mount!") player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received a new mount!")
print("Process complete. [".. player:getName() .."] has recieved mount: ["..orderItemId.."]") print("Process complete. [".. player:getName() .."] has received mount: ["..orderItemId.."]")
else -- Already has mount else -- Already has mount
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You already have this mount!") player:sendTextMessage(MESSAGE_STATUS_WARNING, "You already have this mount!")
print("Process canceled. [".. player:getName() .."] already have mount: ["..orderItemId.."].") print("Process canceled. [".. player:getName() .."] already have mount: ["..orderItemId.."].")
@ -118,16 +119,16 @@ function onThink(interval, lastExecution)
if orderType == 7 then if orderType == 7 then
served = true served = true
local house = House(orderItemId) local house = House(orderItemId)
-- Logged in player is not neccesarily the player that bough the house. So we need to load player from db. -- Logged in player is not necessarily the player that bough the house. So we need to load player from db.
local buyerQuery = db.storeQuery("SELECT `name` FROM `players` WHERE `id` = "..orderCount.." LIMIT 1") local buyerQuery = db.storeQuery("SELECT `name` FROM `players` WHERE `id` = "..orderCount.." LIMIT 1")
if buyerQuery ~= false then if buyerQuery ~= false then
local buyerName = result.getDataString(buyerQuery, "name") local buyerName = result.getString(buyerQuery, "name")
result.free(buyerQuery) result.free(buyerQuery)
if house then if house then
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. orderId .. ";") db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. orderId .. ";")
house:setOwnerGuid(orderCount) house:setOwnerGuid(orderCount)
player:sendTextMessage(MESSAGE_INFO_DESCR, "You have successfully bought the house "..house:getName().." on "..buyerName..", be sure to have the money for the rent in the bank.") player:sendTextMessage(MESSAGE_INFO_DESCR, "You have successfully bought the house "..house:getName().." on "..buyerName..", be sure to have the money for the rent in the bank.")
print("Process complete. [".. buyerName .."] has recieved house: ["..house:getName().."]") print("Process complete. [".. buyerName .."] has received house: ["..house:getName().."]")
else else
print("Process canceled. Failed to load house with ID: "..orderItemId) print("Process canceled. Failed to load house with ID: "..orderItemId)
end end

View File

@ -1,7 +1,6 @@
-- <talkaction words="!report" separator=" " script="adminreport.lua"/> -- <talkaction words="!report" separator=" " script="adminreport.lua"/>
-- Coded by Dark ShaoOz, modified by Znote -- Coded by Dark ShaoOz, modified by Znote
function onSay(cid, words, param, channel) function onSay(player, words, param)
local player = Player(cid)
local storage = 6708 -- You can change the storage if its already in use local storage = 6708 -- You can change the storage if its already in use
local delaytime = 30 -- Exhaust In Seconds. local delaytime = 30 -- Exhaust In Seconds.
if param == '' then if param == '' then

View File

@ -1 +0,0 @@
<talkaction words="!shop" script="znoteshop.lua"/>

View File

@ -1,3 +1,4 @@
-- <talkaction words="!shop" script="znoteshop.lua"/>
-- Znote Shop v1.1 for Znote AAC on TFS 1.2+ -- Znote Shop v1.1 for Znote AAC on TFS 1.2+
function onSay(player, words, param) function onSay(player, words, param)
local storage = 54073 -- Make sure to select non-used storage. This is used to prevent SQL load attacks. local storage = 54073 -- Make sure to select non-used storage. This is used to prevent SQL load attacks.
@ -38,7 +39,7 @@ function onSay(player, words, param)
-- ORDER TYPE 1 (Regular item shop products) -- ORDER TYPE 1 (Regular item shop products)
if q_type == 1 then if q_type == 1 then
served = true served = true
-- Get wheight -- Get weight
if player:getFreeCapacity() >= ItemType(q_itemid):getWeight(q_count) then if player:getFreeCapacity() >= ItemType(q_itemid):getWeight(q_count) then
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";") db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
player:addItem(q_itemid, q_count) player:addItem(q_itemid, q_count)
@ -92,21 +93,20 @@ function onSay(player, words, param)
if orderType == 7 then if orderType == 7 then
served = true served = true
local house = House(orderItemId) local house = House(orderItemId)
-- Logged in player is not neccesarily the player that bough the house. So we need to load player from db. -- Logged in player is not necessarily the player that bough the house. So we need to load player from db.
local buyerQuery = db.storeQuery("SELECT `name` FROM `players` WHERE `id` = "..orderCount.." LIMIT 1") local buyerQuery = db.storeQuery("SELECT `name` FROM `players` WHERE `id` = "..orderCount.." LIMIT 1")
if buyerQuery ~= false then if buyerQuery ~= false then
local buyerName = result.getDataString(buyerQuery, "name") local buyerName = result.getString(buyerQuery, "name")
result.free(buyerQuery) result.free(buyerQuery)
if house then if house then
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. orderId .. ";") db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. orderId .. ";")
house:setOwnerGuid(orderCount) house:setOwnerGuid(orderCount)
player:sendTextMessage(MESSAGE_INFO_DESCR, "You have successfully bought the house "..house:getName().." on "..buyerName..", be sure to have the money for the rent in the bank.") player:sendTextMessage(MESSAGE_INFO_DESCR, "You have successfully bought the house "..house:getName().." on "..buyerName..", be sure to have the money for the rent in the bank.")
print("Process complete. [".. buyerName .."] has recieved house: ["..house:getName().."]") print("Process complete. [".. buyerName .."] has received house: ["..house:getName().."]")
end end
end end
end end
-- Add custom order types here -- Add custom order types here
-- Type 1 is for itemids (Already coded here) -- Type 1 is for itemids (Already coded here)
-- Type 2 is for premium (Coded on web) -- Type 2 is for premium (Coded on web)

File diff suppressed because one or more lines are too long