Any alternative to this?
#1

So in the past I've been putting this piece of code under everything that required me to access player's dini file (commands, callbacks, etc.). I would much rather code some feature into the general server so I can just use "PlayerFile" without having this in the area i'm using it:

Код:
	new string[256], pName[24], PlayerFile[50];
	GetPlayerName(playerid, pName, sizeof(pName));
	format(PlayerFile, sizeof(PlayerFile), "AdminScript/Users/%s.ini", pName);
This is under just about everything that requires access to players files and I'm now realizing how much of a pain it is. Since I'm a bit rusty with pawno I'm not sure how I should do it.
Reply
#2

Something like
Код:
stock PlayerFile()
{
	new string[256], pName[24], PlayerFile[50];
	GetPlayerName(playerid, pName, sizeof(pName));
	format(PlayerFile, sizeof(PlayerFile), "AdminScript/Users/%s.ini", pName);
	return PlayerFile;
}
?

Like I said I'm a bit rusty in pawno since I haven't coded in a wile so i'm not really sure how I should do it.
Reply
#3

pawn Код:
stock PlayerFile(iPlayer)
{
    new
        pName[ MAX_PLAYER_NAME ],
        iFile[ 48 ];
    GetPlayerName(iPlayer, pName, MAX_PLAYER_NAME);
    format(iFile, 48, "AdminScript/Users/%s.ini", pName);
    return iFile;
}
// ex
dini_Set(PlayerFile(playerid), "money", 1337);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)