Git Product home page Git Product logo

Comments (12)

Misiur avatar Misiur commented on July 23, 2024

Since YSI 4.0, this function accepts different arguments, and returns different ones:

forward e_COMMAND_ERRORS:OnPlayerCommandPerformed(playerid, cmdtext[], e_COMMAND_ERRORS:success); 
//(...)
enum e_COMMAND_ERRORS
{
    // The majority of these are even - odd numbers return "1" not "0".
    COMMAND_ZERO_RET      = 0 , // The command returned 0.
    COMMAND_OK            = 1 , // Called corectly.
    COMMAND_UNDEFINED     = 2 , // Command doesn't exist.
    COMMAND_DENIED        = 3 , // Can't use the command.
    COMMAND_HIDDEN        = 4 , // Can't use the command don't let them know it exists.
    COMMAND_NO_PLAYER     = 6 , // Used by a player who shouldn't exist.
    COMMAND_DISABLED      = 7 , // All commands are disabled for this player.
    COMMAND_BAD_PREFIX    = 8 , // Used "/" instead of "#", or something similar.
    COMMAND_INVALID_INPUT = 10, // Didn't type "/something".
}

from ysi-includes.

mokiding avatar mokiding commented on July 23, 2024

I can't get it working, can you give me some example ?

from ysi-includes.

Misiur avatar Misiur commented on July 23, 2024

Sure:

public e_COMMAND_ERRORS:OnPlayerCommandPerformed(playerid, cmdtext[], e_COMMAND_ERRORS:success)
{
    if (success != COMMAND_OK) {
        printf("The command was not successful for player %d", playerid);
        return success;
    }
    return COMMAND_OK;
}

from ysi-includes.

mokiding avatar mokiding commented on July 23, 2024

I still can't get it working, where im failing ?

public e_COMMAND_ERRORS:OnPlayerCommandPerformed(playerid, cmdtext[], e_COMMAND_ERRORS:success)
{
    if(success == COMMAND_UNDEFINED)
    {
        new string[128]; 
        format(string, sizeof(string), "{030CDE}[SM] {FF0000}Command %s doesn't exist !", cmdtext);
        SendClientMessage(playerid,-1, string); 
        return success;
    }
    return COMMAND_OK;
}

Im still getting default sa-mp's "SERVER: Uknown Command!" message ...

from ysi-includes.

Misiur avatar Misiur commented on July 23, 2024

Is the "Command %s doesn't exist" sent?

from ysi-includes.

mokiding avatar mokiding commented on July 23, 2024

Nope. just default sa-mp uknown command ...

from ysi-includes.

Misiur avatar Misiur commented on July 23, 2024

Ok, change success == COMMAND_UNDEFINED to success != COMMAND_OK, and return COMMAND_OK instead of success.

from ysi-includes.

mokiding avatar mokiding commented on July 23, 2024

Nope, still not working ... Still getting sa-mp default one ...

public e_COMMAND_ERRORS:OnPlayerCommandPerformed(playerid, cmdtext[], e_COMMAND_ERRORS:success)
{
    if(success != COMMAND_OK)
    {
        new string[128]; 
        format(string, sizeof(string), "{030CDE}[SM] {FF0000}Command %s doesn't exist !", cmdtext);
        SendClientMessage(playerid,-1, string); 
        return COMMAND_OK;
    }
    return COMMAND_OK;
}

from ysi-includes.

Misiur avatar Misiur commented on July 23, 2024

Ok, the cause might be a little different then - it usually happens when runtime error occurs. If you don't have crashdetect plugin, get it now. Also, it would be helpful if you could paste here your command code.

from ysi-includes.

mokiding avatar mokiding commented on July 23, 2024

Yes, i have crashdetect alredy ... It doesn't showing anything.

Example of my cmd

YCMD:testcmd(playerid,params[],help)
{
    SendClientMessage(playerid, -1, "Test cmd called and its working ?");
    return 1;
}

and it's printing me the "Test cmd called and its working ?" but when i call /testnone (a command that doesn't exist in Gamemode) im getting "SERVER: Unknown command."

And my OnPlayerCommandPerformed is

public e_COMMAND_ERRORS:OnPlayerCommandPerformed(playerid, cmdtext[], e_COMMAND_ERRORS:success)
{
    if(success != COMMAND_OK)
    {
        new string[128]; 
        format(string, sizeof(string), "{030CDE}[SM] {FF0000}Command %s doesn't exist !", cmdtext);
        SendClientMessage(playerid,-1, string); 
        return COMMAND_OK;
    }
    return COMMAND_OK;
}

Just run this gm and it will give same message ... I think thath there is some bug in YSI ...
https://gist.github.com/m0k1/82f6d8bd6e7e69bee5d1

from ysi-includes.

Misiur avatar Misiur commented on July 23, 2024

I don't have time to check that now, but it seems what you need is e_COMMAND_ERRORS:OnPlayerCommandReceived(playerid, cmdtext[], e_COMMAND_ERRORS:success), not OnPlayerCommandPerfomed, as the second one is run only when command is... well, performed.

from ysi-includes.

mokiding avatar mokiding commented on July 23, 2024

Yeah, that fixed issuse ! Thanks.

btw, on old YSI 3.1 it was working under OnPlayerCommandPerfomed

from ysi-includes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.