SA-MP Forums Archive
Saving a variable using Y_INI - 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: Saving a variable using Y_INI (/showthread.php?tid=335254)



Saving a variable using Y_INI - HazardGaming - 17.04.2012

Hello,
My saving system is Y_INI and I was wondering how I would make a command to update someones variable.
I.E AdminLevel.

Would anyone be able to give an example of it to get me started?

Thanks

- HazardGaming.


Re: Saving a variable using Y_INI - KreeDz - 17.04.2012

Well, it's quite simple. You just do something like this

Код:
new INI:uFile = INI_Open(your path to the player files));
	INI_WriteInt(uFile,"AdminLevel",adminlevel);
	INI_Close(uFile);
You add it to the command..., i think you already know how paths work so i won't go into that.

If you use YCMD, i could explain it to you in greater detail, but that's an example of how you'd update a variable.


Re: Saving a variable using Y_INI - HazardGaming - 17.04.2012

Ha I use Zcmd, but if you can use zcmd, sure!


Re: Saving a variable using Y_INI - HazardGaming - 17.04.2012

Can anyone help please, I need this.


Re: Saving a variable using Y_INI - KreeDz - 17.04.2012

I don't know much about ZCMD, but i guess it's not such a big difference between them two.

This is how the command would look like: [you must have sscanf for it to work].

Код:
CMD:makeadmin(playerid,params[],help)
{
	new aLvl,pID,name[MAX_PLAYER_NAME],pString[64];
	if(uData[playerid][aLevel] != 6) return SendMsg(playerid,red,"You are not authorized to use this command !");//Ignore this, you may have a completely different admin system.
	if(help) return SendMsg(playerid,white,"Makes the targeted player an admin.");
	if(sscanf(params,"ud",pID,aLvl)) return SendMsg(playerid,yellow,"Use: /makeadmin <name/id> <admin level>");
	if(aLvl < 0 || aLvl > 7) return SendMsg(playerid,white,"The admin level must be between 0 and 7.");
	if(!IsPlayerConnected(pID)) return SendMsg(playerid,white,"This player is not connected.");
	GetPlayerName(pID,name,sizeof(name));
	format(pString,sizeof(pString),"/Users/%s.ini",name);
        new INI:uFile = INI_Open(pString));
	INI_WriteInt(uFile,"AdminLevel",aLvl);
	INI_Close(uFile);
        return 1;
}
EDIT: Forgot the return -.- .


Re: Saving a variable using Y_INI - HazardGaming - 17.04.2012

Doesn't help, Sorry.


Thanks for the help!

EDIT: I learn by people explaining it, not writing it for me, sorry!


Re: Saving a variable using Y_INI - KreeDz - 17.04.2012

I don't want to be mean or something like that, but most of the information on how to use Y_INI is in the actual Y_INI topic, why would you want someone to explain something to you that is already explained somewhere else?

If you want a complete breakdown of every single thing well, I don't really have time right now so sorry, hope someone else can help you.