Jump to content

outputchatbox


Recommended Posts

How can I make that to if someone type a command he got a message, but only he can see that message?

function onCommand(command, commandType, thePlayer)
    if string.find(command, 'vskins', player) then
        outputChatBox("#F4E607[VIP] #FFFFFF/vskin 1, /vskin 2, /vskin 3, /vskin 4", root, 244, 230, 7, true, thePlayer)
    end
end
addEventHandler("onPlayerCommand", getRootElement(), onCommand)

maybe turn into a client.lua? or there is a function for client version outputCharBox?

Link to comment
30 minutes ago, kukimuki said:

How can I make that to if someone type a command he got a message, but only he can see that message?

function onCommand(command, commandType, thePlayer)
    if string.find(command, 'vskins', player) then
        outputChatBox("#F4E607[VIP] #FFFFFF/vskin 1, /vskin 2, /vskin 3, /vskin 4", root, 244, 230, 7, true, thePlayer)
    end
end
addEventHandler("onPlayerCommand", getRootElement(), onCommand)

maybe turn into a client.lua? or there is a function for client version outputCharBox?

To make it so that only the player who executed the command can see the message, you can replace the root parameter in the outputChatBox function with thePlayer. This will make the message appear only in the chatbox of the player who executed the command.

 example code for the client-side client.lua file:
 

function onCommand(command, commandType)
    if string.find(command, 'vskins') then
        outputChatBox("#F4E607[VIP] #FFFFFF/vskin 1, /vskin 2, /vskin 3, /vskin 4", thePlayer, 244, 230, 7, true)
    end
end
addEventHandler("onClientPlayerCommand", getLocalPlayer(), onCommand)

Note that the onClientPlayerCommand event is used instead of onPlayerCommand, since this code is running on the client-side. Also, the thePlayer parameter is replaced with getLocalPlayer() which returns the player who executed the command on their local machine. Finally, the last parameter of outputChatBox is set to true, which means that the message will be visible only to the player who executed the command.

Link to comment
5 hours ago, kukimuki said:

How can I make that to if someone type a command he got a message, but only he can see that message?

function onCommand(command, commandType, thePlayer)
    if string.find(command, 'vskins', player) then
        outputChatBox("#F4E607[VIP] #FFFFFF/vskin 1, /vskin 2, /vskin 3, /vskin 4", root, 244, 230, 7, true, thePlayer)
    end
end
addEventHandler("onPlayerCommand", getRootElement(), onCommand)

maybe turn into a client.lua? or there is a function for client version outputCharBox?

i recommend this:
 

function MessageByCommand(thePlayer)
    outputChatBox("#F4E607[VIP] #FFFFFF/vskin 1, /vskin 2, /vskin 3, /vskin 4", thePlayer, 244, 230, 7, true)
end
addCommandHandler("vskins", MessageByCommand)

because when you use the onClientPlayerCommand or the onPlayerCommand the script detects all the commands and even messages in the chat and to filter them out if they are "vskins" this is not very optimized, even if the amount of optimization doesn't change the code that much it makes more sense to me since it doesn't detect each command and message and filters them, but if the player executes the command "vskins" it sends a message in the chat

Note: I think there is no onClientPlayerCommand event, only onPlayerCommand, I just didn't find it on the wiki, but I'm not sure

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