format problem
#1

Hello,
pawn Код:
else if (dialogid == DIALOG_GATEINFOS)
    {
        if (response)
        {
            new astring[6][512];
            new fobjectid = strval(inputtext);
            if (fexist(GateINI(fobjectid)))
            {
                INI_ParseFile(GateINI(fobjectid), "LoadGateData_%s", .bExtra = true, .extra = fobjectid);
                format(astring[0], 512, ""COL_GREEN"||"COL_WHITE"ID: %i "COL_GREEN"||"COL_WHITE" Model: %i "COL_GREEN"||"COL_WHITE" Speed: %f "COL_GREEN"||"COL_WHITE" Range: %f "COL_GREEN"||"COL_WHITE" Owner: %s "COL_GREEN"||"COL_WHITE" Pass: %s "COL_GREEN"||", fgateid[fobjectid], fgmodelid[fobjectid], gspeed[fobjectid], grange[fobjectid], gowner[fobjectid], gpassword[fobjectid]);
                format(astring[1], 512, ""COL_GREEN"||"COL_WHITE" PosX: %f "COL_GREEN"|| "COL_WHITE"PosY: %f "COL_GREEN"|| "COL_WHITE"PosZ: %f "COL_GREEN"||", Gpos[fobjectid][0], Gpos[fobjectid][1], Gpos[fobjectid][2]);
                format(astring[2], 512, ""COL_GREEN"||"COL_WHITE" RotX: %f "COL_GREEN"|| "COL_WHITE"RotY: %f "COL_GREEN"|| "COL_WHITE"RotZ: %f "COL_GREEN"||", Grot[fobjectid][0], Grot[fobjectid][1], Grot[fobjectid][2]);
                format(astring[3], 512, ""COL_GREEN"||"COL_WHITE" PosXm: %f "COL_GREEN"|| "COL_WHITE"PosYm: %f "COL_GREEN"|| "COL_WHITE"PosZm: %f "COL_GREEN"||", Gposm[fobjectid][0], Gposm[fobjectid][1], Gposm[fobjectid][2]);
                format(astring[4], 512, ""COL_GREEN"||"COL_WHITE" RotXm: %f "COL_GREEN"|| "COL_WHITE"RotYm: %f "COL_GREEN"|| "COL_WHITE"RotZm: %f "COL_GREEN"||", Grotm[fobjectid][0], Grotm[fobjectid][1], Grotm[fobjectid][2]);
                format(astring[5], 512, "------------------------------------------------------------Gate ID: %i Infos------------------------------------------------------------", fobjectid);
                SendClientMessage(playerid, 0x9ACD32AA, astring[5]);
                SendClientMessage(playerid, -1, astring[0]);
                SendClientMessage(playerid, -1, astring[1]);
                SendClientMessage(playerid, -1, astring[2]);
                SendClientMessage(playerid, -1, astring[3]);
                SendClientMessage(playerid, -1, astring[4]);
                SendClientMessage(playerid, 0x9ACD32AA, astring[5]);

            }
            else SendClientMessage(playerid, -1, ""COL_RED"Gate does not exist!");
        }
    }
