Y_INI help
#1

Hi all
First of all, Its my first time of using Y_INI to store values of players, so pelase explain me properly what you have done in the following code/changed.
Okay so my problem is that i dont know how to use loops with Y_INI on writing, in the following code there is a loop that counting my toys number (slots), if i have 5 slots so the following code will be shown 5 times in the INI file of a specific player for each slots.
+REP if your help works :P

Код:
for(new v = 0; v < MAX_PLAYERTOYS; v++)
	{
		INI_WriteFloat(File, "pt%dModelID", PlayerToyInfo[playerid][v][ptModelID]);
		INI_WriteFloat(File, "pt%dBone", PlayerToyInfo[playerid][v][ptBone]);
		INI_WriteFloat(File, "pt%dPosX", PlayerToyInfo[playerid][v][ptPosX]);
		INI_WriteFloat(File, "pt%dPosY", PlayerToyInfo[playerid][v][ptPosY]);
		INI_WriteFloat(File, "pt%dPosZ", PlayerToyInfo[playerid][v][ptPosZ]);
		INI_WriteFloat(File, "pt%dRotX", PlayerToyInfo[playerid][v][ptRotX]);
		INI_WriteFloat(File, "pt%dRotY", PlayerToyInfo[playerid][v][ptRotY]);
		INI_WriteFloat(File, "pt%dRotZ", PlayerToyInfo[playerid][v][ptRotZ]);
		INI_WriteFloat(File, "pt%dScaleX", PlayerToyInfo[playerid][v][ptScaleX]);
		INI_WriteFloat(File, "pt%dScaleY", PlayerToyInfo[playerid][v][ptScaleY]);
		INI_WriteFloat(File, "pt%dScaleZ", PlayerToyInfo[playerid][v][ptScaleZ]);
	}
Reply
#2

Please its very important... i need my registration and login system complete ASAP...
Reply
#3

maybe this
pawn Код:
new tag[50];
for(new v = 0; v < MAX_PLAYERTOYS; v++)
    {    
                format(tag,sizeof(tag),"ToyNo%i",v);
                INI_SetTag(File,tag);
        INI_WriteFloat(File, "pt%dModelID", PlayerToyInfo[playerid][v][ptModelID]);
        INI_WriteFloat(File, "pt%dBone", PlayerToyInfo[playerid][v][ptBone]);
        INI_WriteFloat(File, "pt%dPosX", PlayerToyInfo[playerid][v][ptPosX]);
        INI_WriteFloat(File, "pt%dPosY", PlayerToyInfo[playerid][v][ptPosY]);
        INI_WriteFloat(File, "pt%dPosZ", PlayerToyInfo[playerid][v][ptPosZ]);
        INI_WriteFloat(File, "pt%dRotX", PlayerToyInfo[playerid][v][ptRotX]);
        INI_WriteFloat(File, "pt%dRotY", PlayerToyInfo[playerid][v][ptRotY]);
        INI_WriteFloat(File, "pt%dRotZ", PlayerToyInfo[playerid][v][ptRotZ]);
        INI_WriteFloat(File, "pt%dScaleX", PlayerToyInfo[playerid][v][ptScaleX]);
        INI_WriteFloat(File, "pt%dScaleY", PlayerToyInfo[playerid][v][ptScaleY]);
        INI_WriteFloat(File, "pt%dScaleZ", PlayerToyInfo[playerid][v][ptScaleZ]);
    }
Reply
#4

Is there any other way to make it without tags?
Reply
#5

Quote:
Originally Posted by Lidor124
Посмотреть сообщение
Is there any other way to make it without tags?
BUMP
Reply
#6

BUMP
Reply
#7

You need first to format it and then use the name of it.

pawn Код:
// opening file for playerid
new tmp[32];
for(new v = 0; v < MAX_PLAYERTOYS; v++)
{
    format(tmp, sizeof (tmp), "pt%dModelID", v);
    INI_WriteInt(File, tmp, PlayerToyInfo[playerid][v][ptModelID]);
    format(tmp, sizeof (tmp), "pt%dBone", v);
    INI_WriteInt(File, tmp, PlayerToyInfo[playerid][v][ptBone]);
    // continue the rest like that
}
// closing file for playerid
By the way, modelid and bone are integers not floats. Be careful on those!
Reply
#8

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
You need first to format it and then use the name of it.

pawn Код:
// opening file for playerid
new tmp[32];
for(new v = 0; v < MAX_PLAYERTOYS; v++)
{
    format(tmp, sizeof (tmp), "pt%dModelID", v);
    INI_WriteInt(File, tmp, PlayerToyInfo[playerid][v][ptModelID]);
    format(tmp, sizeof (tmp), "pt%dBone", v);
    INI_WriteInt(File, tmp, PlayerToyInfo[playerid][v][ptBone]);
    // continue the rest like that
}
// closing file for playerid
By the way, modelid and bone are integers not floats. Be careful on those!
@Konstatinos, on loading file for player i need to do exactly the same as you posted or just loop and each enum variable one time?

I mean: (if it will load all the toys for player according to number of slots in the player ini file?)

Код:
for(new t = 0; t < MAX_PLAYERTOYS; t++)
	{		
		INI_Int("ptModelID", PlayerToyInfo[playerid][t][ptModelID]);
		INI_Int("ptBone", PlayerToyInfo[playerid][t][ptBone]);
		INI_Float("ptPosX", PlayerToyInfo[playerid][t][ptPosX]);
		INI_Float("ptPosY", PlayerToyInfo[playerid][t][ptPosY]);
		INI_Float("ptPosZ", PlayerToyInfo[playerid][t][ptPosZ]);
		INI_Float("ptRotX", PlayerToyInfo[playerid][t][ptRotX]);
		INI_Float("ptRotY", PlayerToyInfo[playerid][t][ptRotY]);
		INI_Float("ptRotZ", PlayerToyInfo[playerid][t][ptRotZ]);
		INI_Float("ptScaleX", PlayerToyInfo[playerid][t][ptScaleX]);
		INI_Float("ptScaleY", PlayerToyInfo[playerid][t][ptScaleY]);
		INI_Float("ptScaleZ", PlayerToyInfo[playerid][t][ptScaleZ]);
	}
Reply
#9

BUMP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)