Morris
New Member
- Joined
- Sep 10, 2009
- Messages
- 4
- Reaction score
- 0
So I've been trying to get a NPC Dicer to my server, and I found a script, (wich isn't working).
I've read a little about Lua and tried to fix the script(I probably just butchered the thing), but my experience is way to low.
So if someone have the time to look over the script and maybe see if they can help, that would be awesome.
Also, I'm using Tfs 1.2 Client 10.77
Thanks in Advance.
/Morris
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid) npcHandlernCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandlernCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandlernCreatureSay(cid, type, msg) end
function onThink() npcHandlernThink() end
function creatureSayCallback ( cid , type , msg )
if ( not npcHandler : isFocused ( cid )) then
return false
end
Local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
Local coins = {[ 2148 ] = 1 , [ 2152 ] = 100 , [ 2160 ] = 10000 }
function countMoneyOnPos ( pos )
Local money = 0
for stack = 1 , 50 do
pos . stackpos = stack
Local item = getThingFromPos ( pos )
if item and item . uid > 0 then
if coins [ item . itemid ] then
money = money + coins [ item . itemid ] * item . type
end
end
end
return money
end
Local posCoal = { x = 32394 , and = 32192 , z = 7 } - POSI Ca O DO COAL , GOLD DEVE ONDE OR BE
Local posNpc = { x = 32394 , and = 32191 , z = 7 } - POSI Ca O DO NPC
Local pos = getPosByDir ( getThingPos ( cid ), getCreatureLookDirection ( cid ), 1 ) - N Ã OR ALTER
if msgcontains ( msg , 'l' ) or msgcontains ( msg , 'L' ) or msgcontains ( msg , 'low' ) or msgcontains ( msg , 'Low' ) Then
if countMoneyOnPos ( pos ) > 0 then
if math . random ( 1 , 6 ) <= 3 then a
doPlayerAddMoney ( cid , countMoneyOnPos ( pos ) * 2 )
doRemoveItem ( getTileItemById ( pos , 2148 ). uid )
repeat
Until not doRemoveItem ( getTileItemById ( pos , 2148 ). uid )
doRemoveItem ( getTileItemById ( pos , 2152 ). uid )
repeat
Until not doRemoveItem ( getTileItemById ( pos , 2152 ). uid )
doRemoveItem ( getTileItemById ( pos , 2160 ). uid )
repeat
Until not doRemoveItem ( getTileItemById ( pos , 2160 ). uid )
doSendMagicEffect ( posNpc , 26 )
doSendMagicEffect ( posNpc , 28 )
doCreatureSay ( getNpcId (), getCreatureName ( cid ) .. 'Tirou or number' .. math . random ( 1 , 3 ) .. 'parabéns!' , TALKTYPE_ORANGE_1 )
else
doRemoveItem ( getTileItemById ( pos , 2148 ). uid )
repeat
Until not doRemoveItem ( getTileItemById ( pos , 2148 ). uid )
doRemoveItem ( getTileItemById ( pos , 2152 ). uid )
repeat
Until not doRemoveItem ( getTileItemById ( pos , 2152 ). uid )
doRemoveItem ( getTileItemById ( pos , 2160 ). uid )
repeat
Until not doRemoveItem ( getTileItemById ( pos , 2160 ). uid )
doSendMagicEffect ( posNpc , 2 )
doSendMagicEffect ( posNpc , 26 )
doCreatureSay ( getNpcId (), getCreatureName ( cid ) .. 'Tirou or number' .. math . random ( 4 , 6 ) .. 'patent novamente!' , TALKTYPE_ORANGE_1 )
end
else
doCreatureSay ( getNpcId (), getCreatureName ( cid ) .. ', put uma quantia of gold container começar not betting!' , TALKTYPE_ORANGE_1 )
end
msgcontains elseif ( msg , 'h' ) or msgcontains ( msg , 'H' ) or msgcontains ( msg , 'high' ) or msgcontains ( msg , 'High' ) then
if countMoneyOnPos ( pos ) > 0 then
if math . random ( 1 , 6 ) <= 3 then a
doPlayerAddMoney ( cid , countMoneyOnPos ( pos ) * 2 )
doRemoveItem ( getTileItemById ( pos , 2148 ). uid )
repeat
Until not doRemoveItem ( getTileItemById ( pos , 2148 ). uid )
doRemoveItem ( getTileItemById ( pos , 2152 ). uid )
repeat
Until not doRemoveItem ( getTileItemById ( pos , 2152 ). uid )
doRemoveItem ( getTileItemById ( pos , 2160 ). uid )
repeat
Until not doRemoveItem ( getTileItemById ( pos , 2160 ). uid )
doSendMagicEffect ( posNpc , 26 )
doSendMagicEffect ( posNpc , 28 )
doCreatureSay ( getNpcId (), getCreatureName ( cid ) .. 'Tirou or number' .. math . random ( 4 , 6 ) .. 'parabéns!' , TALKTYPE_ORANGE_1 )
else
doRemoveItem ( getTileItemById ( pos , 2148 ). uid )
repeat
Until not doRemoveItem ( getTileItemById ( pos , 2148 ). uid )
doRemoveItem ( getTileItemById ( pos , 2152 ). uid )
repeat
Until not doRemoveItem ( getTileItemById ( pos , 2152 ). uid )
doRemoveItem ( getTileItemById ( pos , 2160 ). uid )
repeat
Until not doRemoveItem ( getTileItemById ( pos , 2160 ). uid )
doSendMagicEffect ( posNpc , 2 )
doSendMagicEffect ( posNpc , 26 )
doCreatureSay ( getNpcId (), getCreatureName ( cid ) .. 'Tirou or number' .. math . random ( 1 , 3 ) .. 'patent novamente!' , TALKTYPE_ORANGE_1 )
end
else
doCreatureSay ( getNpcId (), getCreatureName ( cid ) .. ', put uma quantia of gold container começar not betting!' , TALKTYPE_ORANGE_1 )
end
end
return true
end
npcHandler : setCallback ( CALLBACK_MESSAGE_DEFAULT , creatureSayCallback )
npcHandler : AddModule ( FocusModule : new ())
I've read a little about Lua and tried to fix the script(I probably just butchered the thing), but my experience is way to low.
So if someone have the time to look over the script and maybe see if they can help, that would be awesome.
Also, I'm using Tfs 1.2 Client 10.77
Thanks in Advance.
/Morris
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid) npcHandlernCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandlernCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandlernCreatureSay(cid, type, msg) end
function onThink() npcHandlernThink() end
function creatureSayCallback ( cid , type , msg )
if ( not npcHandler : isFocused ( cid )) then
return false
end
Local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
Local coins = {[ 2148 ] = 1 , [ 2152 ] = 100 , [ 2160 ] = 10000 }
function countMoneyOnPos ( pos )
Local money = 0
for stack = 1 , 50 do
pos . stackpos = stack
Local item = getThingFromPos ( pos )
if item and item . uid > 0 then
if coins [ item . itemid ] then
money = money + coins [ item . itemid ] * item . type
end
end
end
return money
end
Local posCoal = { x = 32394 , and = 32192 , z = 7 } - POSI Ca O DO COAL , GOLD DEVE ONDE OR BE
Local posNpc = { x = 32394 , and = 32191 , z = 7 } - POSI Ca O DO NPC
Local pos = getPosByDir ( getThingPos ( cid ), getCreatureLookDirection ( cid ), 1 ) - N Ã OR ALTER
if msgcontains ( msg , 'l' ) or msgcontains ( msg , 'L' ) or msgcontains ( msg , 'low' ) or msgcontains ( msg , 'Low' ) Then
if countMoneyOnPos ( pos ) > 0 then
if math . random ( 1 , 6 ) <= 3 then a
doPlayerAddMoney ( cid , countMoneyOnPos ( pos ) * 2 )
doRemoveItem ( getTileItemById ( pos , 2148 ). uid )
repeat
Until not doRemoveItem ( getTileItemById ( pos , 2148 ). uid )
doRemoveItem ( getTileItemById ( pos , 2152 ). uid )
repeat
Until not doRemoveItem ( getTileItemById ( pos , 2152 ). uid )
doRemoveItem ( getTileItemById ( pos , 2160 ). uid )
repeat
Until not doRemoveItem ( getTileItemById ( pos , 2160 ). uid )
doSendMagicEffect ( posNpc , 26 )
doSendMagicEffect ( posNpc , 28 )
doCreatureSay ( getNpcId (), getCreatureName ( cid ) .. 'Tirou or number' .. math . random ( 1 , 3 ) .. 'parabéns!' , TALKTYPE_ORANGE_1 )
else
doRemoveItem ( getTileItemById ( pos , 2148 ). uid )
repeat
Until not doRemoveItem ( getTileItemById ( pos , 2148 ). uid )
doRemoveItem ( getTileItemById ( pos , 2152 ). uid )
repeat
Until not doRemoveItem ( getTileItemById ( pos , 2152 ). uid )
doRemoveItem ( getTileItemById ( pos , 2160 ). uid )
repeat
Until not doRemoveItem ( getTileItemById ( pos , 2160 ). uid )
doSendMagicEffect ( posNpc , 2 )
doSendMagicEffect ( posNpc , 26 )
doCreatureSay ( getNpcId (), getCreatureName ( cid ) .. 'Tirou or number' .. math . random ( 4 , 6 ) .. 'patent novamente!' , TALKTYPE_ORANGE_1 )
end
else
doCreatureSay ( getNpcId (), getCreatureName ( cid ) .. ', put uma quantia of gold container começar not betting!' , TALKTYPE_ORANGE_1 )
end
msgcontains elseif ( msg , 'h' ) or msgcontains ( msg , 'H' ) or msgcontains ( msg , 'high' ) or msgcontains ( msg , 'High' ) then
if countMoneyOnPos ( pos ) > 0 then
if math . random ( 1 , 6 ) <= 3 then a
doPlayerAddMoney ( cid , countMoneyOnPos ( pos ) * 2 )
doRemoveItem ( getTileItemById ( pos , 2148 ). uid )
repeat
Until not doRemoveItem ( getTileItemById ( pos , 2148 ). uid )
doRemoveItem ( getTileItemById ( pos , 2152 ). uid )
repeat
Until not doRemoveItem ( getTileItemById ( pos , 2152 ). uid )
doRemoveItem ( getTileItemById ( pos , 2160 ). uid )
repeat
Until not doRemoveItem ( getTileItemById ( pos , 2160 ). uid )
doSendMagicEffect ( posNpc , 26 )
doSendMagicEffect ( posNpc , 28 )
doCreatureSay ( getNpcId (), getCreatureName ( cid ) .. 'Tirou or number' .. math . random ( 4 , 6 ) .. 'parabéns!' , TALKTYPE_ORANGE_1 )
else
doRemoveItem ( getTileItemById ( pos , 2148 ). uid )
repeat
Until not doRemoveItem ( getTileItemById ( pos , 2148 ). uid )
doRemoveItem ( getTileItemById ( pos , 2152 ). uid )
repeat
Until not doRemoveItem ( getTileItemById ( pos , 2152 ). uid )
doRemoveItem ( getTileItemById ( pos , 2160 ). uid )
repeat
Until not doRemoveItem ( getTileItemById ( pos , 2160 ). uid )
doSendMagicEffect ( posNpc , 2 )
doSendMagicEffect ( posNpc , 26 )
doCreatureSay ( getNpcId (), getCreatureName ( cid ) .. 'Tirou or number' .. math . random ( 1 , 3 ) .. 'patent novamente!' , TALKTYPE_ORANGE_1 )
end
else
doCreatureSay ( getNpcId (), getCreatureName ( cid ) .. ', put uma quantia of gold container começar not betting!' , TALKTYPE_ORANGE_1 )
end
end
return true
end
npcHandler : setCallback ( CALLBACK_MESSAGE_DEFAULT , creatureSayCallback )
npcHandler : AddModule ( FocusModule : new ())