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

Lua [SQLite] -=[TFS]=- 0.4 8.60 Need script Talkaction show premium time of player

Lua:
function onPlayerCheckPremiumTime(cid, targetName)
    local target = getPlayerByNameWildcard(targetName)
    if target then
        local premiumTime = getPlayerPremiumDays(target)
        if premiumTime > 0 then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, targetName .. " it has " .. premiumTime .. " premium time days remaining.")
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, targetName .. "does not have premium time.")
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Player not found.")
    end
end

function onSay(cid, words, param)
    local t = string.explode(param, ",")
    if #t == 1 then
        onPlayerCheckPremiumTime(cid, t[1])
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Use the correct syntax: /pa playername")
    end

    return true
end
 
check
add script en talkactions/scripts premiumcheck.lua and add this code
Lua:
function onSay(cid, words, param, channel)
        if(param == '') then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
                return true
        end


        local pid = cid
        if(t[2]) then
                pid = getPlayerByNameWildcard(t[2])
                if(not pid) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[2] .. " not found.")
                        return true
                end
        end
     
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player have" .. getPlayerPremiumDays(cid) .. " premium days.")
        return true
end

in talkactions,xml add
XML:
<talkaction log="yes" words="/premium" access="5" event="script" value="premiumcheck.lua"/>

example /premium Isaac
 
Lua:
[21/09/2023 20:36:59] [Error - TalkAction Interface]
[21/09/2023 20:36:59] data/talkactions/scripts/premiumcheck.lua:onSay
[21/09/2023 20:36:59] Description:
[21/09/2023 20:36:59] data/talkactions/scripts/premiumcheck.lua:9: attempt to index global 't' (a nil value)
[21/09/2023 20:36:59] stack traceback:
[21/09/2023 20:36:59]     data/talkactions/scripts/premiumcheck.lua:9: in function <data/talkactions/scripts/premiumcheck.lua:1>
 
Lua:
[21/09/2023 20:36:59] [Error - TalkAction Interface]
[21/09/2023 20:36:59] data/talkactions/scripts/premiumcheck.lua:onSay
[21/09/2023 20:36:59] Description:
[21/09/2023 20:36:59] data/talkactions/scripts/premiumcheck.lua:9: attempt to index global 't' (a nil value)
[21/09/2023 20:36:59] stack traceback:
[21/09/2023 20:36:59]     data/talkactions/scripts/premiumcheck.lua:9: in function <data/talkactions/scripts/premiumcheck.lua:1>
in which of the two scripts?
 

Similar threads

Back
Top