18.02.2013, 00:37
(
Last edited by Y_Less; 19/02/2013 at 04:50 PM.
)
This has been a feature of YSI for a long time, but a recent update has made it even more useful by supporting a wider range of variables. The system is fully documented on the YSI wiki, but a brief description is also given below:
http://ysi.wikia.com/wiki/Library:YSI\y_svar
To save and load data using y_svar, you just need to declare the array in which the data will be stored! You need to do that anyway for all data, but with other systems you then need to actually write the save and load code too. This system does away with all that simply by replacing "new" with "svar":
That will save the variable called "gSavedText" when the mode ends, and reload it when the mode starts. There is NO complex file/database code required AT ALL - it is all done behind the scenes.
To download this library, just get YSI from the main topic:
https://sampforum.blast.hk/showthread.php?tid=321092
http://ysi.wikia.com/wiki/Library:YSI\y_svar
To save and load data using y_svar, you just need to declare the array in which the data will be stored! You need to do that anyway for all data, but with other systems you then need to actually write the save and load code too. This system does away with all that simply by replacing "new" with "svar":
pawn Code:
#define MODE_NAME "SavedText"
#include <YSI\y_svar>
svar gSavedText[200];
public OnGameModeInit()
{
printf("Saved Text: %s", gSavedText);
}
YCMD:settext(playerid, params[], help)
{
if (help) return SendClientMessage(playerid, 0xFF0000AA, "Sets the saved text");
strcpy(gSavedText, params);
return 1;
}
To download this library, just get YSI from the main topic:
https://sampforum.blast.hk/showthread.php?tid=321092