How can I make a 10- code
#1

You might have played CrazyBob's CnR and notice he has 10- codes like for example: Okay, affirmative (10-4), Good Job! (10-120)

I was wondering how do I make them? At the moment I have this code:

pawn Код:
if (strfind(text, "10-0") != -1)  // THIS FINDS THE TEXT THAT THE PLAYER TYPES IN THE CHAT
{
          new PlayerName[MAX_PLAYER_NAME];
          GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
          format(text, 1024, "%s (%d): {FFFFFF}Testing (10-0)", PlayerName, playerid, text); // THIS LINE SHOWS A CUSTOM NAME OF THE 10 CODE WHICH IS Testing (10-0) - This is what I want it to show up as when someone types 10-0 in the chat
          SendClientMessageToAll(GetPlayerColor(playerid), text);
         //SCROLL RIGHT -----> TO SEE THE REST
}
So in easier terms, when someone types 10-0 in the chat it will say Testing (10-0). I tried this above code but it didn';t work and it still showed up as 10-0 when someone typed it.

Thanks.
Reply
#2

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(!strcmp(text, "10-0", true))
    {
        new string[100], PlayerName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
        format(text, 1024, "%s (%d): {FFFFFF}Testing (10-0)", PlayerName, playerid, text); // THIS LINE SHOWS A CUSTOM NAME OF THE 10 CODE WHICH IS Testing (10-0) - This is what I want it to show up as when someone types 10-0 in the chat
          SendClientMessageToAll(GetPlayerColor(playerid), text);
        return 0;
    }
    return 1;
}
try this
Reply
#3

That does not work. Thanks though.

Anyone else?
Reply
#4

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(!strcmp(text, "10-0", true))
    {
        new string[100], PlayerName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
        format(string, sizeof(string), "%s (%d): {FFFFFF}Testing (10-0)", PlayerName, playerid); // THIS LINE SHOWS A CUSTOM NAME OF THE 10 CODE WHICH IS Testing (10-0) - This is what I want it to show up as when someone types 10-0 in the chat
          SendClientMessageToAll(GetPlayerColor(playerid), text);
        return 0;
    }
    return 1;
}
try now
Reply
#5

pawn Код:
CMD:10-0(playerid, params[])
{
new string[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(string, 128, "%s: Testing (10-0)", name);
SendClientMessageToAll(GetPlayerColor(playerid), string);
return 1;
}
Sorry for indenting, made it in browser.
Reply
#6

Quote:
Originally Posted by Sascha
Посмотреть сообщение
pawn Код:
public OnPlayerText(playerid, text[])
{
    if(!strcmp(text, "10-0", true))
    {
        new string[100], PlayerName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
        format(string, sizeof(string), "%s (%d): {FFFFFF}Testing (10-0)", PlayerName, playerid); // THIS LINE SHOWS A CUSTOM NAME OF THE 10 CODE WHICH IS Testing (10-0) - This is what I want it to show up as when someone types 10-0 in the chat
          SendClientMessageToAll(GetPlayerColor(playerid), text);
        return 0;
    }
    return 1;
}
try now
Are you a newb? it's OnPlayerCommandText.
Reply
#7

OnPlayerText, use sscanf to check wheather or not the player entered "10-" followed by a number.
Reply
#8

Quote:
Originally Posted by maramizo
Посмотреть сообщение
Are you a newb? it's OnPlayerCommandText.
cough lol..
it more seems as if you are a "newb"...
look..
OnPlayerCommandText detects commands... it would be: /10-0

my version detects the text that is written into the chat so:
10-0

instead of showing 10-0 it should show the msg...
Reply
#9

Quote:
Originally Posted by Sascha
Посмотреть сообщение
cough lol..
OnPlayerCommandText detects commands... it would be: /10-0

my version detects the text that is written into the chat so:
10-0

instead of showing 10-0 it should show the msg...
I agree, but he should use sscanf instead of strfind or strcmp
Reply
#10

Quote:
Originally Posted by Lorrden
Посмотреть сообщение
I agree, but he should use sscanf instead of strfind or strcmp
Could you please make one, I don't know how to set it up, I use sscanf but I just don't know how to setup the code.

Also, sascha and maram, both don't work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)