Jump to content

Problem with command and outputChatbox


Overkillz

Recommended Posts

Posted

Hi, I made a easy script with commands and outputchatbox but, I will like to block it if the player is muted, so If the player is muted, he cant use it.

What is wrong here ?

function hi (player) 
    outputChatBox("#FFFFFF<"..getPlayerName(player).."#ffffff>:Hey #00ffffGuys !",root,255,255,255,true) 
    if isPlayerMuted(source) then  
    cancelEvent() 
    outputChatBox("You are muted.",source, 255, 255, 0,true) 
    return 
end 
addCommandHandler ( "hi", hi ) 

Regards.

Posted (edited)

EDIT: ohh i should have noticed that

  
function hi (player) 
    if not isPlayerMuted(player) then 
    outputChatBox("#FFFFFF<"..getPlayerName(player).."#ffffff>:Hey #00ffffGuys !",root,255,255,255,true) 
    else 
    cancelEvent() 
    outputChatBox("You are muted.",player, 255, 255, 0,true) 
    end 
end 
addCommandHandler ( "hi", hi ) 
  

Edited by Guest

Ingame Name: Arnold

If you need my help, contact me on Skype @bshr.ara

NOTE:DO NOT ASK ME FOR SCRIPTS, ASK ME FOR HELP

Posted
hmm, the code seems to be fine, are you sure it's placed server side?, wait i will test it and post the results.
    "Overkillz" version="1.0" type="script"/>   
    

Doesn't work ;(

Posted
function hi (player) 
    if not isPlayerMuted(player) then 
        outputChatBox("#FFFFFF<"..getPlayerName(player).."#ffffff>:Hey #00ffffGuys !",root,255,255,255,true) 
    else 
        outputChatBox("You are muted.",player, 255, 255, 0,true) 
    end 
end 
addCommandHandler ( "hi", hi ) 

Please do not PM me with scripting related question nor support, use the forums instead.

Posted

Make the check before you output the message. Also you should use player instead of source for the player source.

function exampleCommand_Handler(thePlayer, theCMD) 
    if(isPlayerMuted(thePlayer) ~= true) then 
        outputChatBox("<"..getPlayerName(thePlayer).."#FFFFFF>: #00FFFFHello World!", root, 255, 255, 255, true) 
    else 
        outputChatBox("You're muted and can not use this command.") 
        cancelEvent() 
    end 
end 
addCommandHandler("hi", exampleCommand_Handler, false) 
-- False tells the command handler that it is NOT case-sensitive. 

Edit:

DNL beat me to it :lol:

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

Posted

Thanks you guys, and with the PM System ?

function privateMessage(player, command, toplayername, ...) 
local words = { ... } 
local message = table.concat(words," ") 
    if toplayername then 
        if (findPlayerByName (toplayername)) then 
        toplayer = (findPlayerByName (toplayername)) 
            if not (toplayer == player) then 
                if message then 
                    outputChatBox("#FF0000[PM]#00aaff Message to #FFFFFF" .. getPlayerName(toplayer) .. "#FFFFFF: " .. message, player, 255, 255, 255, true) 
                    outputChatBox("#FF0000[PM]#00aaff Message from #FFFFFF" .. getPlayerName(player) .. "#FFFFFF: " .. message, toplayer, 255, 255, 255, true) 
                else 
                    outputChatBox("#FF0000[PM]#00aaff Invalid syntax! Usage:#FFFFFF /pm [partical player name] [message]", player, 255, 255, 255, true) 
                    return false 
                end 
            else 
                outputChatBox("#FF0000[PM]#00aaff You cannot PM yourself#FFFFFF!", player, 255, 255, 255, true) 
                return false 
            end 
        else 
            outputChatBox("#FF0000[PM]#00aaff Player not found! #FFFFFF("..toplayername..").", player, 255, 255, 255, true) 
            return false 
        end 
    else 
        outputChatBox("#FF0000[PM]#00aaff Invalid syntax! Usage:#FFFFFF /pm [partical player name] [message]", player, 255, 255, 255, true) 
        return false 
    end 
end 
addCommandHandler("pm", privateMessage) 

Posted

You can try this;

function privateMessage(player, command, toplayername, ...) 
local words = { ... } 
local message = table.concat(words," ") 
    if(isPlayerMuted(player) ~= true) then 
        if toplayername then 
            if (findPlayerByName (toplayername)) then 
            toplayer = (findPlayerByName (toplayername)) 
                if not (toplayer == player) then 
                    if message then 
                        outputChatBox("#FF0000[PM]#00aaff Message to #FFFFFF" .. getPlayerName(toplayer) .. "#FFFFFF: " .. message, player, 255, 255, 255, true) 
                        outputChatBox("#FF0000[PM]#00aaff Message from #FFFFFF" .. getPlayerName(player) .. "#FFFFFF: " .. message, toplayer, 255, 255, 255, true) 
                    else 
                        outputChatBox("#FF0000[PM]#00aaff Invalid syntax! Usage:#FFFFFF /pm [partical player name] [message]", player, 255, 255, 255, true) 
                        return false 
                    end 
                else 
                    outputChatBox("#FF0000[PM]#00aaff You cannot PM yourself#FFFFFF!", player, 255, 255, 255, true) 
                    return false 
                end 
            else 
                outputChatBox("#FF0000[PM]#00aaff Player not found! #FFFFFF("..toplayername..").", player, 255, 255, 255, true) 
                return false 
            end 
        else 
            outputChatBox("#FF0000[PM]#00aaff Invalid syntax! Usage:#FFFFFF /pm [partical player name] [message]", player, 255, 255, 255, true) 
            return false 
        end 
    else 
        outputChatBox("#FF0000[PM]:#00AAFF Failed to send PM - you're muted!", player, 255, 255, 255, true) 
    end 
end 
addCommandHandler("pm", privateMessage) 

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

Posted
Work fine, thanks so much <3

Glad I could be of help :)

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

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...