introzen

Server-side OnPlayerCommand event

Recommended Posts

Posted (edited)
7 minutes ago, robearded said:

 

You have to catch it as custom event, not like normal server events.

[RemoteEvent("command")]

Still does not work. And so I guess we're back at where we started, without an normal server event where you can intercept and cancel the player's command if requirements are not met.

What you're suggesting, I can already achieve by calling my own remote event when player writes the command.

Edited by introzen

Share this post


Link to post
Share on other sites
Posted (edited)
11 minutes ago, introzen said:

Still does not work. And so I guess we're back at where we started, without an normal server event where you can intercept and cancel the player's command if requirements are not met.

What you're suggesting, I can already achieve by calling my own remote event when player writes the command.

Easiest way would be do edit that script where that specific command is processed and just return before doing anything if the requirements are not met. Using playerCommand on JS won't let you cancel the event anyway. You're supposed to do the checks inside the method of the command, not inside another pre command method.

Edited by robearded

Share this post


Link to post
Share on other sites
2 minutes ago, robearded said:

Easiest way would be do edit that script where that specific command is processed and just return before doing anything if the requirements are not met.

Yep, will have to do that I guess. Still think it should be implented though.

Share this post


Link to post
Share on other sites
1 minute ago, introzen said:

Yep, will have to do that I guess. Still think it should be implented though.

Probably it will be implemented (maybe if you're using already compiled scripts by someone else and you want to limit the access to its commands?) but I don't think it's a priority for now as most resources that are posted have their code available which you can edit and add your own checks.

Share this post


Link to post
Share on other sites
Posted (edited)
2 minutes ago, robearded said:

Probably it will be implemented (maybe if you're using already compiled scripts by someone else and you want to limit the access to its commands?) but I don't think it's a priority for now as most resources that are posted have their code available which you can edit and add your own checks.

Nah, I don't use any other code except mine. I can just see the usability of this. E.g. if you want to disable commands all together, you could check for a bool on the Event rather than in every command existing in the server.

Or if you'd like to prevent users that are not logged in from executing commands. Rather than checking if the user is logged in every single command, you could perform one check in the event.

Edited by introzen

Share this post


Link to post
Share on other sites

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.