Custom Command Operators?
#1

While viewing another thread i was wondering if you could initiate commands when the player just types something like "ban dowster" where the OnPlayerText would pickup that the user was initiating the ban function. I know how to do this but how would it figure out the dowster part? actually thinking of this right now makes me think that using strcmp like you would in OnPlayerCommandText to just pickup that they said ban, then have it throw the rest into another string. Is this possible or am i just crazy?
Reply
#2

Some proof of concept code, yes it was possible. I'll explain this tomorrow if anyone wants me to.
pawn Код:
public OnPlayerText(playerid, text[])
{
    if (strcmp( text, "say", true, 3) == 0)
    {
        new useless[3], string[124];
        sscanf(text, "ss", useless, string);
        format(string, sizeof(string), "Admin: %s", string);
        SendClientMessageToAll( 0xFFFFFFFF, string);
        return 0;
    }      
    return 1;
}
This probably wont work as is because it is ripped from my game mode, here is the entire OnPlayerText function
pawn Код:
public OnPlayerText(playerid, text[])
{
    if (gPlayerData[playerid][REPORTED] == 2)
    {
        SendPlayerMessageToPlayer(gPlayerData[playerid][ACTIVEREPORT], playerid, text);
    }
    else if (strcmp( text, "say", true, 3) == 0)
    {
        new useless[3], string[124];
        sscanf(text, "ss", useless, string);
        format(string, sizeof(string), "Admin: %s", string);
        SendClientMessageToAll( 0xFFFFFFFF, string);
        return 0;
    }      
    #if defined CHAT_DISTANCE
    else
    {
        new Float:x, Float:y, Float:z;
        GetPlayerPos( playerid, x, y, z);
        for(new i = 0; i <= MAX_PLAYERS; i++)
        {
           
            if(IsPlayerInRangeOfPoint( i, CHAT_DISTANCE, x, y, z))
            {
                SendPlayerMessageToPlayer(i, playerid, text);
            }
        }
    }
    #else
    else SendPlayerMessageToAll(playerid, text);
    #endif
    return 0;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)