I need to know how to make a script that comes with ZnoteACC (for TFS) work on OTHire.
I managed to get the shop system working to where you can buy points and items from the shop. However I cannot use the command "!shop" in-game to receive the item. I tried to use the TFS XML and LUA files but that (as expected) did not work.
Here are the XML and LUA files.
znoteshop.lua (for TFS)
talkactions.xml
As you can see, I added:
<talkaction words="!shop" access="0" script="znoteshop.lua"/>
at the very bottom of talkactions.xml
Any help would be appreciated, thanks.
I managed to get the shop system working to where you can buy points and items from the shop. However I cannot use the command "!shop" in-game to receive the item. I tried to use the TFS XML and LUA files but that (as expected) did not work.
Here are the XML and LUA files.
znoteshop.lua (for TFS)
Code:
-- Znote Shop v1.0 for Znote AAC on TFS 0.2.13+ Mystic Spirit.
function onSay(cid, words, param)
local storage = 54073 -- Make sure to select non-used storage. This is used to prevent SQL load attacks.
local cooldown = 15 -- in seconds.
if getPlayerStorageValue(cid, storage) <= os.time() then
setPlayerStorageValue(cid, storage, os.time() + cooldown)
local accid = getAccountNumberByPlayerName(getCreatureName(cid))
-- Create the query
local orderQuery = db.storeQuery("SELECT `id`, `type`, `itemid`, `count` FROM `znote_shop_orders` WHERE `account_id` = " .. accid .. " LIMIT 1;")
-- Detect if we got any results
if orderQuery ~= false then
-- Fetch order values
local q_id = result.getDataInt(orderQuery, "id")
local q_type = result.getDataInt(orderQuery, "type")
local q_itemid = result.getDataInt(orderQuery, "itemid")
local q_count = result.getDataInt(orderQuery, "count")
result.free(orderQuery)
-- ORDER TYPE 1 (Regular item shop products)
if q_type == 1 then
-- Get wheight
local playerCap = getPlayerFreeCap(cid)
local itemweight = getItemWeight(q_itemid, q_count)
if playerCap >= itemweight then
db.query("DELETE FROM `znote_shop_orders` WHERE `id` = " .. q_id .. ";")
doPlayerAddItem(cid, q_itemid, q_count)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have recieved ".. q_count .." "..getItemName(q_itemid).."(s)!")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Need more CAP!")
end
end
-- Add custom order types here
-- Type 2 is reserved for premium days and is handled on website, not needed here.
-- Type 3 is reserved for character gender(sex) change and is handled on website as well.
-- So use type 4+ for custom stuff, like etc packages.
-- if q_type == 4 then
-- end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You have no orders.")
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Can only be executed once every "..cooldown.." seconds. Remaining cooldown: ".. getPlayerStorageValue(cid, storage) - os.time())
end
return false
end
talkactions.xml
Code:
<?xml version="1.0"?>
<talkactions>
<!-- Gods -->
<talkaction words="/i" access="3" filter="first word" script="createitembyid.lua"/>
<talkaction words="/ifr" access="3" filter="first word" script="createitembyidfront.lua"/>
<talkaction words="/n" access="3" filter="first word" script="createitembyname.lua"/>
<talkaction words="/nfr" access="3" filter="first word" script="createitembynamefront.lua"/>
<talkaction words="/a" access="3" filter="first word" script="teleportntiles.lua"/>
<talkaction words="/goto" access="3" filter="first word" script="teleportto.lua"/>
<talkaction words="/owner" access="3" filter="first word" script="sethouseowner.lua"/>
<talkaction words="/save" access="3" script="saveserver.lua"/>
<talkaction words="/cleanhouses" access="3" filter="first word" script="housecleaning.lua"/>
<talkaction words="/raid" access="3" filter="first word" function="forceRaid"/>
<talkaction words="/s" access="3" filter="first word" function="placeNpc"/>
<talkaction words="/openserver" access="3" filter="first word" script="openserver.lua"/>
<talkaction words="/closeserver" access="3" filter="first word" script="closeserver.lua"/>
<talkaction words="/shutdown" access="3" filter="first word" script="shutdown.lua"/>
<talkaction words="/serverdiag" access="3" filter="first word" function="serverDiagnostic"/>
<talkaction words="/c" access="3" filter="first word" script="teleporthere.lua"/>
<talkaction words="/m" access="3" filter="first word" script="placemonster.lua"/>
<talkaction words="/r" access="3" filter="first word" script="removething.lua"/>
<talkaction words="/kick" access="3" filter="first word" script="kickplayer.lua"/>
<talkaction words="/reload" access="3" filter="first word" script="reload.lua"/>
<talkaction words="/ban" access="3" filter="first word" script="banmanager.lua"/>
<!-- Gamemasters -->
<talkaction words="/up" access="2" filter="first word" script="floorchange.lua"/>
<talkaction words="/down" access="2" filter="first word" script="floorchange.lua"/>
<talkaction words="/t" access="2" script="teleportmasterpos.lua"/>
<talkaction words="/town" access="2" filter="first word" script="teleporttotown.lua"/>
<talkaction words="/summon" access="2" filter="first word" script="placesummon.lua"/>
<talkaction words="/refreshmap" access="2" filter="first word" script="refreshmap.lua"/>
<talkaction words="/bc" access="2" filter="first word" script="broadcastclass.lua"/>
<talkaction words="/invisible" access="2" filter="first word" script="gminvisible.lua"/>
<talkaction words="/info" access="2" filter="first word" script="getinfo.lua"/>
<talkaction words="/z" access="2" filter="first word" script="testeffect.lua"/>
<!-- Tutors -->
<talkaction words="/serverinfo" access="1" script="serverinfo.lua"/>
<talkaction words="/getonline" access="1" filter="first word" script="accessonlinelist.lua"/>
<talkaction words="/gethouse" access="1" filter="first word" script="gethouse.lua"/>
<!-- Players -->
<talkaction words="!sellhouse" access="0" function="sellHouse"/>
<talkaction words="!buyhouse" access="0" script="buyhouse.lua"/>
<talkaction words="!leavehouse" access="0" script="leavehouse.lua"/>
<talkaction words="!houseinfo" access="0" script="houseinfo.lua"/>
<talkaction words="!online" access="0" script="onlinelist.lua"/>
<talkaction words="!frags" access="0" script="frags.lua"/>
<talkaction words="!shop" access="0" script="znoteshop.lua"/>
</talkactions>
As you can see, I added:
<talkaction words="!shop" access="0" script="znoteshop.lua"/>
at the very bottom of talkactions.xml
Any help would be appreciated, thanks.