Split function problem.
#1

Hello,

I have to following code, and for some reason it doesn't print me step12, which means that the code stops running at the split function;

pawn Код:
new m_attach[13][16];
    print("step11");
    print(data[3]);
    split(data[3], m_attach, ',');
    print("step12");
    if(strval(m_attach[11]) != 0)
    {
        print("step13");
        SetPlayerAttachedObject(playerid, 0, strval(m_attach[0]), strval(m_attach[1]), floatstr(m_attach[2]), floatstr(m_attach[3]), floatstr(m_attach[4]), floatstr(m_attach[5]), floatstr(m_attach[6]), floatstr(m_attach[7]), floatstr(m_attach[8]), floatstr(m_attach[9]), floatstr(m_attach[10]), strval(m_attach[11]), strval(m_attach[12]));
    }
    else
    {
        print("step14");
        SetPlayerAttachedObject(playerid, 0, strval(m_attach[0]), strval(m_attach[1]), floatstr(m_attach[2]), floatstr(m_attach[3]), floatstr(m_attach[4]), floatstr(m_attach[5]), floatstr(m_attach[6]), floatstr(m_attach[7]), floatstr(m_attach[8]), floatstr(m_attach[9]), floatstr(m_attach[10]));
    }
    pGeneral[playerid][PLR_ATTACHED_ID] = strval(data[0]);
    print("step4");
data[3] contains: 19137, 2, 0.138999, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000,0,0,
Reply
#2

Use sscanf.
Reply
#3

Quote:
Originally Posted by MP2
Посмотреть сообщение
Use sscanf.
Do what MP2 said. Use sscanf or show us your split function , maybe we can fix it by updating something in the code.
Reply
#4

Ye well I fixed it, it seems the stringsize of data was to small, something that happends to me often ;p
Anyway I prefer using split because now i don't have to create many different variables like ints,floats,strings.
But anyway, thanks.
Reply
#5

If your still going to use the same split function you might want to edit it, so that it doesn't break your code when an incorrect array size is used. EG, send the size of the string with the function call. Make it give a warning instead of crashing.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)