SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 03/06/2011, 08:44 PM   #1
StilThere
Big Clucker
 
Join Date: May 2011
Posts: 86
Reputation: 0
Default Saving and loading with Y_ini

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
StilThere is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Y_INI Loading Help randomkid88 Help Archive 3 06/06/2011 05:47 PM
y_ini saving help Tommy_Mandaz Help Archive 16 18/04/2011 07:17 AM
Issue with y_ini skin loading OldDirtyBastard Help Archive 3 17/02/2011 05:43 PM
[SOLVED]Strange y_ini skin loading problem OldDirtyBastard Help Archive 0 16/02/2011 08:09 PM


All times are GMT. The time now is 05:50 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.