Saving and loading with Y_ini
#1

Hi all,

I got a problem using Y_ini. I just don't understand it. In another script I got it working perfectly fine and now I did it the exact same way and it does not work. So here's the problem:
I'm making a teleport script in which you can save and load teleports (not completely finished yet, but I'm working on the save and loading part). The problem is that I can create a new teleport, and it DOES save to the file, but next, when I reperform the dialog, it still prints the old value of Place0, though it has changed

Here's my code
Code:
#include <a_samp>
#include <YSI/y_ini>

#define			FILTERSCRIPT
#define			TP_DIALOG			50
#define			MAX_TP_NAME			32
#define			MAX_TP				20

new TP_NAME[MAX_TP][MAX_TP_NAME];

public OnPlayerCommandText(playerid, cmdtext[]){
	new cmd[32],
		idx;
	
	cmd = strtok(cmdtext, idx);
	if(strcmp("/teleport", cmd, true) == 0){
		return ShowPlayerDialog(playerid, TP_DIALOG, DIALOG_STYLE_LIST, "Teleport menu", "Show teleports\nCreate teleport\nDelete teleport", "OK", "Cancel");
	}
	return 0;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]){
	if(response){
		switch(dialogid){
			case (TP_DIALOG):{
				switch(listitem){
					case 0: ShowTeleports(playerid);
					case 1: CreateTeleport(playerid);
				}
			}
			case (TP_DIALOG + 1):{
				new INI:teleport = INI_Open("Teleports.ini");
				INI_SetTag(teleport, "Names");
				INI_WriteString(teleport, "Place0", inputtext);
				INI_Close(teleport);
			}
		}
	}
	return 0;
}

stock ShowTeleports(playerid){
	#pragma unused playerid
	INI_ParseFile("Teleports.ini", "load_teleports_%s", .bExtra = false);
	printf(TP_NAME[0]);
	return 0;
}

stock CreateTeleport(playerid){
	return ShowPlayerDialog(playerid, TP_DIALOG + 1, DIALOG_STYLE_INPUT, "Create Teleport", "Give in a short description of your location", "OK", "Cancel");
}

forward load_teleports_Names(name[], value[]);
public load_teleports_Names(name[], value[])
{
    INI_String("Place0", TP_NAME[0], MAX_TP_NAME);
    return 0;
}
And here's my file
Code:
[Names]
Place0 = Los Santos
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)