• 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!

TalkAction 0.4 /offline reward sent to depot

5lave Ots

Active Member
Joined
Oct 2, 2017
Messages
243
Solutions
1
Reaction score
40
Location
Ankrahmun
// Update 16/6 1:35 am >> improve the text message for the player to send pop up text msg with rewarded item //

@caquinha asked for a talkaction to send offline / online reward to a player

how it works?
you type / reward Player Name, Item ID or name, Item Count
if the player is offline a depot parcel is send. if he is online he will get a notify and magic effect
**you can use item id or item name. wrong ids or name will not make tfs error and will not be sent
**i had modify the maximum item count to 999 so its dosnt send +12 item spot in a parcel with 12 container spots
//tell me if i should make any thing with it//
Lua:
 function onSay(cid, words, param)
 local par = string.explode(param, ",")
    if(not par[1]) or (not par[2]) or (not par[3]) or (param == "") then
    doPlayerSendCancel(cid,'please enter a vailed params\nuse:['..words..' Player_name, Item_id, Item Count]')
    doSendMagicEffect(getCreaturePosition(cid),2)
 return true
 end
 if(not isNumber(par[3])) or (tonumber(par[3]) > 999)then
     doPlayerSendCancel(cid, 'please enter a valid numeric item count')
    return true
    end
--/reward Name,  item Id or name, Count
player = db.getResult('SELECT `name`, `town_id` FROM `players` WHERE `name` = "' .. par[1] .. '";')
  if(player:getID() == -1) then --wrong player name
    doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'invalid player name.')
return true
else
 if not isNumber(par[2])then --item name??
item = getItemIdByName(par[2], false)
p_item = par[2]
if not item then
doPlayerSendCancel(cid, 'please enter a valid item name')
    return true
    end
else
p_item =     getItemNameById(par[2])
item = par[2]
    end  
    local pp = getPlayerByNameWildcard(par[1])
    if isPlayer(pp) then
    doPlayerPopupFYI(pp,'you have been rewarded with '..par[3]..'x '..p_item..' by '.. getPlayerName(cid)..'\nPlease go ahead to your main depot!')
        doSendMagicEffect(getCreaturePosition(pp),27)
        end
                local chest = doCreateItemEx(2595)
            doAddContainerItem(chest, item, par[3])
            doPlayerSendMailByName(par[1], chest, player.town_id)
         doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'items was sent to '..par[1]..' succesfuly')      
       end     
return true
end
as always thanks for @Gesior.pl for overlook the code
Please keep UP to date with that script because in case of finding anything mistake
 
Last edited:

caquinha

Member
Joined
Aug 8, 2016
Messages
248
Solutions
1
Reaction score
24
If the player is online it is working, but if the player is off it is crashing the server
Idk why, but i tried to help with indentation:
Code:
function onSay(cid, words, param)
    local par = string.explode(param, ",")
    if(not par[1]) or (not par[2]) or (not par[3]) or (param == "") then
        doPlayerSendCancel(cid,'please enter a vailed params\nuse:['..words..' Player_name, Item_id, Item Count]')
        doSendMagicEffect(getCreaturePosition(cid),2)
        return true
    end
    if(not isNumber(par[3])) or (tonumber(par[3]) > 999)then
        doPlayerSendCancel(cid, 'please enter a valid numeric item count')
        return true
    end
    --/reward Name,  item Id or name, Count
    player = db.getResult('SELECT `name`, `town_id` FROM `players` WHERE `name` = "' .. par[1] .. '";')
    if(player:getID() == -1) then --wrong player name
        doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'invalid player name.')
        return true
    else
        if not isNumber(par[2])then --item name??
            item = getItemIdByName(par[2], false)
            p_item = par[2]
            if not item then
                doPlayerSendCancel(cid, 'please enter a valid item name')
                return true
            end
        else
            p_item = getItemNameById(par[2])
            item = par[2]
        end   
        local pp = getPlayerByNameWildcard(par[1])
        if isPlayer(pp) then
           doPlayerPopupFYI(pp,'you have been rewarded with '..par[3]..'x '..p_item..' by '.. getPlayerName(cid)..'\nPlease go ahead to your main depot!') 
           doSendMagicEffect(getCreaturePosition(pp),27)
        end
        local chest = doCreateItemEx(2595)
        doAddContainerItem(chest, item, par[3])
        doPlayerSendMailByName(par[1], chest, player.town_id)
        doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'items was sent to '..par[1]..' succesfuly')       
    end      
    return true
end
 
OP
OP
5lave Ots

5lave Ots

Active Member
Joined
Oct 2, 2017
Messages
243
Solutions
1
Reaction score
40
Location
Ankrahmun
I tested it on 0.4 and worked with O error for online and offline what tfs are you using?
Post automatically merged:

brother.. what kind of database are you using? mysql or sqlite??? also what are the town ids you have???
i think your problem with the town ids
 
Last edited:

caquinha

Member
Joined
Aug 8, 2016
Messages
248
Solutions
1
Reaction score
24
I tested it on 0.4 and worked with O error for online and offline what tfs are you using?
Post automatically merged:

brother.. what kind of database are you using? mysql or sqlite??? also what are the town ids you have???
i think your problem with the town ids

I'm using 0.4 too Fir3element/3777 (https://github.com/Fir3element/3777)
I'm using MYSQL

What are u mean with town ids? In my map i have 1,2,3,4,5,6,7
Why the problem is town ids? The column is there on players table
Are u sure it is not crashing for offline players?
 

Mauya

New Member
Joined
Jun 20, 2021
Messages
2
Reaction score
0
it worked for online and offline but im not sure about the validity of the sql line
 
OP
OP
5lave Ots

5lave Ots

Active Member
Joined
Oct 2, 2017
Messages
243
Solutions
1
Reaction score
40
Location
Ankrahmun
well.. i saw that syntax on other scripts for 0.4 >> but yeah you could be right and i still got no error under all conditions
 

caquinha

Member
Joined
Aug 8, 2016
Messages
248
Solutions
1
Reaction score
24
i found a way to don't crash:
Code:
local town_id = player:getDataInt("town_id")
 
Top