Basic scripting question.
#1

Hello guys I'am running a trucking server and i want to make it light rp.I edited some stuff bur couldn't find something for the basic of all :i want to add /L(ocal)I© and /L(ocal)O(oc) chats...Any help?
Reply
#2

Global OOC Chat:
pawn Код:
public OnPlayerText(playerid, text[])
{
    new string [128];
    GetPlayerName(playerid, string, sizeof(string));
    format(string, sizeof(string), "(( %s says: %s)) ", string, text);
    SendClientMessageToAll(playerid, 0xFFFFFFFF, string);
    return 1;
}
OOC Local Chat:
pawn Код:
if(strcmp(string, "/lo", true) == 0)
    {
        object = strlen(cmdtext);
        while ((idx < object) && (cmdtext[idx] <= ' '))
        {
            idx++;
        }
        new offset = idx;
        new result[64];
        while ((idx < object) && ((idx - offset) < (sizeof(result) - 1)))
        {
            result[idx - offset] = cmdtext[idx];
            idx++;
        }
        result[idx - offset] = EOS;
        if(!strlen(result))
        {
            SendClientMessage(playerid, COLOR_GREY, "USAGE: /lo [chat]");
            return 1;
        }
        GetPlayerName(playerid, playername, sizeof(playername));
        format(string, sizeof(string), "((%s says: %s))", playername, result);
        ProxDetector(20.0, playerid, string, COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);      printf(string);
    }
IC Local Chat:
pawn Код:
if(strcmp(string, "/li", true) == 0)
    {
        object = strlen(cmdtext);
        while ((idx < object) && (cmdtext[idx] <= ' '))
        {
            idx++;
        }
        new offset = idx;
        new result[64];
        while ((idx < object) && ((idx - offset) < (sizeof(result) - 1)))
        {
            result[idx - offset] = cmdtext[idx];
            idx++;
        }
        result[idx - offset] = EOS;
        if(!strlen(result))
        {
            SendClientMessage(playerid, COLOR_GREY, "USAGE: /li [chat]");
            return 1;
        }
        GetPlayerName(playerid, playername, sizeof(playername));
        format(string, sizeof(string), "%s says: %s", playername, result);
        ProxDetector(20.0, playerid, string, COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);      printf(string);
    }
Reply
#3

Quote:
Originally Posted by Adil
Посмотреть сообщение
IC Chat:
pawn Код:
public OnPlayerText(playerid, text[])
{
    new string [128];
    GetPlayerName(playerid, string, sizeof(string));
    format(string, sizeof(string), "%s says: %s", string, text);
    ProxDetector(20.0, playerid, string, COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
    return 1;
}
OOC Chat:
pawn Код:
if(strcmp(string, "/l", true) == 0)
    {
        object = strlen(cmdtext);
        while ((idx < object) && (cmdtext[idx] <= ' '))
        {
            idx++;
        }
        new offset = idx;
        new result[64];
        while ((idx < object) && ((idx - offset) < (sizeof(result) - 1)))
        {
            result[idx - offset] = cmdtext[idx];
            idx++;
        }
        result[idx - offset] = EOS;
        if(!strlen(result))
        {
            SendClientMessage(playerid, COLOR_GREY, "USAGE: /l [chat]");
            return 1;
        }
        GetPlayerName(playerid, playername, sizeof(playername));
        format(string, sizeof(string), "%s %s", playername, result);
        ProxDetector(30, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        printf(string);
    }
Hello, thnk you for responding so fast, but i want to keep the normal chat ooc that everyone can see and i want to add an -local- in and out of charapter chat...Can I?
Reply
#4

Done, post edited.
Reply
#5

Youre damn awsome!!!
Reply
#6

Quote:
Originally Posted by Adil
Посмотреть сообщение
Done, post edited.
: error 017: undefined symbol "object"
: error 017: undefined symbol "cmdtext"
: error 017: undefined symbol "idx"
: error 029: invalid expression, assumed zero
: error 029: invalid expression, assumed zero
: fatal error 107: too many error messages on one line

Whats wrongI was suppose to put them on public OnPlayerText(playerid, text[]) right
Reply
#7

Change OnPlayerCommandText(playerid) to public OnPlayerCommandText(playerid, cmdtext[]). Write these lines beneath OnPlayerCommandText:
pawn Код:
new object;
new idx;
EDIT: And you were actually only suppose to put the first one in OnPlayerText, and the other two in OnPlayerCommandText.
Reply
#8

Quote:
Originally Posted by Adil
Посмотреть сообщение
Change OnPlayerCommandText(playerid) to public OnPlayerCommandText(playerid, cmdtext[]). Write these lines beneath OnPlayerCommandText:
pawn Код:
new object;
new idx;
EDIT: And you were actually only suppose to put the first one in OnPlayerText, and the other two in OnPlayerCommandText.
sorry but can you send it in one becouse iam doin something wrong.. sen the hole callback ..I'am sorry...
Reply
#9

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new object;
    new idx;
    if(strcmp(string, "/lo", true) == 0)
    {
        object = strlen(cmdtext);
        while ((idx < object) && (cmdtext[idx] <= ' '))
        {
            idx++;
        }
        new offset = idx;
        new result[64];
        while ((idx < object) && ((idx - offset) < (sizeof(result) - 1)))
        {
            result[idx - offset] = cmdtext[idx];
            idx++;
        }
        result[idx - offset] = EOS;
        if(!strlen(result))
        {
            SendClientMessage(playerid, COLOR_GREY, "USAGE: /lo [chat]");
            return 1;
        }
        GetPlayerName(playerid, playername, sizeof(playername));
        format(string, sizeof(string), "((%s says: %s))", playername, result);
        ProxDetector(20.0, playerid, string, COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);     
        printf(string);
    }
    if(strcmp(string, "/li", true) == 0)
    {
        object = strlen(cmdtext);
        while ((idx < object) && (cmdtext[idx] <= ' '))
        {
            idx++;
        }
        new offset = idx;
        new result[64];
        while ((idx < object) && ((idx - offset) < (sizeof(result) - 1)))
        {
            result[idx - offset] = cmdtext[idx];
            idx++;
        }
        result[idx - offset] = EOS;
        if(!strlen(result))
        {
            SendClientMessage(playerid, COLOR_GREY, "USAGE: /li [chat]");
            return 1;
        }
        GetPlayerName(playerid, playername, sizeof(playername));
        format(string, sizeof(string), "%s says: %s", playername, result);
        ProxDetector(20.0, playerid, string, COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);     
        printf(string);
    }
    return 1;
}
And the OnPlayerText One.
Reply
#10

Or you can use include on my siggy.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)