The string get shrink why?
#1

As can you see i'm typing " Vand casa " and it get "Casa " ...



pawn Код:
if(Mobile[playerid] == 2525)
        {
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GREEN, "People CNN: Ok , what is the announce??");
                return 0;
            }
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new length = strlen(text);
            while ((idx < length) && (text[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[643];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = text[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            new payout = idx * SBizzInfo[6][sbEntranceCost] * 2;
            if(GetPlayerMoney(playerid) < payout + 900)
            {
                format(string,sizeof(string), "~R~NO CASH~N~~R~(%d$ )", payout);
                GameTextForPlayer(playerid, string, 5000, 1);
                Mobile[playerid] = 255;
                return 1;
            }
            if(adds == 0)
            {
                format(string,sizeof(string), "~Y~WAIT PLEASE ~R~60~Y~ SEC", payout);
                GameTextForPlayer(playerid, string, 5000, 1);
                Mobile[playerid] = 255;
                return 1;
            }
            SafeGivePlayerMoney(playerid, - payout);
            SBizzInfo[6][sbTill] += payout;
            new stringnumar[456];
            if(PlayerInfo[playerid][pPnumber] != 0)
            {
                format(stringnumar, 456, "%d", PlayerInfo[playerid][pPnumber]);
                strins(stringnumar, "-", 3);
            }
            else
            {
                stringnumar = "000-000";
            }
            new stringcnn[456];
            format(stringcnn, sizeof(stringcnn), "(Anunt publicat de %s) -  %s, (Phone: %s)",  GetName(playerid), result, stringnumar);
            OOCNews(TEAM_GROVE_COLOR,stringcnn);
            format(string, sizeof(string), "~Y~Paid ~R~%d$~n~~Y~%d Characters", payout, idx);
            GameTextForPlayer(playerid, string, 5000, 4);
            SetTimer("AddsOn", addtimer, 0); adds = 0;
            Mobile[playerid] = 255;
        }
Reply
#2

You are removing the first word by using "strtok placed in a function - godfather style", after nearly 8 years this disease isn't dead yet

Long version
pawn Код:
if(Mobile[playerid] == 2525)
        {
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GREEN, "People CNN: Ok , what is the announce??");
                return 0;
            }
            //GetPlayerName(playerid, sendername, sizeof(sendername)); // never used
            //strtok part removed
            new payout = idx * SBizzInfo[6][sbEntranceCost] * 2;
            if(GetPlayerMoney(playerid) < payout + 900)
            {
                format(string,sizeof(string), "~R~NO CASH~N~~R~(%d$ )", payout);
                GameTextForPlayer(playerid, string, 5000, 1);
                Mobile[playerid] = 255;
                return 1;
            }
            if(adds == 0) // unclear variable name
            {
                format(string,sizeof(string), "~Y~WAIT PLEASE ~R~60~Y~ SEC", payout); // payout never formated (no %d in string)
                GameTextForPlayer(playerid, string, 5000, 1);
                Mobile[playerid] = 255;
                return 1;
            }
            SafeGivePlayerMoney(playerid, - payout);
            SBizzInfo[6][sbTill] += payout;
            new stringnumar[32] = "000-000"; // why 456 cells ?
            if(PlayerInfo[playerid][pPnumber] != 0)
            {
                format(stringnumar, sizeof stringnumar, "%d", PlayerInfo[playerid][pPnumber]); // why format ? use strcat to copy a string
                strins(stringnumar, "-", 3);
            }
            new stringcnn[128]; // yeah you like the number 456
            format(stringcnn, sizeof(stringcnn), "(Anunt publicat de %s) -  %s, (Phone: %s)",  GetName(playerid), text, stringnumar);
            OOCNews(TEAM_GROVE_COLOR,stringcnn);
            format(string, sizeof(string), "~Y~Paid ~R~%d$~n~~Y~%d Characters", payout, idx);
            GameTextForPlayer(playerid, string, 5000, 4);
            SetTimer("AddsOn", addtimer, 0);
            Mobile[playerid] = 255;
            adds = 0;
        }
Short version - change in that line "result" to "text"
pawn Код:
format(stringcnn, sizeof(stringcnn), "(Anunt publicat de %s) -  %s, (Phone: %s)",  GetName(playerid), result, stringnumar);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)