/o help?
#1

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/o", cmdtext, true, 10) == 0)
    {
        if(!strlen(cmdtext)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /o [chat]");
        new str[256];
        GetPlayerName(playerid, str, sizeof(str));
        format(str, sizeof(str), "%s: %s", str, cmdtext);
        SendClientMessageToAll(COLOR_WHITE, str);
        return 1;
    }
    return 0;
I have set up gTeam and I was wandering how to make it so when the player is on PD duty and he types, E.g Hello in /o his name would be Luis_Foxx: Hello

Thanks
Reply
#2

You cannot use two seperate colours in 'SendClientMessageToAll'. Use 'SendPlayerMessageToAll'.
Reply
#3

If you want somebody's chat color to be a particular color, then you need to use "SetPlayerColor". So for you set their color to blue when they go on PD duty.
Reply
#4

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp("/o", cmdtext, true, 2))
    {
        new str[128];
        GetPlayerName(playerid, str, sizeof(str));
        format(str, sizeof(str), "%s", cmdtext[2]);
        SendPlayerMessageToAll(playerid, str);
        return 1;
    }
    return 0;
}
Okay it works now but I want it to say this, "Usage: /o [Message]" if the Player only types /o?
Reply
#5

use sscanf or strlen.. i'm not sure i mostly work with zcmd and dcmd
Reply
#6

If I were you, I would consider using SSCANF(2) and ZCMD. This is the command using SSCANF(2), but not ZCMD.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp("/o", cmdtext, true, 2))
    {
        new message, string[128], sendername[24];
        if(sscanf(params, "s[105]", message)) return SendClientMessage(playerid, COLOR_WHITE, "SYNTAX: /o [message]");
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(str, sizeof(str), "OOC %s: %s", sendername, message);
        SendPlayerMessageToAll(playerid, str);
        return 1;
    }
    return 0;
}
It should work for you.

EDIT: I am so used to working with ZCMD that the command I provided for you will not work with STRCMP. I'll see what I can do, as I don't use STRCMP. I would recommend that you use ZCMD and convert your STRCMP commands to ZCMD as "OnPlayerCommandText" will cause a compatibility issue.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)