SA-MP Forums Archive
Y_INI help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Y_INI help (/showthread.php?tid=503590)



Y_INI help - Lidor124 - 30.03.2014

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]);
	}



Re: Y_INI help - Lidor124 - 30.03.2014

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


Re: Y_INI help - BroZeus - 30.03.2014

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]);
    }



Re: Y_INI help - Lidor124 - 01.04.2014

Is there any other way to make it without tags?


Re: Y_INI help - Lidor124 - 02.04.2014

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


Re: Y_INI help - Lidor124 - 04.04.2014

BUMP


Re: Y_INI help - Konstantinos - 05.04.2014

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!


Re: Y_INI help - Lidor124 - 05.04.2014

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]);
	}



Re: Y_INI help - Lidor124 - 07.04.2014

BUMP