SA-MP Forums Archive
Basic scripting question. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Basic scripting question. (/showthread.php?tid=268040)



Basic scripting question. - steve_gibson - 10.07.2011

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?


Re: Basic scripting question. - Adil - 10.07.2011

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);
    }



Re: Basic scripting question. - steve_gibson - 10.07.2011

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?


Re: Basic scripting question. - Adil - 10.07.2011

Done, post edited.


Re: Basic scripting question. - steve_gibson - 10.07.2011

Youre damn awsome!!!


Re: Basic scripting question. - steve_gibson - 10.07.2011

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


Re: Basic scripting question. - Adil - 10.07.2011

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.


Re: Basic scripting question. - steve_gibson - 11.07.2011

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...


Re: Basic scripting question. - Adil - 11.07.2011

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.


Re: Basic scripting question. - =WoR=Varth - 11.07.2011

Or you can use include on my siggy.