SA-MP Forums Archive
How do I create a pname - 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: How do I create a pname (/showthread.php?tid=440720)



How do I create a pname - lramos15 - 31.05.2013

I was wondering how I can create a pname variable for my save system


Respuesta: How do I create a pname - JustBored - 31.05.2013

pawn Код:
new pName[24]; //Same as MAX_PLAYER_NAME
GetPlayerName(playerid, pName, 24);



Re: How do I create a pname - lramos15 - 31.05.2013

How would I save it on log out and at it to my enum here is my enum
Код HTML:
enum pInfo
{
    pPass,
    pCash,
    pAdmin,
    pKills,
    pDeaths
}
new PlayerInfo[MAX_PLAYERS][pInfo];
And here is the on player disconnect
Код HTML:
public OnPlayerDisconnect(playerid, reason)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Close(File);
    return 1;
}



Re: How do I create a pname - Glad2BeHere - 31.05.2013

pawn Код:
enum pInfo
{
    pName[MAX_PLAYER_NAME],
    pPass,
    pCash,
    pAdmin,
    pKills,
    pDeaths
}
new PlayerInfo[MAX_PLAYERS][pInfo];

public OnPlayerDisconnect(playerid, reason)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteString(File, "Name", GetName(playerid) );
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Close(File);
    return 1;
}

stock GetName(playerid)
{
        new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}



Re: How do I create a pname - lramos15 - 31.05.2013

How would I add it to the load user?
Код HTML:
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    return 1;
}



Re: How do I create a pname - OxyG3N - 31.05.2013

pawn Код:
public LoadUser_data(playerid,name[],value[])
{
    INI_String("Name", PlayerInfo[playerid][pName]);
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    return 1;
}



Re: How do I create a pname - lramos15 - 31.05.2013

INI_String doesn't exist


Re: How do I create a pname - Littlehelper - 31.05.2013

What if the OP does not have y_ini?
Stop copy-pasting codes from your script please...
OT: please can you be more specific? your saving system? do you have any enums defined before?


Re: How do I create a pname - OxyG3N - 31.05.2013

Quote:
Originally Posted by lramos15
Посмотреть сообщение
INI_String doesn't exist
you using y_ini yeah?

INI_String
name[] - Name of the INI textual identifier.
variable - Variable to store to.
length - Length of the destination array.

Saves the passed value as a string if the name matches.