Radio with space?
#1

pawn Код:
if(!strcmp(cmdtext, "/r", true, 2))
    {
        new string[128], Player[MAX_PLAYER_NAME];
        GetPlayerName(playerid, Player, MAX_PLAYER_NAME);
        format(string, 128, "RADIO: %s: %s", Player, cmdtext[2]);
        for(new i=0; i<MAX_PLAYERS; i++) if(gTeam[i]==gTeam[playerid]) SendClientMessage(i, COLOR_GREEN, string);
        return 1;
    }
now when I type /rules it says
RADIO: Mean: ules
how can I make it so it needs to put space not like /rhelp me I want it /r help me
Reply
#2

Explain more
Reply
#3

Maybe:

pawn Код:
if(!strcmp(cmdtext, "/r ", true, 3))
    {
        new string[128], Player[MAX_PLAYER_NAME];
        GetPlayerName(playerid, Player, MAX_PLAYER_NAME);
        format(string, 128, "RADIO: %s: %s", Player, cmdtext[3]);
        for(new i=0; i<MAX_PLAYERS; i++) if(gTeam[i]==gTeam[playerid]) SendClientMessage(i, COLOR_GREEN, string);
        return 1;
    }
Try it. ^^
Reply
#4

Doesnt work
Reply
#5

pawn Код:
if(!strcmp(cmdtext, "/r", true, 2) && strlen(cmdtext) = 2)
    {
        new string[128], Player[MAX_PLAYER_NAME];
        GetPlayerName(playerid, Player, MAX_PLAYER_NAME);
        format(string, 128, "RADIO: %s: %s", Player, cmdtext[2]);
        for(new i=0; i<MAX_PLAYERS; i++) if(gTeam[i]==gTeam[playerid]) SendClientMessage(i, COLOR_GREEN, string);
        return 1;
    }
try that ^
Reply
#6

I'm sorry Bessensap, but I think this won't work.
Look: The '/r' has a lenght of 2, so if you type anything more, it is never 2 again, which means you can type /r, but the following will give Unknown Command.

Try:
pawn Код:
if(!strcmp(cmdtext, "/r", true, 2) && cmdtext[2]==' ')
    {
        new string[128], Player[MAX_PLAYER_NAME];
        GetPlayerName(playerid, Player, MAX_PLAYER_NAME);
        format(string, 128, "RADIO: %s: %s", Player, cmdtext[3]);
        for(new i=0; i<MAX_PLAYERS; i++) if(gTeam[i]==gTeam[playerid]) SendClientMessage(i, COLOR_GREEN, string);
        return 1;
    }
Reply
#7

I dont understand what you want. You want to change the /r command or ?
Reply
#8

Nevermind, I got it working with zcmd
Thanks for helping
Reply
#9

Try this,
Код:
 if(strcmp(cmd, "/radio", true) == 0 || strcmp(cmd, "/r", true) == 0)
    {
        new string[128], Player[MAX_PLAYER_NAME];
        GetPlayerName(playerid, Player, MAX_PLAYER_NAME);
        format(string, 128, "RADIO: %s: %s", Player, cmdtext[3]);
        for(new i=0; i<MAX_PLAYERS; i++) if(gTeam[i]==gTeam[playerid]) SendClientMessage(i, COLOR_GREEN, string);
        return 1;
    }
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)