[HELP]Split a string
#1

I do a system to save only the objects attached to the player that I would save all the 9 fields of '"SetPlayerAttachedObject" in one field of mysql instead of create 9.
Else is needed to use sscanf, but I do not understand how to use it to split a string.

well now I have made ​​the function to insert values ​​in database
PHP код:
stock SavePlayerObject(playeridindexmodelidboneidFloat:fOffsetXFloat:fOffsetYFloat:fOffsetZFloat:fRotXFloat:fRotYFloat:fRotZFloat:fScaleXFloat:fScaleYFloat:fScaleZ)
{
    new 
string[500];
    switch(
index)
    {
        case 
SLOT_TESTA:
        {
            
format(string,sizeof(string),"%d,%d,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f",modelidboneidFloat:fOffsetXFloat:fOffsetYFloat:fOffsetZFloat:fRotXFloat:fRotYFloat:fRotZFloat:fScaleXFloat:fScaleYFloat:fScaleZ);
            
MySQLUpdatePlayerStr(queryPlayerInfo[playerid][pSQLID], "OggettoTesta",string);
        }
        case 
SLOT_BOCCA:
        {
            
format(string,sizeof(string),"%d,%d,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f",modelidboneidFloat:fOffsetXFloat:fOffsetYFloat:fOffsetZFloat:fRotXFloat:fRotYFloat:fRotZFloat:fScaleXFloat:fScaleYFloat:fScaleZ);
            
MySQLUpdatePlayerStr(queryPlayerInfo[playerid][pSQLID], "OggettoBocca",string);
        }
        case 
SLOT_OCCHI:
        {
            
format(string,sizeof(string),"%d,%d,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f",modelidboneidFloat:fOffsetXFloat:fOffsetYFloat:fOffsetZFloat:fRotXFloat:fRotYFloat:fRotZFloat:fScaleXFloat:fScaleYFloat:fScaleZ);
            
MySQLUpdatePlayerStr(queryPlayerInfo[playerid][pSQLID], "OggettoOcchi",string);
        }
    }

PHP код:
stock LoadPlayerObject(playerid)
{
    new 
indexmodelidboneidFloat:fOffsetXFloat:fOffsetYFloat:fOffsetZFloat:fRotXFloat:fRotYFloat:fRotZFloat:fScaleXFloat:fScaleYFloat:fScaleZ;
    
//the string with all values it's PlayerInfo[playerid][pOggTesta]
    
SetPlayerAttachedObject(playeridindexmodelidboneidFloat:fOffsetXFloat:fOffsetYFloat:fOffsetZFloat:fRotXFloat:fRotYFloat:fRotZFloat:fScaleXFloat:fScaleYFloat:fScaleZ);

I do not know how to separate the various fields separated by a comma and assign to each variable and mostly how to convert the string into a numeric variable
Reply


Messages In This Thread
[HELP]Split a string [SSCANF PROBLEM] - by xX_Simon_Xx - 25.04.2012, 14:27
Re: Save an attached player object in one Mysql field - by SuperViper - 25.04.2012, 14:29
Re: Save an attached player object in one Mysql field - by xX_Simon_Xx - 25.04.2012, 14:35
Re: [HELP]Split a string - by SuperViper - 25.04.2012, 14:38
Re: [HELP]Split a string - by xX_Simon_Xx - 25.04.2012, 14:44
Re: [HELP]Split a string - by SuperViper - 25.04.2012, 14:46
Re: [HELP]Split a string - by xX_Simon_Xx - 25.04.2012, 15:19
Re: [HELP]Split a string - by xX_Simon_Xx - 25.04.2012, 17:33

Forum Jump:


Users browsing this thread: 4 Guest(s)