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=595597)
Y_ini help -
xTURBOx - 05.12.2015
PHP код:
CMD:givecolourtext(playerid,params[])
{
new id,idname[MAX_PLAYER_NAME],string[128];
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF}: You are not authorised to use this command");
if(isnull(params)) return SendClientMessage(playerid,COLOR_RED,"Usage: {FFFFFF}/givecolourtext (id)");
if(pInfo[id][ColourText] == 1) return SendClientMessage(playerid,COLOR_RED, "[ERROR]{FFFFFF}: That player already have colourtext, How can you give it twice?");
GetPlayerName(playerid, idname, sizeof(idname));
format(string, sizeof(string), "You have given %s(%d) colour text.",idname,id);
SendClientMessage(playerid, -1, string);
SendClientMessage(id, -1, "An administrator has given you ColourText. You can now use /colourtext");
new INI:file = INI_Open(Path(id));
INI_SetTag(file,"ColourText Player's Data");
INI_WriteInt(file,"ColourText",1);
INI_Close(file);
return 1;
}
CMD:takecolourtext(playerid,params[])
{
new id,idname[MAX_PLAYER_NAME],string[128];
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF}: You are not authorised to use this command");
if(isnull(params)) return SendClientMessage(playerid,COLOR_RED,"Usage: {FFFFFF}/takecolourtext (id)");
if(pInfo[id][ColourText] == 0) return SendClientMessage(playerid,COLOR_RED, "[ERROR]{FFFFFF}: That player doesnot have colourtext, How can you take it?");
GetPlayerName(playerid, idname, sizeof(idname));
format(string, sizeof(string), "You have taken %s(%d)'s' colour text.",idname,id);
SendClientMessage(playerid, -1, string);
SendClientMessage(id, -1, "An administrator has taken your ColourText. You cannot now use /colourtext anymore");
new INI:file = INI_Open(Path(id));
INI_SetTag(file,"ColourText Player's Data");
INI_WriteInt(file,"ColourText",0);
INI_Close(file);
return 1;
}
it does not save the file
eg: if colourtext = 0 it remains 0
Re: Y_ini help -
xTURBOx - 07.12.2015
bump
Re: Y_ini help -
Logic_ - 07.12.2015
PHP код:
CMD:givecolourtext(playerid,params[])
{
new id,idname[MAX_PLAYER_NAME],string[128];
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF}: You are not authorised to use this command");
if(isnull(params)) return SendClientMessage(playerid,COLOR_RED,"Usage: {FFFFFF}/givecolourtext (id)");
if(pInfo[id][ColourText] == 1) return SendClientMessage(playerid,COLOR_RED, "[ERROR]{FFFFFF}: That player already have colourtext, How can you give it twice?");
GetPlayerName(playerid, idname, sizeof(idname));
format(string, sizeof(string), "You have given %s(%d) colour text.",idname,id);
SendClientMessage(playerid, -1, string);
SendClientMessage(id, -1, "An administrator has given you ColourText. You can now use /colourtext");
new INI:File = INI_Open(path);
INI_SetTag(File, "data");
INI_WriteInt(File, "ColourText", 1);
INI_Close(File);
return 1;
}
and show me your stats saving stock (if any).. have you added the INI_WriteInt line in the stats saving stock? does it works for the player who is online at the moment? As I believe the tag have to be same in the Y_INI and it can't be changed.. Waiting for your reply.
example of a stats saving stock, you can use it in OnPlayerDisconnect or in the command too.
PHP код:
stock SaveStats(playerid)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"ColourText",pInfo[id][ColourText]);
return 1;
}