• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction [/message] Prompt the hoster!

Colandus

Advanced OT User
Senator
Joined
Jun 6, 2007
Messages
2,434
Solutions
19
Reaction score
220
Location
Sweden
Hey, I've made a script that'll send a message box to the hoster :D

Simply, you write /message "hey moron, login :D and he'll receive a message box saying that :p

So, this goes to data/talkactions/scripts:
- message.lua
PHP:
local STORAGE_VALUE = 4353
local EXHAUST_TIME = 20

local ACCESS_TO_USE = 1

function onSay(cid, words, param)
	if (getPlayerGroupId(cid) >= ACCESS_TO_USE) then
		if (exhaust(cid, STORAGE_VALUE, EXHAUST_TIME) == 1) then
			if param:len() >= 5 then
				if param:len() <= 1950 then
					io.popen('msgbox.exe "' .. escapeString(param) .. '" "' .. getPlayerName(cid) .. ' [' .. os.date("%d/%m/%Y")  .. ']\"')
				else
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, message is too long.")
				end
			else
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Please enter a message consisting atleast 5 letters.")
			end
			if (MESSAGE_SAVE_LOG == true) then
				logs = io.open("./data/logs/commands.log", "a")
			    logs:write("[" .. os.date("%d/%m/%Y") .. "] " .. getPlayerName(cid) .. ": " .. words .. " " .. escapeString(param) .. "\n")
			    logs:close()
			end
		else
			doPlayerSendCancel(cid, "Please wait before sending another message to the hoster.")
		end
	else
		doPlayerSendCancel(cid, "You can not execute this command.")
	end
	return 1
end

- talkactions.xml:
PHP:
<talkaction words="/message" script="message.lua" />

- global.lua (top)
PHP:
MESSAGE_SAVE_LOG=true

- global.lua (bottom)
PHP:
function exhaust(cid, storevalue, exhausttime)
-- Exhaustion function by Alreth, v1.1 2006-06-24 01:31
-- Returns 1 if not exhausted and 0 if exhausted
    newExhaust = os.time()
    oldExhaust = getPlayerStorageValue(cid, storevalue)
    if (oldExhaust == nil or oldExhaust < 0) then
        oldExhaust = 0
    end
    if (exhausttime == nil or exhausttime < 0) then
        exhausttime = 1
    end
    diffTime = os.difftime(newExhaust, oldExhaust)
    if (diffTime >= exhausttime or diffTime < 0) then
        setPlayerStorageValue(cid, storevalue, newExhaust) 
        return 1
    else
        return 0
    end
end

Download this program:
http://claudiosoft.online.fr/msgbox.zip

Take MSGBOX.exe and place it in your servers folder (where config.lua and the distro is).

Now, I must tell you that I don't use TFS for testing so I'm unsure if escapeString will do as I think it does... So... You'll have to tell me if it works with texts like "'"*"*2'*"'2'2 xD

Regards,
Colandus
 
Last edited:
Nice, lol I googled Batch messagebox and that was the first link, did u even searched for it xD?:P but anyways nice script. But I think you should add Access to it or names so not everyplayer can spam the hoster xD

U only noob in google not in Lua =D!

Edit: removed my own post down lol xD
 
Last edited:
Just added access, was supposed to do but kinda forgot xD

And actually I didn't search MsgBox, just searched "prompt batch" me r nuubz ;)

U only noob in google not in Lua =D!

No, I didn't know it was called MsgBox lal xD
 
Last edited by a moderator:
Back
Top