Jump to content

private message


Castillo

Recommended Posts

hey, i added a PM system into my player menu but the problem is that players can send empty messages so im trying to cancel that but dunno why dosnt works, here is my code.

addEvent ("sendMsg", true)
addEventHandler ("sendMsg", getRootElement(),
function(msg,client)
local givenplayer = getPlayerFromName ( client )	
if( givenplayer ) then
if msg == nil then
outputChatBox ( "* PM from " .. getPlayerName(source) .. ": " ..msg.. ".", givenplayer, 243, 151, 12 )
else
outputChatBox ("Error: You cant send empty messages.", source, 255, 0, 0, false)
end	
end
end)

Thanks in advance.

Link to comment

If msg is always string then it will never be nil. You can check if string is empty by checking its length (with #) or "".

if msg == "" then
-- message is empty...
end
-- OR
if #msg == 0 then
-- message is empty...
end

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...