Skip to content

Commit 4aee6c4

Browse files
committed
Fixed an issue in parsing onPlayerCommand event
1 parent 1fd3af5 commit 4aee6c4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

VCMP-LUA/vcmpWrap/vcmpCallbacks.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -733,8 +733,14 @@ void RegisterVCMPCallbacks() {
733733
}
734734
std::string data(message);
735735
std::vector<std::string> args = std::split(data, ' ');
736+
std::string command;
737+
if (args.size() > 0)
738+
{
739+
command = args.at(0);
740+
args.erase(args.begin());
741+
}
736742
for (auto fn : handlers) {
737-
if (args.size() <= 0) { // No command at all? Pass nil
743+
if (command.size() == 0) { // No command at all? Pass nil
738744
sol::function_result r = fn(player, sol::lua_nil, sol::lua_nil);
739745
if (!r.valid()) {
740746
sol::error e = r;
@@ -747,8 +753,6 @@ void RegisterVCMPCallbacks() {
747753
}
748754
}
749755
else {
750-
std::string command = args.at(0);
751-
args.erase(args.begin());
752756
if (args.size() > 0) {
753757
sol::function_result r = fn(player, command, sol::as_table_t<std::vector<std::string>>(args));
754758
if (!r.valid()) {

0 commit comments

Comments
 (0)