Castillo Posted August 12, 2010 Posted August 12, 2010 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. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
50p Posted August 12, 2010 Posted August 12, 2010 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 - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
dzek (varez) Posted August 12, 2010 Posted August 12, 2010 post whole code maybe? or try if msg==nil or msg=='' or msg==false then Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
Castillo Posted August 12, 2010 Author Posted August 12, 2010 yea that worked, thanks. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
LonelyRoad Posted August 12, 2010 Posted August 12, 2010 Solid, it's irrelevant here to your question, but read your code more carefully, specifically line 6 and think about how it would work. Regards.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now