• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 0.X Add player item for talkaction?

caquinha

Member
Joined
Aug 8, 2016
Messages
248
Solutions
1
Reaction score
24
How to add some items for parcel to offline players?

I would like to do /addcoin Darknight,50

I tried:
<talkaction log="yes" words="/addcoin" access="5" event="script" value="add_tokens.lua"/>
Code:
function onSay(cid, words, param)

    if(param ~= "") then

        local result = db.getResult("SELECT `name`, `town_id` FROM `players` WHERE `name` = " .. param)

        if (result) then

            local town_id = result:getDataString("town_id")

            local chest = doCreateItemEx(2595)

            doAddContainerItem(chest, 6527, 50)

            doPlayerSendMailByName(param, chest, town_id)

        end

    end

    return true

end


Code:
[16:39:48.393] mysql_real_query(): SELECT `name`, `town_id` FROM `players` WHERE `name` = Darknight - MYSQL ERROR: Unknown column 'Darknight' in 'where clause' (1054)

[16:39:48.394] [Error - TalkAction Interface] 
[16:39:48.394] data/talkactions/scripts/add_tokens.lua:onSay
[16:39:48.394] Description: 
[16:39:48.394] data/lib/004-database.lua:76: [Result:getDataString] Result not set!
[16:39:48.394] stack traceback:
[16:39:48.394]  [C]: in function 'error'
[16:39:48.394]  data/lib/004-database.lua:76: in function 'getDataString'
[16:39:48.394]  data/talkactions/scripts/add_tokens.lua:5: in function <data/talkactions/scripts/add_tokens.lua:1>
 
are you using tfs 0.4?
also is it a real map with ~17 cities? or custom map with ~3 cities??
it seems that your code cant define the town id to send a parcel on it!
Post automatically merged:

aaa.png
Lua:
 function onSay(cid, words, param)
if(param == "") then
    doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'please enter a vailed params.')
    doSendMagicEffect(getCreaturePosition(cid),2)
 return true
 end

                local pp = getPlayerByNameWildcard(string.explode(param, ",")[1])
                
            if not isPlayer(pp) == TRUE then     
    doSendMagicEffect(getCreaturePosition(cid),2)           
                doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'this player is offline or its an invalid name.')
                    return true
     else         
                local chest = doCreateItemEx(2595)
            doAddContainerItem(chest, 2160, 50)
            doPlayerSendMailByName(param, chest, getPlayerTown(pp))
         doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'items was sent to '..param..' succesfuly')
        doPlayerPopupFYI(pp,'you have been rewarded by '.. getPlayerName(cid)..'\nPlease go ahead to your main depot!')
        doSendMagicEffect(getCreaturePosition(pp),27)               
        end       
return true
end


i tested it on my 0.4 tfs
it works well and i added some magic effects and msgs.. also it check the player's main town by lua code not a query..
im not sure that its 100% perfect syntax bec im still newbie with LUA but it works with no error and tested on many cities
Post automatically merged:

**** about what items to be sent for the player you can modify the
doAddContainerItem(chest, 2160, 50)
its doAddContainerItem(chest, param2, param3) so you can send any item with any count you want.. but you will need to define the params 2 3 in the talkaction main function. and sorry i cant do it now
if your problem was solved please mark as solved
 
Last edited:
are you using tfs 0.4?
also is it a real map with ~17 cities? or custom map with ~3 cities??
it seems that your code cant define the town id to send a parcel on it!
Post automatically merged:

View attachment 59605
Lua:
 function onSay(cid, words, param)
if(param == "") then
    doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'please enter a vailed params.')
    doSendMagicEffect(getCreaturePosition(cid),2)
 return true
 end

                local pp = getPlayerByNameWildcard(string.explode(param, ",")[1])
              
            if not isPlayer(pp) == TRUE then   
    doSendMagicEffect(getCreaturePosition(cid),2)         
                doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'this player is offline or its an invalid name.')
                    return true
     else       
                local chest = doCreateItemEx(2595)
            doAddContainerItem(chest, 2160, 50)
            doPlayerSendMailByName(param, chest, getPlayerTown(pp))
         doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'items was sent to '..param..' succesfuly')
        doPlayerPopupFYI(pp,'you have been rewarded by '.. getPlayerName(cid)..'\nPlease go ahead to your main depot!')
        doSendMagicEffect(getCreaturePosition(pp),27)             
        end     
return true
end


i tested it on my 0.4 tfs
it works well and i added some magic effects and msgs.. also it check the player's main town by lua code not a query..
im not sure that its 100% perfect syntax bec im still newbie with LUA but it works with no error and tested on many cities
Post automatically merged:

**** about what items to be sent for the player you can modify the
doAddContainerItem(chest, 2160, 50)
its doAddContainerItem(chest, param2, param3) so you can send any item with any count you want.. but you will need to define the params 2 3 in the talkaction main function. and sorry i cant do it now
if your problem was solved please mark as solved

I'm trying to create that script to add item to offline players (with selected amount)
 
my bad i thought it was ' online ' not offline :( :(
ill rewrite it for you but not today because i got alot of things todo.. but ill make it its okay
Post automatically merged:

my bad i thought it was ' online ' not offline :( :(
ill rewrite it for you but not today because i got alot of things todo.. but ill make it its okay
ill just need a mysql code to get the player from ' players table' when he is offline <<< everything else if fine >>
 
Back
Top