Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command return SERVER: Unknown command in case of COMMAND_SILENT #641

Open
xs1vr opened this issue Apr 3, 2023 · 2 comments
Open

Command return SERVER: Unknown command in case of COMMAND_SILENT #641

xs1vr opened this issue Apr 3, 2023 · 2 comments

Comments

@xs1vr
Copy link

xs1vr commented Apr 3, 2023

My code:

hook OnGameModeInit()
{
	Command_SetUnknownReturn(true);
	Command_SetDeniedReturn(true);

	return Y_HOOKS_CONTINUE_RETURN_1;
}

public e_COMMAND_ERRORS:OnPlayerCommandReceived(playerid, cmdtext[], e_COMMAND_ERRORS:success)
{
	SendClientMessage(playerid, -1, "Recv=%d", success);
	switch (success) {
		case COMMAND_UNDEFINED: {
			SendErrorMessage(playerid, "Ova komanda (%s) ne postoji.", cmdtext);
		}
		case COMMAND_DENIED: {
			SendErrorMessage(playerid, "Komanda (%s) zahteva dodatne dozvole ili vise nemate mogucnosti da ju koristite.", cmdtext);
		}
	}
	return success;
}

public e_COMMAND_ERRORS:OnPlayerCommandPerformed(playerid, cmdtext[], e_COMMAND_ERRORS:success)
{
	SendClientMessage(playerid, -1, "Perf=%d", success);
	switch(success) {
		case COMMAND_ZERO_RET: { // Added this as a temporal fix as the message is gone then
			return COMMAND_OK;
		}
		case COMMAND_DENIED: {
			SendErrorMessage(playerid, "Komanda (%s) zahteva dodatne dozvole ili vise nemate mogucnost da je koristite.", cmdtext);
		}
		case COMMAND_INVALID_INPUT: {
			SendErrorMessage(playerid, "Ova komanda zahteva argumente. Za vise detalja /help <komanda>.");
		}
	}
	return success;
}

@cmd(.alts = {"h", "pomoc"}) help(playerid, params[], help)
{
    if (help) {
        SendUsageMessage(playerid, "Koristite /help <komanda> da dobijete informacije o komandi.");
        return COMMAND_ZERO_RET; // SERVER: Unknown command
    }

    if (isnull(params)) {
        return COMMAND_ZERO_RET; // SERVER: Unkown command
    }
    
    Command_ReProcess(playerid, params, true);
    return COMMAND_OK;
}

Either a bad design or a bug

@xs1vr
Copy link
Author

xs1vr commented Apr 3, 2023

Figured it out on Discord, tldr use COMMAND_SILENT paired with Command_SetSilentReturn(true)

@xs1vr xs1vr closed this as completed Apr 3, 2023
@xs1vr
Copy link
Author

xs1vr commented Apr 3, 2023

Apparently COMMAND_SILENT returns SERVER: Unknown message even with Command_SetSilentReturn set to true, however it did not when I used the /help command so that's why I assumed it initially worked..

Doing

case COMMAND_SILENT: {
	success = COMMAND_OK;
}

under the ..OnPerformed callback naturally "fixes" the issue.

@xs1vr xs1vr reopened this Apr 3, 2023
@xs1vr xs1vr changed the title Command return SERVER: Unknown command in case of COMMAND_ZERO_RET Command return SERVER: Unknown command in case of COMMAND_SILENT Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant