mirror of
https://github.com/Znote/ZnoteAAC.git
synced 2025-04-30 19:29:22 +02:00
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:
parent
a78d26b103
commit
e056898f31
@ -1,6 +1,6 @@
|
|||||||
function onLogin(cid)
|
function onLogin(cid)
|
||||||
local storage = 30055 -- storage value
|
local storage = 30055 -- storage value
|
||||||
|
|
||||||
local sorcItems = {
|
local sorcItems = {
|
||||||
2460, -- Brass helmet
|
2460, -- Brass helmet
|
||||||
2465, -- Brass armor
|
2465, -- Brass armor
|
||||||
@ -39,39 +39,39 @@ function onLogin(cid)
|
|||||||
1988, -- Brown backpack
|
1988, -- Brown backpack
|
||||||
2050 -- torch
|
2050 -- torch
|
||||||
}
|
}
|
||||||
|
|
||||||
if getPlayerStorageValue(cid, storage) == -1 then
|
if getPlayerStorageValue(cid, storage) == -1 then
|
||||||
setPlayerStorageValue(cid, storage, 1)
|
setPlayerStorageValue(cid, storage, 1)
|
||||||
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
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
function onSay(cid, words, param)
|
function onSay(cid, 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.
|
||||||
local cooldown = 15 -- in seconds.
|
local cooldown = 15 -- in seconds.
|
||||||
|
|
||||||
if getPlayerStorageValue(cid, storage) <= os.time() then
|
if getPlayerStorageValue(cid, storage) <= os.time() then
|
||||||
setPlayerStorageValue(cid, storage, os.time() + cooldown)
|
setPlayerStorageValue(cid, storage, os.time() + cooldown)
|
||||||
local accid = getAccountNumberByPlayerName(getCreatureName(cid))
|
local accid = getAccountNumberByPlayerName(getCreatureName(cid))
|
||||||
|
|
||||||
local type_desc = {
|
local type_desc = {
|
||||||
"itemids",
|
"itemids",
|
||||||
"pending premium (skip)",
|
"pending premium (skip)",
|
||||||
@ -34,17 +34,17 @@ function onSay(cid, words, param)
|
|||||||
description = type_desc[q_type]
|
description = type_desc[q_type]
|
||||||
end
|
end
|
||||||
print("Processing type "..q_type..": ".. description)
|
print("Processing type "..q_type..": ".. description)
|
||||||
|
|
||||||
-- 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
|
||||||
@ -77,7 +77,7 @@ function onSay(cid, words, param)
|
|||||||
|
|
||||||
-- ORDER TYPE 6 (Mounts)
|
-- ORDER TYPE 6 (Mounts)
|
||||||
-- Not supported on TFS 0.2
|
-- Not supported on TFS 0.2
|
||||||
|
|
||||||
-- 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)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
function onLogin(cid)
|
function onLogin(cid)
|
||||||
local storage = 30055 -- storage value
|
local storage = 30055 -- storage value
|
||||||
|
|
||||||
local sorcItems = {
|
local sorcItems = {
|
||||||
2460, -- Brass helmet
|
2460, -- Brass helmet
|
||||||
2465, -- Brass armor
|
2465, -- Brass armor
|
||||||
@ -39,39 +39,39 @@ function onLogin(cid)
|
|||||||
1988, -- Brown backpack
|
1988, -- Brown backpack
|
||||||
2050 -- torch
|
2050 -- torch
|
||||||
}
|
}
|
||||||
|
|
||||||
if getPlayerStorageValue(cid, storage) == -1 then
|
if getPlayerStorageValue(cid, storage) == -1 then
|
||||||
setPlayerStorageValue(cid, storage, 1)
|
setPlayerStorageValue(cid, storage, 1)
|
||||||
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
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
function onSay(cid, words, param)
|
function onSay(cid, 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.
|
||||||
local cooldown = 15 -- in seconds.
|
local cooldown = 15 -- in seconds.
|
||||||
|
|
||||||
if getPlayerStorageValue(cid, storage) <= os.time() then
|
if getPlayerStorageValue(cid, storage) <= os.time() then
|
||||||
setPlayerStorageValue(cid, storage, os.time() + cooldown)
|
setPlayerStorageValue(cid, storage, os.time() + cooldown)
|
||||||
local accid = getAccountNumberByPlayerName(getCreatureName(cid))
|
local accid = getAccountNumberByPlayerName(getCreatureName(cid))
|
||||||
|
|
||||||
local type_desc = {
|
local type_desc = {
|
||||||
"itemids",
|
"itemids",
|
||||||
"pending premium (skip)",
|
"pending premium (skip)",
|
||||||
@ -35,7 +35,7 @@ function onSay(cid, words, param)
|
|||||||
description = type_desc[q_type]
|
description = type_desc[q_type]
|
||||||
end
|
end
|
||||||
print("Processing type "..q_type..": ".. description)
|
print("Processing type "..q_type..": ".. description)
|
||||||
|
|
||||||
-- 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
|
||||||
@ -91,7 +91,7 @@ function onSay(cid, words, param)
|
|||||||
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You already have this mount!")
|
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You already have this mount!")
|
||||||
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)
|
||||||
@ -115,4 +115,4 @@ function onSay(cid, words, param)
|
|||||||
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Can only be executed once every "..cooldown.." seconds. Remaining cooldown: ".. getPlayerStorageValue(cid, storage) - os.time())
|
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Can only be executed once every "..cooldown.." seconds. Remaining cooldown: ".. getPlayerStorageValue(cid, storage) - os.time())
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
function onSay(cid, words, param)
|
function onSay(cid, 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.
|
||||||
local cooldown = 15 -- in seconds.
|
local cooldown = 15 -- in seconds.
|
||||||
|
|
||||||
if getPlayerStorageValue(cid, storage) <= os.time() then
|
if getPlayerStorageValue(cid, storage) <= os.time() then
|
||||||
setPlayerStorageValue(cid, storage, os.time() + cooldown)
|
setPlayerStorageValue(cid, storage, os.time() + cooldown)
|
||||||
local accid = getAccountNumberByPlayerName(getCreatureName(cid))
|
local accid = getAccountNumberByPlayerName(getCreatureName(cid))
|
||||||
|
|
||||||
local type_desc = {
|
local type_desc = {
|
||||||
"itemids",
|
"itemids",
|
||||||
"pending premium (skip)",
|
"pending premium (skip)",
|
||||||
@ -29,28 +29,28 @@ function onSay(cid, words, param)
|
|||||||
local q_type = result.getDataInt(orderQuery, "type")
|
local q_type = result.getDataInt(orderQuery, "type")
|
||||||
local q_itemid = result.getDataInt(orderQuery, "itemid")
|
local q_itemid = result.getDataInt(orderQuery, "itemid")
|
||||||
local q_count = result.getDataInt(orderQuery, "count")
|
local q_count = result.getDataInt(orderQuery, "count")
|
||||||
|
|
||||||
local description = "Unknown or custom type"
|
local description = "Unknown or custom type"
|
||||||
if type_desc[q_type] ~= nil then
|
if type_desc[q_type] ~= nil then
|
||||||
description = type_desc[q_type]
|
description = type_desc[q_type]
|
||||||
end
|
end
|
||||||
print("Processing type "..q_type..": ".. description)
|
print("Processing type "..q_type..": ".. description)
|
||||||
|
|
||||||
-- 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
|
||||||
--backpack check
|
-- backpack check
|
||||||
local backpack = getPlayerSlotItem(cid, 3)
|
local backpack = getPlayerSlotItem(cid, 3)
|
||||||
local gotItem = false
|
local gotItem = false
|
||||||
if(backpack and backpack.itemid > 0) then
|
if(backpack and backpack.itemid > 0) then
|
||||||
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
|
||||||
@ -100,7 +100,7 @@ function onSay(cid, words, param)
|
|||||||
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You already have this mount!")
|
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You already have this mount!")
|
||||||
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)
|
||||||
@ -120,9 +120,9 @@ function onSay(cid, words, param)
|
|||||||
else
|
else
|
||||||
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have no orders.")
|
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have no orders.")
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Can only be executed once every "..cooldown.." seconds. Remaining cooldown: ".. getPlayerStorageValue(cid, storage) - os.time())
|
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Can only be executed once every "..cooldown.." seconds. Remaining cooldown: ".. getPlayerStorageValue(cid, storage) - os.time())
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
Step 1: Copy firstitems.lua to /data/creaturescripts/scripts/ folder
|
Step 1: Copy firstitems.lua to /data/creaturescripts/scripts/ folder
|
||||||
-- Edit firstitems.lua with item IDs you want characters to start with on your server.
|
-- Edit firstitems.lua with item IDs you want characters to start with on your server.
|
||||||
|
|
||||||
Step 2: Restart OT server, and it should work. :)
|
Step 2: Restart OT server, and it should work. :)
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
killerName = "field item"
|
if killer:isPlayer() then
|
||||||
else
|
|
||||||
if killerCreature:isPlayer() then
|
|
||||||
byPlayer = 1
|
byPlayer = 1
|
||||||
else
|
else
|
||||||
local master = killerCreature:getMaster()
|
local master = killer:getMaster()
|
||||||
if master and master ~= killerCreature and master:isPlayer() then
|
if master and master ~= killer and master:isPlayer() then
|
||||||
killerCreature = master
|
killer = master
|
||||||
byPlayer = 1
|
byPlayer = 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
killerName = killerCreature:isMonster() and killerCreature:getType():getNameDescription() or killerCreature:getName()
|
killerName = killer:getName()
|
||||||
|
else
|
||||||
|
killerName = "field item"
|
||||||
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
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
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")
|
||||||
|
|
||||||
3. Place Lua file syncoutfit.lua in folder: data/creaturescripts/scripts/
|
3. Place Lua file syncoutfit.lua in folder: data/creaturescripts/scripts/
|
||||||
|
@ -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`
|
|
@ -1 +0,0 @@
|
|||||||
<globalevent name="Znote Shop" interval="30000" script="znoteshop.lua"/>
|
|
@ -1,154 +1,155 @@
|
|||||||
|
-- <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([[
|
||||||
SELECT
|
SELECT
|
||||||
MIN(`po`.`player_id`) AS `player_id`,
|
MIN(`po`.`player_id`) AS `player_id`,
|
||||||
`shop`.`id`,
|
`shop`.`id`,
|
||||||
`shop`.`type`,
|
`shop`.`type`,
|
||||||
`shop`.`itemid`,
|
`shop`.`itemid`,
|
||||||
`shop`.`count`
|
`shop`.`count`
|
||||||
FROM `players_online` AS `po`
|
FROM `players_online` AS `po`
|
||||||
INNER JOIN `players` AS `p`
|
INNER JOIN `players` AS `p`
|
||||||
ON `po`.`player_id` = `p`.`id`
|
ON `po`.`player_id` = `p`.`id`
|
||||||
INNER JOIN `znote_shop_orders` AS `shop`
|
INNER JOIN `znote_shop_orders` AS `shop`
|
||||||
ON `p`.`account_id` = `shop`.`account_id`
|
ON `p`.`account_id` = `shop`.`account_id`
|
||||||
WHERE `shop`.`type` IN(1,5,6,7)
|
WHERE `shop`.`type` IN(1,5,6,7)
|
||||||
GROUP BY `shop`.`id`
|
GROUP BY `shop`.`id`
|
||||||
]])
|
]])
|
||||||
-- Detect if we got any results
|
-- Detect if we got any results
|
||||||
if orderQuery ~= false then
|
if orderQuery ~= false then
|
||||||
local type_desc = {
|
local type_desc = {
|
||||||
"itemids",
|
"itemids",
|
||||||
"pending premium (skip)",
|
"pending premium (skip)",
|
||||||
"pending gender change (skip)",
|
"pending gender change (skip)",
|
||||||
"pending character name change (skip)",
|
"pending character name change (skip)",
|
||||||
"Outfit and addons",
|
"Outfit and addons",
|
||||||
"Mounts",
|
"Mounts",
|
||||||
"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)
|
||||||
if player ~= nil then
|
if player ~= nil then
|
||||||
|
|
||||||
local description = "Unknown or custom type"
|
local description = "Unknown or custom type"
|
||||||
if type_desc[orderType] ~= nil then
|
if type_desc[orderType] ~= nil then
|
||||||
description = type_desc[orderType]
|
description = type_desc[orderType]
|
||||||
end
|
end
|
||||||
print("Processing type "..orderType..": ".. description)
|
print("Processing type "..orderType..": ".. description)
|
||||||
print("Processing shop order for: [".. player:getName() .."] type "..orderType..": ".. description)
|
print("Processing shop order for: [".. player:getName() .."] type "..orderType..": ".. description)
|
||||||
|
|
||||||
local tile = Tile(player:getPosition())
|
|
||||||
if tile ~= nil and tile:hasFlag(TILESTATE_PROTECTIONZONE) then
|
|
||||||
-- ORDER TYPE 1 (Regular item shop products)
|
|
||||||
if orderType == 1 then
|
|
||||||
served = true
|
|
||||||
local itemType = ItemType(orderItemId)
|
|
||||||
-- Get wheight
|
|
||||||
if player:getFreeCapacity() >= itemType:getWeight(orderCount) then
|
|
||||||
local backpack = player:getSlotItem(CONST_SLOT_BACKPACK)
|
|
||||||
-- variable = (condition) and (return if true) or (return if false)
|
|
||||||
local needslots = itemType:isStackable() and math.floor(orderCount / 100) + 1 or orderCount
|
|
||||||
if backpack ~= nil and backpack:getEmptySlots(false) >= needslots then
|
|
||||||
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. orderId .. ";")
|
|
||||||
player:addItem(orderItemId, orderCount)
|
|
||||||
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() .. ".")
|
|
||||||
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() .. "!")
|
|
||||||
print("Process canceled. [".. player:getName() .."] need more space in his backpack to get " .. orderCount .. "x " .. ItemType(orderItemId):getName() .. ".")
|
|
||||||
end
|
|
||||||
else -- not enough cap
|
|
||||||
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You need more CAP to carry this order!")
|
|
||||||
print("Process canceled. [".. player:getName() .."] need more cap to carry " .. orderCount .. "x " .. ItemType(orderItemId):getName() .. ".")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- ORDER TYPE 5 (Outfit and addon)
|
local tile = Tile(player:getPosition())
|
||||||
if orderType == 5 then
|
if tile ~= nil and tile:hasFlag(TILESTATE_PROTECTIONZONE) then
|
||||||
served = true
|
-- ORDER TYPE 1 (Regular item shop products)
|
||||||
|
if orderType == 1 then
|
||||||
|
served = true
|
||||||
|
local itemType = ItemType(orderItemId)
|
||||||
|
-- Get weight
|
||||||
|
if player:getFreeCapacity() >= itemType:getWeight(orderCount) then
|
||||||
|
local backpack = player:getSlotItem(CONST_SLOT_BACKPACK)
|
||||||
|
-- variable = (condition) and (return if true) or (return if false)
|
||||||
|
local needslots = itemType:isStackable() and math.floor(orderCount / 100) + 1 or orderCount
|
||||||
|
if backpack ~= nil and backpack:getEmptySlots(false) >= needslots then
|
||||||
|
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. orderId .. ";")
|
||||||
|
player:addItem(orderItemId, orderCount)
|
||||||
|
player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received " .. orderCount .. "x " .. ItemType(orderItemId):getName() .. "!")
|
||||||
|
print("Process complete. [".. player:getName() .."] has received " .. orderCount .. "x " .. ItemType(orderItemId):getName() .. ".")
|
||||||
|
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() .. "!")
|
||||||
|
print("Process canceled. [".. player:getName() .."] need more space in his backpack to get " .. orderCount .. "x " .. ItemType(orderItemId):getName() .. ".")
|
||||||
|
end
|
||||||
|
else -- not enough cap
|
||||||
|
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You need more CAP to carry this order!")
|
||||||
|
print("Process canceled. [".. player:getName() .."] need more cap to carry " .. orderCount .. "x " .. ItemType(orderItemId):getName() .. ".")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local itemid = orderItemId
|
-- ORDER TYPE 5 (Outfit and addon)
|
||||||
local outfits = {}
|
if orderType == 5 then
|
||||||
|
served = true
|
||||||
|
|
||||||
if itemid > 1000 then
|
local itemid = orderItemId
|
||||||
local first = math.floor(itemid/1000)
|
local outfits = {}
|
||||||
table.insert(outfits, first)
|
|
||||||
itemid = itemid - (first * 1000)
|
|
||||||
end
|
|
||||||
table.insert(outfits, itemid)
|
|
||||||
|
|
||||||
for _, outfitId in pairs(outfits) do
|
if itemid > 1000 then
|
||||||
-- Make sure player don't already have this outfit and addon
|
local first = math.floor(itemid/1000)
|
||||||
if not player:hasOutfit(outfitId, orderCount) then
|
table.insert(outfits, first)
|
||||||
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. orderId .. ";")
|
itemid = itemid - (first * 1000)
|
||||||
player:addOutfit(outfitId)
|
end
|
||||||
player:addOutfitAddon(outfitId, orderCount)
|
table.insert(outfits, itemid)
|
||||||
player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received a new outfit!")
|
|
||||||
print("Process complete. [".. player:getName() .."] has recieved outfit: ["..outfitId.."] with addon: ["..orderCount.."]")
|
|
||||||
else -- Already has outfit
|
|
||||||
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You already have this outfit and addon!")
|
|
||||||
print("Process canceled. [".. player:getName() .."] already have outfit: ["..outfitId.."] with addon: ["..orderCount.."].")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- ORDER TYPE 6 (Mounts)
|
for _, outfitId in pairs(outfits) do
|
||||||
if orderType == 6 then
|
-- Make sure player don't already have this outfit and addon
|
||||||
served = true
|
if not player:hasOutfit(outfitId, orderCount) then
|
||||||
-- Make sure player don't already have this outfit and addon
|
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. orderId .. ";")
|
||||||
if not player:hasMount(orderItemId) then
|
player:addOutfit(outfitId)
|
||||||
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. orderId .. ";")
|
player:addOutfitAddon(outfitId, orderCount)
|
||||||
player:addMount(orderItemId)
|
player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received a new outfit!")
|
||||||
player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received a new mount!")
|
print("Process complete. [".. player:getName() .."] has received outfit: ["..outfitId.."] with addon: ["..orderCount.."]")
|
||||||
print("Process complete. [".. player:getName() .."] has recieved mount: ["..orderItemId.."]")
|
else -- Already has outfit
|
||||||
else -- Already has mount
|
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You already have this outfit and addon!")
|
||||||
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You already have this mount!")
|
print("Process canceled. [".. player:getName() .."] already have outfit: ["..outfitId.."] with addon: ["..orderCount.."].")
|
||||||
print("Process canceled. [".. player:getName() .."] already have mount: ["..orderItemId.."].")
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- ORDER TYPE 7 (Direct house purchase)
|
-- ORDER TYPE 6 (Mounts)
|
||||||
if orderType == 7 then
|
if orderType == 6 then
|
||||||
served = true
|
served = true
|
||||||
local house = House(orderItemId)
|
-- Make sure player don't already have this outfit and addon
|
||||||
-- Logged in player is not neccesarily the player that bough the house. So we need to load player from db.
|
if not player:hasMount(orderItemId) then
|
||||||
local buyerQuery = db.storeQuery("SELECT `name` FROM `players` WHERE `id` = "..orderCount.." LIMIT 1")
|
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. orderId .. ";")
|
||||||
if buyerQuery ~= false then
|
player:addMount(orderItemId)
|
||||||
local buyerName = result.getDataString(buyerQuery, "name")
|
player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations! You have received a new mount!")
|
||||||
result.free(buyerQuery)
|
print("Process complete. [".. player:getName() .."] has received mount: ["..orderItemId.."]")
|
||||||
if house then
|
else -- Already has mount
|
||||||
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. orderId .. ";")
|
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You already have this mount!")
|
||||||
house:setOwnerGuid(orderCount)
|
print("Process canceled. [".. player:getName() .."] already have mount: ["..orderItemId.."].")
|
||||||
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.")
|
end
|
||||||
print("Process complete. [".. buyerName .."] has recieved house: ["..house:getName().."]")
|
end
|
||||||
else
|
|
||||||
print("Process canceled. Failed to load house with ID: "..orderItemId)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
print("Process canceled. Failed to load player with ID: "..orderCount)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if not served then -- If this order hasn't been processed yet (missing type handling?)
|
-- ORDER TYPE 7 (Direct house purchase)
|
||||||
print("Znote shop: Type ["..orderType.."] not properly processed. Missing Lua code?")
|
if orderType == 7 then
|
||||||
end
|
served = true
|
||||||
else -- Not in protection zone
|
local house = House(orderItemId)
|
||||||
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have a pending shop order, please enter protection zone.')
|
-- Logged in player is not necessarily the player that bough the house. So we need to load player from db.
|
||||||
print("Skipped one shop order. Reason: Player: [".. player:getName() .."] is not inside protection zone.")
|
local buyerQuery = db.storeQuery("SELECT `name` FROM `players` WHERE `id` = "..orderCount.." LIMIT 1")
|
||||||
end
|
if buyerQuery ~= false then
|
||||||
else -- player not logged in
|
local buyerName = result.getString(buyerQuery, "name")
|
||||||
print("Skipped one shop order. Reason: Player with id [".. player_id .."] is not online.")
|
result.free(buyerQuery)
|
||||||
end
|
if house then
|
||||||
|
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. orderId .. ";")
|
||||||
|
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.")
|
||||||
|
print("Process complete. [".. buyerName .."] has received house: ["..house:getName().."]")
|
||||||
|
else
|
||||||
|
print("Process canceled. Failed to load house with ID: "..orderItemId)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
print("Process canceled. Failed to load player with ID: "..orderCount)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
until not result.next(orderQuery)
|
if not served then -- If this order hasn't been processed yet (missing type handling?)
|
||||||
result.free(orderQuery)
|
print("Znote shop: Type ["..orderType.."] not properly processed. Missing Lua code?")
|
||||||
end
|
end
|
||||||
return true
|
else -- Not in protection zone
|
||||||
end
|
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have a pending shop order, please enter protection zone.')
|
||||||
|
print("Skipped one shop order. Reason: Player: [".. player:getName() .."] is not inside protection zone.")
|
||||||
|
end
|
||||||
|
else -- player not logged in
|
||||||
|
print("Skipped one shop order. Reason: Player with id [".. player_id .."] is not online.")
|
||||||
|
end
|
||||||
|
|
||||||
|
until not result.next(orderQuery)
|
||||||
|
result.free(orderQuery)
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
@ -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
|
||||||
|
@ -1 +0,0 @@
|
|||||||
<talkaction words="!shop" script="znoteshop.lua"/>
|
|
@ -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.
|
||||||
@ -5,7 +6,7 @@ function onSay(player, words, param)
|
|||||||
|
|
||||||
if player:getStorageValue(storage) <= os.time() then
|
if player:getStorageValue(storage) <= os.time() then
|
||||||
player:setStorageValue(storage, os.time() + cooldown)
|
player:setStorageValue(storage, os.time() + cooldown)
|
||||||
|
|
||||||
local type_desc = {
|
local type_desc = {
|
||||||
"itemids",
|
"itemids",
|
||||||
"pending premium (skip)",
|
"pending premium (skip)",
|
||||||
@ -34,11 +35,11 @@ function onSay(player, words, param)
|
|||||||
description = type_desc[q_type]
|
description = type_desc[q_type]
|
||||||
end
|
end
|
||||||
print("Processing type "..q_type..": ".. description)
|
print("Processing type "..q_type..": ".. description)
|
||||||
|
|
||||||
-- 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)
|
||||||
@ -90,22 +91,21 @@ function onSay(player, words, param)
|
|||||||
|
|
||||||
-- ORDER TYPE 7 (Direct house purchase)
|
-- ORDER TYPE 7 (Direct house purchase)
|
||||||
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)
|
||||||
@ -130,4 +130,4 @@ function onSay(player, words, param)
|
|||||||
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Can only be executed once every " .. cooldown .. " seconds. Remaining cooldown: " .. player:getStorageValue(storage) - os.time())
|
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Can only be executed once every " .. cooldown .. " seconds. Remaining cooldown: " .. player:getStorageValue(storage) - os.time())
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
211
config.php
211
config.php
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user