SA-MP Forums Archive
OnPlayerText problem - 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)
+--- Thread: OnPlayerText problem (/showthread.php?tid=390341)



OnPlayerText problem - Stereotype - 05.11.2012

Hello , i have a problem when someone uses normal chat it shows message to everyone , i just wanna to be in radius of 20 ... Here is the code
pawn Код:
mid(PaperInfo[WritingPaperNumber[playerid]][PaperText3], nstring, 0, strlen(nstring), 255);
                line = 3; WritingLine[playerid] = 5;
            }
            case 5:
            {
                strmid(PaperInfo[WritingPaperNumber[playerid]][PaperText4], nstring, 0, strlen(nstring), 255);
                line = 4; WritingLine[playerid] = 6;
            }
            case 6:
            {
                strmid(PaperInfo[WritingPaperNumber[playerid]][PaperText5], nstring, 0, strlen(nstring), 255);
                line = 5; WritingLine[playerid] = 7;
            }
            case 7:
            {
                strmid(PaperInfo[WritingPaperNumber[playerid]][PaperText6], nstring, 0, strlen(nstring), 255);
                line = 6; WritingLine[playerid] = 8;
            }
            case 8:
            {
                strmid(PaperInfo[WritingPaperNumber[playerid]][PaperText7], nstring, 0, strlen(nstring), 255);
                PaperInfo[WritingPaperNumber[playerid]][PaperUsed] = 1;
                SavePapers();
                line = 7; WritingLine[playerid] = 0; WritingPaper[playerid] = 0; WritingPaperNumber[playerid] = 999;
            }
        }
        if(line > 0)
        {
            format(string, sizeof(string), "* Napisali ste %d red/a/ova u vasim novina.", line);
            SendClientMessage(playerid, COLOR_WHITE, string);
            if(line == 7)
            {
                SendClientMessage(playerid, COLOR_WHITE, "* Vase Novine su dodate na listi Novina (za Raznosace Novina).");
            }
        }
        return 0;
    }
    if(CallLawyer[playerid] == 111)
    {
        new idx;
        tmp = strtok(text, idx);
        if ((strcmp("yes", tmp, true, strlen(tmp)) == 0) && (strlen(tmp) == strlen("yes")))
        {
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, sizeof(string), "** %s je u zatvoru i treba advokata. Idite u Policijsku Stanicu.", sendername);
            SendJobMessage(2, TEAM_AZTECAS_COLOR, string);
            SendJobMessage(2, TEAM_AZTECAS_COLOR, "* Kada ste u Policijskoj Stanici, pitajte nekog policajca da vam dozvoli oslobadjanje sa /accept lawyer.");
            SendClientMessage(playerid, COLOR_LIGHTRED, "Poruka je poslata svim slobodnim advokatima, molimo sacekajte.");
            WantLawyer[playerid] = 0;
            CallLawyer[playerid] = 0;
            return 0;
        }
        else
        {
            SendClientMessage(playerid, COLOR_LIGHTRED, "Trenutno nema slobodnih advokata, zatvorska kazna je pocela.");
            WantLawyer[playerid] = 0;
            CallLawyer[playerid] = 0;
            return 0;
        }
    }
    if(TalkingLive[playerid] != 255)
    {
        GetPlayerName(playerid, sendername, sizeof(sendername));
        if(PlayerInfo[playerid][pMember] == 9 || PlayerInfo[playerid][pLeader] == 9)
        {
            format(string, sizeof(string), "{FFFF00}[RTS] Novinar %s: {FFFFFF}%s", sendername, text);
            OOCNews(COLOR_LIGHTGREEN, string);
        }
        else
        {
            format(string, sizeof(string), "{FFFF80}[RTS] Gost %s: {FFFFFF}%s", sendername, text);
            OOCNews(COLOR_LIGHTGREEN, string);
        }
        return 0;
    }
    if(Mobile[playerid] != 255)
    {
        new idx;
        tmp = strtok(text, idx);
        GetPlayerName(playerid, sendername, sizeof(sendername));
           new result[256];
           new brojevi[] = { '1','2','3','4','5','6','7','8','9'};
            for(new b = 0; b < sizeof brojevi; b++)
            {
                new tekst = strlen(result);
                for(new i = 0; i<tekst; i++)
                    {
                    if(result[i] == brojevi[b])
                    result[i] = '*' ;
                    }
            }
        if(UnidentifedCall[playerid] == 1)
        {
            format(string, sizeof(string), "{F3FF02}Stranac kaze (telefon): %s", text);
        }
        else
        {
            format(string, sizeof(string), "{F3FF02}%s kaze (telefon): %s", sendername, text);
        }
        ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
        if(Mobile[playerid] == 914)
        {
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, TEAM_CYAN_COLOR, "Dispacher: Izvinite, ne razumijem?");
                return 0;
            }
            new turner[MAX_PLAYER_NAME];
            new wanted[128];
            GetPlayerName(playerid, turner, sizeof(turner));
            SendClientMessage(playerid, TEAM_CYAN_COLOR, "Dispacher: Javili smo svim jedinicama u tom podruciju.");
            SendClientMessage(playerid, TEAM_CYAN_COLOR, "Hvala vam sto ste prijavili incident");
            format(wanted, sizeof(wanted), "Dispacher: Svim jedinicama, novi incident: Prijavio: %s",turner);
            SendTeamBeepMessage(1, TEAM_CYAN_COLOR, wanted);
            format(wanted, sizeof(wanted), "Dispacher: Incident: %s",text);
            SendTeamMessage(1, TEAM_CYAN_COLOR, wanted);
            new Float:trace_x, Float:trace_y, Float:trace_z;
            GetPlayerPos(playerid, trace_x, trace_y, trace_z);
            emdtrace = 1; emdtrace_x = trace_x; emdtrace_y = trace_y; emdtrace_z = trace_z;
            SendClientMessage(playerid, COLOR_GRAD2, "   Prekinuli su...");
            Mobile[playerid] = 255;
            return 0;
        }
        if(Mobile[playerid] == 913)
        {
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_ALLDEPT, "Hitna Sluzba: Izvinite, ne razumijem?");
                return 0;
            }
            if ((strcmp("no", tmp, true, strlen(tmp)) == 0) && (strlen(tmp) == strlen("no")))
            {
                new turner[MAX_PLAYER_NAME];
                new wanted[128];
                GetPlayerName(playerid, turner, sizeof(turner));
                SendClientMessage(playerid, COLOR_DBLUE, "PD Dispacher: Javili smo svim jedinicama u tom podruciju .");
                SendClientMessage(playerid, COLOR_DBLUE, "Hvala vam sto ste prijavili zlocin");
                format(wanted, sizeof(wanted), "BAZA: Svim jedinicama, novi zlocin: Prijavio: %s",turner);
                SendFamilyMessage(1, COLOR_DBLUE, wanted);
                format(wanted, sizeof(wanted), "BAZA: Zlocin: %s, Osumnjiceni: Nepoznat",PlayerCrime[playerid][pAccusing]);
                SendFamilyMessage(1, COLOR_DBLUE, wanted);
                new Float:trace_x, Float:trace_y, Float:trace_z;
                GetPlayerPos(playerid, trace_x, trace_y, trace_z);
                pdtrace = 1; pdtrace_x = trace_x; pdtrace_y = trace_y; pdtrace_z = trace_z;
                SendClientMessage(playerid, COLOR_GRAD2, "   Prekinuli su...");
                Mobile[playerid] = 255;
                return 0;
            }
            new badguy;
            badguy = ReturnUser(tmp);
            if (IsPlayerConnected(badguy))
            {
                if(badguy != INVALID_PLAYER_ID)
                {
                    if (gTeam[badguy] == 2 || gTeam[badguy] == 1)
                    {
                        SendClientMessage(playerid, COLOR_DBLUE, "PD Dispacher: Moracete da prijavite unutrasnjoj kontroli.");
                        SendClientMessage(playerid, COLOR_GRAD2, "   Prekinuli su...");
                        Mobile[playerid] = 255;
                        return 0;
                    }
                    if (WantedPoints[badguy] > 0)
                    {
                        SendClientMessage(playerid, COLOR_DBLUE, "PD Dispacher: Sve jedinice su vec obavjestene o tom slucaju");
                        SendClientMessage(playerid, COLOR_DBLUE, "Hvala vam sto ste prijavili taj zlocin");
                        SendClientMessage(playerid, COLOR_GRAD2, "   Prekinuli su...");
                        Mobile[playerid] = 255;
                        return 0;
                    }
                    if (badguy == playerid)
                    {
                        SendClientMessage(playerid, COLOR_DBLUE, "PD Dispacher: Nemojte se zezati, ovo je linija za hitne slucajeve.");
                        SendClientMessage(playerid, COLOR_GRAD2, "   Prekinuli su...");
                        Mobile[playerid] = 255;
                        return 0;
                    }
                    SendClientMessage(playerid, COLOR_DBLUE, "PD Dispacher: Javili smo svim jedinicama u tom podruciju.");
                    SendClientMessage(playerid, COLOR_DBLUE, "Hvala sto ste prijavili zlocin");
                    new Float:trace_x, Float:trace_y, Float:trace_z;
                    GetPlayerPos(playerid, trace_x, trace_y, trace_z);
                    pdtrace = 1; pdtrace_x = trace_x; pdtrace_y = trace_y; pdtrace_z = trace_z;
                    SetPlayerCriminal(badguy,playerid, PlayerCrime[playerid][pAccusing]);
                    if(WantedPoints[badguy] > 0) { } else { WantedPoints[badguy] += 2; }
                    SendClientMessage(playerid, COLOR_GRAD2, "   Prekinuli su...");
                    Mobile[playerid] = 255;
                    return 0;
                }
                return 0;
            }
            else
            {
                format(string, sizeof(string), "PD Dispacher: Nemamo informacija o %s-u, da li ste sigurni da je to tacno ime?",tmp);
                SendClientMessage(playerid, COLOR_DBLUE, string);
                return 0;
            }
        }
        if(Mobile[playerid] == 912)
        {
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_ALLDEPT, "Hitna Sluzba: Izvinite, ne razumijem?");
                return 0;
            }
            strmid(PlayerCrime[playerid][pAccusing], text, 0, strlen(text), 255);
            SendClientMessage(playerid, COLOR_DBLUE, "PD: Ako znate ime pocinioca napisite ga, ako ne znate napisite 'no'.");
            Mobile[playerid] = 913;
            return 0;
        }
        if(Mobile[playerid] == 911)
        {
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_ALLDEPT, "Hitna Sluzba: Ne razumijem, da li trebate 'Policiju' ili 'Hitnu Pomoc'? (kucajte policija ili hitna_pomoc)");
                return 0;
            }
            else if ((strcmp("policija", tmp, true, strlen(tmp)) == 0) && (strlen(tmp) == strlen("policija")))
            {
                SendClientMessage(playerid, COLOR_ALLDEPT, "Hitna Sluzba: Povezujem vas sa Policijom, sacekajte...");
                Mobile[playerid] = 912;
                SendClientMessage(playerid, COLOR_DBLUE, "PD: Molimo vas dajte nam kratke podatke o zlocinu i lokaciji.");
                return 0;
            }
            else if ((strcmp("hitna_pomoc", tmp, true, strlen(tmp)) == 0) && (strlen(tmp) == strlen("hitna_pomoc")))
            {
                SendClientMessage(playerid, COLOR_ALLDEPT, "Hitna Sluzba: Povezujem vas Sa Hitnom Pomoci.");
                Mobile[playerid] = 914;
                SendClientMessage(playerid, TEAM_CYAN_COLOR, "Dispacher: Molimo vas dajte nam kratke podatke o incidentu.");
                return 0;
            }
            else
            {
                SendClientMessage(playerid, COLOR_ALLDEPT, "Hitna Sluzba: Izvinite, ne razumijem, da li trebate 'Policiju' ili 'Hitnu Pomoc'?");
                return 0;
            }
        }
        if(Mobile[playerid] == 3900)
        {
            SendFamilyMessage(9, COLOR_GREEN, "{F3FF02}[INFO] Imate novu poruku:");
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, sizeof(string), "[ID:%d] %s kaze: %s", playerid, sendername, text);
            SendFamilyMessage(9, COLOR_GREEN, string);
            SendClientMessage(playerid, COLOR_GREEN, "ABC Studio: Hvala vam na informacijama !");
            SendClientMessage(playerid, COLOR_GRAD2, "[INFO] Prekinuli su !");
            Mobile[playerid] = 255;
            return 0;
        }
        if(IsPlayerConnected(Mobile[playerid]))
        {
            if(Mobile[Mobile[playerid]] == playerid)
            {
                if(PlayerInfo[Mobile[playerid]][pSpeaker] == 1)
                {
                    ProxDetector(20.0, Mobile[playerid], string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
                }
                else
                {
                    SendClientMessage(Mobile[playerid], COLOR_YELLOW,string);
                }
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_YELLOW,"Nema nikog tamo !");
        }
        return 0;
    }
    if (BusShowLocation[playerid][0] == 1)
    {
        new idx;
        tmp = strtok(text, idx);
        if ((strcmp("yes", tmp, true, strlen(tmp)) == 0) && (strlen(tmp) == strlen("yes")))
        {
            SetPlayerCheckpoint(playerid, BusShowLocation[playerid][1], BusShowLocation[playerid][2], BusShowLocation[playerid][3], 3.0);
            SendClientMessage(playerid, COLOR_YELLOW, "Lokacija vam je prikazana na mapi, bolje vam je da pozurite!");
            BusShowLocation[playerid][0] = 0;
            BusShowLocationC[playerid] = 1;
            return 0;
        }
        else
        {
            BusShowLocation[playerid][0] = 0;
            return 0;
        }
    }
    if (realchat)
    {
        if(gPlayerLogged[playerid] == 0)
        {
            return 0;
        }
        GetPlayerName(playerid, sendername, sizeof(sendername));
        if(!IsPlayerInAnyVehicle(playerid))
        {
            if(PlayerInfo[playerid][pMaskuse] == 1)
            {
                format(string, sizeof(string), "Stranac kaze: %s", text);
                ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
            }
            else
            {
                format(string, sizeof(string), "%s kaze: %s", sendername, text);
                ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
            }
        }
        else
        {
            new carid = GetPlayerVehicleID(playerid);
            new pveh = GetVehicleModel(GetPlayerVehicleID(playerid));
            if(IsABike(carid) || IsAOBike(carid) || IsAPizzabike(carid) || IsAPlane(carid) || IsABoat(carid) || IsAHarvest(carid) || pveh == 523 || pveh == 480 || pveh == 567 || pveh == 533 || pveh == 555 || pveh == 539 || pveh == 572 || pveh == 571 || pveh == 530 || pveh == 457 || pveh == 575 || pveh == 536 || pveh == 424)
            {
                if(PlayerInfo[playerid][pMaskuse] == 1)
                {
                    format(string, sizeof(string), "Stranac kaze: %s", text);
                    ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
                }
                else
                {
                    format(string, sizeof(string), "%s kaze: %s", sendername, text);
                    ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
                }
            }
            else
            {
                if(VehicleWindows[GetPlayerVehicleID(playerid)] == 0)
                {
                    if(PlayerInfo[playerid][pMaskuse] == 1)
                    {
                        format(string, sizeof(string), "(Prozor Zatvoren) Stranac kaze: %s", text);
                        ProxDetector(10.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
                    }
                    else
                    {
                        format(string, sizeof(string), "(Prozor Zatvoren) %s kaze: %s", sendername, text);
                        ProxDetector(10.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
                    }
                }
                else
                {
                    if(PlayerInfo[playerid][pMaskuse] == 1)
                    {
                        format(string, sizeof(string), "(Prozor Otvoren) Stranac kaze: %s", text);
                        ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
                    }
                    else
                    {
                        format(string, sizeof(string), "(Prozor Otvoren) %s kaze: %s", sendername, text);
                        ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
                    }
                }
            }
        }
        return 0;
    }
    return 1;
}