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

Npc Scrip Request

skrm

New Member
Joined
Mar 15, 2008
Messages
67
Reaction score
0
Hey,
Im trying to find a script where players pay an npc to broadcast a message (im using tfs 0.3.2).

If anyone could make this script i would be very happy :)
 
So you still waiting ;)

I found script Talkaction made by Colandus
Code:
-- Script 100% by Colandus
local levelReq = 150 -- Level needed to use the command.
local minChars = 5 -- How many characters may you write as minumum?
local basePrice = 1000 -- Base price, will be multiplied with the price made by a formula in the script.
 
-- Exhaustion Settings
local useExhaust = true
local storageValue = 3435
local exhaustTime = 1 * 60 -- 1 minute
 
--[[ Example:
You are level 100 and you are going to write a sentence of 45 characters with base price 1000.
1000 + (100 * 5) =
1000 + 500 = 1500
1500 * 45 = 67500
The message of 45 characters, broadcasted by a level 100 with the base price as 1000 would cost the player 67500 gold (67.5k),.
]]--
 
function onSay(cid, words, param)
    local letterPrice = basePrice + getPlayerLevel(cid) * 2
    local broadcastPrice = letterPrice * param:len()
    if getPlayerLevel(cid) < levelReq then
        doPlayerSendCancel(cid,"Sorry, you need to be atleast level " .. levelReq .. " to use this command.")
    elseif (useExhaust and isExhausted(cid, storageValue, exhaustTime) == TRUE) then
        doPlayerSendCancel(cid, "Sorry, you need to wait before broadcasting another message.")
    elseif param:len() < minChars then
        doPlayerSendCancel(cid,"Sorry, you need to enter atleast " .. minChars .. " characters. Each character will cost you " .. letterPrice .. " gold coins.")
    elseif doPlayerRemoveMoney(cid, broadcastPrice) == FALSE then
        doPlayerSendCancel(cid, "Sorry, you have not enough money. This message would have costed you " .. broadcastPrice .. " gold coins.")
    else
        doPlayerSendTextMessage(cid, 24, "Broadcast successfully sent. Your message contained " .. string.len(param) .. " characters and costed you " .. broadcastPrice .. " gold coins.")
        broadcastMessage(getPlayerName(cid) .. " [" .. getPlayerLevel(cid) .. "]: " .. param, MESSAGE_STATUS_WARNING)
        doPlayerSendTextMessage(cid, 25, "!broadcast \"" .. param)
        setExhaust(cid, storageValue)
    end
end

Including these functions:
Code:
function setExhaust(cid, storage)
    setPlayerStorageValue(cid, storage, os.time())
end

function isExhausted(cid, storage, exhaust)
    local exhaustTime = getPlayerStorageValue(cid, storage)
    if exhaustTime == -1 then
        return FALSE
    end
    local isExhausted = os.time() - exhaustTime < exhaust
    return isExhausted and TRUE or FALSE
end

To use it, just write !broadcast "message.
 
Broadcasting isn't good idea, people would spam, other new players will think that this is another noob server so I wouldn't use that if I were you. Sorry for offtopic.
 
So you still waiting ;)

I found script Talkaction made by Colandus
Code:
-- Script 100% by Colandus
local levelReq = 150 -- Level needed to use the command.
local minChars = 5 -- How many characters may you write as minumum?
local basePrice = 1000 -- Base price, will be multiplied with the price made by a formula in the script.
 
-- Exhaustion Settings
local useExhaust = true
local storageValue = 3435
local exhaustTime = 1 * 60 -- 1 minute
 
--[[ Example:
You are level 100 and you are going to write a sentence of 45 characters with base price 1000.
1000 + (100 * 5) =
1000 + 500 = 1500
1500 * 45 = 67500
The message of 45 characters, broadcasted by a level 100 with the base price as 1000 would cost the player 67500 gold (67.5k),.
]]--
 
function onSay(cid, words, param)
    local letterPrice = basePrice + getPlayerLevel(cid) * 2
    local broadcastPrice = letterPrice * param:len()
    if getPlayerLevel(cid) < levelReq then
        doPlayerSendCancel(cid,"Sorry, you need to be atleast level " .. levelReq .. " to use this command.")
    elseif (useExhaust and isExhausted(cid, storageValue, exhaustTime) == TRUE) then
        doPlayerSendCancel(cid, "Sorry, you need to wait before broadcasting another message.")
    elseif param:len() < minChars then
        doPlayerSendCancel(cid,"Sorry, you need to enter atleast " .. minChars .. " characters. Each character will cost you " .. letterPrice .. " gold coins.")
    elseif doPlayerRemoveMoney(cid, broadcastPrice) == FALSE then
        doPlayerSendCancel(cid, "Sorry, you have not enough money. This message would have costed you " .. broadcastPrice .. " gold coins.")
    else
        doPlayerSendTextMessage(cid, 24, "Broadcast successfully sent. Your message contained " .. string.len(param) .. " characters and costed you " .. broadcastPrice .. " gold coins.")
        broadcastMessage(getPlayerName(cid) .. " [" .. getPlayerLevel(cid) .. "]: " .. param, MESSAGE_STATUS_WARNING)
        doPlayerSendTextMessage(cid, 25, "!broadcast \"" .. param)
        setExhaust(cid, storageValue)
    end
end

Including these functions:
Code:
function setExhaust(cid, storage)
    setPlayerStorageValue(cid, storage, os.time())
end

function isExhausted(cid, storage, exhaust)
    local exhaustTime = getPlayerStorageValue(cid, storage)
    if exhaustTime == -1 then
        return FALSE
    end
    local isExhausted = os.time() - exhaustTime < exhaust
    return isExhausted and TRUE or FALSE
end

To use it, just write !broadcast "message.

I dont think you need to use the " :p


14:57 Test [155]: !broadcast "Testing
14:57 Test [155]: "Testing

14:59 Test [155]: !broadcast Testing
14:59 Test [155]: Testing

:D

Other than that, thanks for the script I needed it too :thumbup: +Rep

And @triamerka~

Well, considering this script lets you configure the broadcasting exhaust, price and lvl needed, if you configure them correctly you can avoid spam, and not necesarily servers are noob for using it, only if used wrong ;).

Cheers~
 
Ive just updated to 0.3.3
and now the script wont work anymore,

Code:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/paybroadcast.lua:onSay

data/talkactions/scripts/paybroadcast.lua:24 attempt to call global 'isExhausted' <a nil value>
stack traceback:
	data talkactions/scripts/paybroadcast.lua:24: in function <data/talkactions/scripts/paybroadcast.lua:19>

anyone got a solution? I give rep!!!
 
Back
Top