The first string (astring[0]) is not showing on the screen http://i.imgur.com/tH6kIUY.jpg
(it is not a null string, (I checked it using printf("%s", astring[0]) )
Also I'm getting this when I compile!
Код:
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase

Header size:           6900 bytes
Code size:           170692 bytes
Data size:         27914036 bytes
Stack/heap size:      16384 bytes; estimated max. usage: unknown, due to recursion
Total requirements:28108012 bytes
Reply
#2

The formatted string likely exceeds the variable... do some calculations, how long is the written text and spaces, + the max size of each element your formatting in. Which is good practice anyway as if a string is too long, your allocating unnecessary memory.
Reply
#3

pawn Код:
else if (dialogid == DIALOG_GATEINFOS)
{
    if (response)
    {
        new fobjectid = strval(inputtext);
        if(fexist(GateINI(fobjectid)))
        {
            new astring[145];
            INI_ParseFile(GateINI(fobjectid), "LoadGateData_%s", .bExtra = true, .extra = fobjectid);
            format(astring, sizeof(astring), "------------------------------------------------------------Gate ID: %i Infos------------------------------------------------------------", fobjectid);
            SendClientMessage(playerid, 0x9ACD3200, astring);
            format(astring, sizeof(astring), ""COL_GREEN"||"COL_WHITE"ID: %i "COL_GREEN"||"COL_WHITE" Model: %i "COL_GREEN"||"COL_WHITE" Speed: %f "COL_GREEN"||"COL_WHITE" Range: %f "COL_GREEN"||"COL_WHITE" Owner: %s "COL_GREEN"||"COL_WHITE" Pass: %s "COL_GREEN"||", fgateid[fobjectid], fgmodelid[fobjectid], gspeed[fobjectid], grange[fobjectid], gowner[fobjectid], gpassword[fobjectid]);
            SendClientMessage(playerid, -1, astring);
            format(astring, sizeof(astring), ""COL_GREEN"||"COL_WHITE" PosX: %f "COL_GREEN"|| "COL_WHITE"PosY: %f "COL_GREEN"|| "COL_WHITE"PosZ: %f "COL_GREEN"||", Gpos[fobjectid][0], Gpos[fobjectid][1], Gpos[fobjectid][2]);
            SendClientMessage(playerid, -1, astring);
            format(astring, sizeof(astring), ""COL_GREEN"||"COL_WHITE" RotX: %f "COL_GREEN"|| "COL_WHITE"RotY: %f "COL_GREEN"|| "COL_WHITE"RotZ: %f "COL_GREEN"||", Grot[fobjectid][0], Grot[fobjectid][1], Grot[fobjectid][2]);
            SendClientMessage(playerid, -1, astring);
            format(astring, sizeof(astring), ""COL_GREEN"||"COL_WHITE" PosXm: %f "COL_GREEN"|| "COL_WHITE"PosYm: %f "COL_GREEN"|| "COL_WHITE"PosZm: %f "COL_GREEN"||", Gposm[fobjectid][0], Gposm[fobjectid][1], Gposm[fobjectid][2]);
            SendClientMessage(playerid, -1, astring);
            format(astring, sizeof(astring), ""COL_GREEN"||"COL_WHITE" RotXm: %f "COL_GREEN"|| "COL_WHITE"RotYm: %f "COL_GREEN"|| "COL_WHITE"RotZm: %f "COL_GREEN"||", Grotm[fobjectid][0], Grotm[fobjectid][1], Grotm[fobjectid][2]);
            SendClientMessage(playerid, -1, astring);
            format(astring, sizeof(astring), "------------------------------------------------------------Gate ID: %i Infos------------------------------------------------------------", fobjectid);
            SendClientMessage(playerid, 0x9ACD3200, astring);
        }
        else SendClientMessage(playerid, -1, ""COL_RED"Gate does not exist!");
    }
}
Reply
#4

pawn Код:
#pragma dynamic 10000
Reply
#5

+ rep for all: Jefff's sollution solved both of the non showing line and the compiling "error"
silenthill's Solution soldved the compiling error only (+rep also)
IceCube! thanks for the advice , that was the problem, I had to optimize it! +rep
Reply
#6

Quote:
Originally Posted by Jefff
Посмотреть сообщение
pawn Код:
else if (dialogid == DIALOG_GATEINFOS)
{
    if (response)
    {
        new fobjectid = strval(inputtext);
        if(fexist(GateINI(fobjectid)))
        {
            new astring[145];
            INI_ParseFile(GateINI(fobjectid), "LoadGateData_%s", .bExtra = true, .extra = fobjectid);
            format(astring, sizeof(astring), "------------------------------------------------------------Gate ID: %i Infos------------------------------------------------------------", fobjectid);
            SendClientMessage(playerid, 0x9ACD3200, astring);
            format(astring, sizeof(astring), ""COL_GREEN"||"COL_WHITE"ID: %i "COL_GREEN"||"COL_WHITE" Model: %i "COL_GREEN"||"COL_WHITE" Speed: %f "COL_GREEN"||"COL_WHITE" Range: %f "COL_GREEN"||"COL_WHITE" Owner: %s "COL_GREEN"||"COL_WHITE" Pass: %s "COL_GREEN"||", fgateid[fobjectid], fgmodelid[fobjectid], gspeed[fobjectid], grange[fobjectid], gowner[fobjectid], gpassword[fobjectid]);
            SendClientMessage(playerid, -1, astring);
            format(astring, sizeof(astring), ""COL_GREEN"||"COL_WHITE" PosX: %f "COL_GREEN"|| "COL_WHITE"PosY: %f "COL_GREEN"|| "COL_WHITE"PosZ: %f "COL_GREEN"||", Gpos[fobjectid][0], Gpos[fobjectid][1], Gpos[fobjectid][2]);
            SendClientMessage(playerid, -1, astring);
            format(astring, sizeof(astring), ""COL_GREEN"||"COL_WHITE" RotX: %f "COL_GREEN"|| "COL_WHITE"RotY: %f "COL_GREEN"|| "COL_WHITE"RotZ: %f "COL_GREEN"||", Grot[fobjectid][0], Grot[fobjectid][1], Grot[fobjectid][2]);
            SendClientMessage(playerid, -1, astring);
            format(astring, sizeof(astring), ""COL_GREEN"||"COL_WHITE" PosXm: %f "COL_GREEN"|| "COL_WHITE"PosYm: %f "COL_GREEN"|| "COL_WHITE"PosZm: %f "COL_GREEN"||", Gposm[fobjectid][0], Gposm[fobjectid][1], Gposm[fobjectid][2]);
            SendClientMessage(playerid, -1, astring);
            format(astring, sizeof(astring), ""COL_GREEN"||"COL_WHITE" RotXm: %f "COL_GREEN"|| "COL_WHITE"RotYm: %f "COL_GREEN"|| "COL_WHITE"RotZm: %f "COL_GREEN"||", Grotm[fobjectid][0], Grotm[fobjectid][1], Grotm[fobjectid][2]);
            SendClientMessage(playerid, -1, astring);
            format(astring, sizeof(astring), "------------------------------------------------------------Gate ID: %i Infos------------------------------------------------------------", fobjectid);
            SendClientMessage(playerid, 0x9ACD3200, astring);
        }
        else SendClientMessage(playerid, -1, ""COL_RED"Gate does not exist!");
    }
}
Actually, all lines are shown on the screen but, the first line is not entirely shown!
When I increase/derease the size of astring, the first line doesn't show at all which means I have to keep ir 145 but 145 is not enough because it won't show the entire line (when I add a printf before the clientmessage, the first line is entirely shown on the console (when I make the size [200]) but SendClientMessage doesn't show anything O.o) help please
I am so confused
Reply
#7

Too many color codes they count as characters every time you use a color code! Basically you need to split that line into 2.
Reply
#8

Ya, that's what I just did, even though I don't want to :/ anyway +rep
Reply
#9

You can only send 255 characters using SendClientMessage at once, I believe
You should simply split it up in more lines if your texts exceeds the limit.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)