fremove, little help please?
#1

Код:
CMD:changeplayer(playerid, params[])
{
		new pName[MAX_PLAYER_NAME], str[50];
		if(sscanf(params, "u", pName))SendClientMessage(playerid, RED, "runn3r: /changeplayer [NAME]");
		GetPlayerName(playerid, pName, sizeof pName);
		format(str, sizeof str, "/accounts/%s.ini", pName);
		fremove(str);
		return 1;
		}
How can i put this like i type /changeplayer %s and it opens the user file and writes something in that %s.ini file that i want?

I want to use FWRITE!
If you have time please help me...
Reply
#2

Nobody? :/
Reply
#3

Help me i need this fast!
Reply
#4

Just an example of how it would look like.

Код:
//Your enum names or whatever you're "storing" the data in temporarily
enum PlayerInformation
{
	pString,
	pInt,
	pFloat
}
new playerInfo[MAX_PLAYERS][PlayerInformation];


CMD:change(playerid, params[])
{
	new str[128], id, Float:double;
	new playerToChangeSomethingOn;
	if(sscanf(params, "us[128]if, playerToChangeSomethingOn, str, integer, double)) return SCM(playerid, color, "use this instead: /change [player u want to change something on] [string] [integer] [float]");
	
	//Two ways you can do it:
	//Directly change in the file:
	new userPath[128], annoyingString[128];
	GetPlayerName(playerToChangeSoemthingOn, annoyingString, sizeof(annoyingString));
	format(userPath, sizeof(userPath), "/Users/%s.ini", annoyingString);
	new INI:fileChange = INI_Open(userPath);
	INI_WriteInt(fileChange, "YourIntTitle", integer);
	INI_WriteFloat(fileChange, "YourFloatTitle", double);
	INI_WriteString(fileChange, "YourStringTitle", str);
	INI_Close(fileChange);
	
	//The other way is to store the data in enums, variables or whatever you're using to temporarily store hopefully you have a way to load them as well...
	playerInfo[playerToChangeSomethingOn][pString] = str;
	playerInfo[playerToChangeSomethingOn][pInt] = integer;
	playerInfo[playerToChangeSomethingOn][pFloat] = double;
	
	return 1;
}

//The second way won't be "saving" into the file directly but when the player possibly disconnects or wherever you have your "INI_Parse",
//which I really hope you have one as you're using different-user based system
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)