[HELP]Need help with skin saving and loading! -
anito - 28.06.2012
Hello guys. I have login/register system. I created it following this tutorial
link! But i want to add skin saving. For example, while registering i can select skin and when i exit SA-MP i want it to be saved in %/Users/%.ini. And while logging second time i want (i'd like to) disable Class Selection (Automatically load saved skin ID in %.ini - If you know what i mean). Thank you in advance.
Sincerely,
anito
Re: [HELP]Need help with skin saving and loading! -
phillip875 - 28.06.2012
Ok, so your using Y_INI,
Give me a few minutes and I'll have it for you
Re: [HELP]Need help with skin saving and loading! -
anito - 28.06.2012
Sir, please check link I added! [HINT:14th word]
Re: [HELP]Need help with skin saving and loading! -
Cxnnor - 28.06.2012
At the top of your script.
pawn Код:
enum pInfo
{
pSkin,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
forward LoadUser_data(playerid,name[],value[]); // Loads the actual skin.
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Skin",PlayerInfo[playerid][pSkin]);
return 1;
}
stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),PATH,playername);
return string;
}
stock udb_hash(buf[]) {
new length=strlen(buf);
new s1 = 1;
new s2 = 0;
new n;
for (n=0; n<length; n++)
{
s1 = (s1 + buf[n]) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}
Under OnPlayerDisconnect:
pawn Код:
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
INI_Close(File);
return 1;
}
Re: [HELP]Need help with skin saving and loading! -
anito - 28.06.2012
Quote:
Originally Posted by Cxnnor
At the top of your script.
pawn Код:
enum pInfo { pSkin, } new PlayerInfo[MAX_PLAYERS][pInfo];
forward LoadUser_data(playerid,name[],value[]); // Loads the actual skin. public LoadUser_data(playerid,name[],value[]) { INI_Int("Skin",PlayerInfo[playerid][pSkin]); return 1; } stock UserPath(playerid) { new string[128],playername[MAX_PLAYER_NAME]; GetPlayerName(playerid,playername,sizeof(playername)); format(string,sizeof(string),PATH,playername); return string; }
stock udb_hash(buf[]) { new length=strlen(buf); new s1 = 1; new s2 = 0; new n; for (n=0; n<length; n++) { s1 = (s1 + buf[n]) % 65521; s2 = (s2 + s1) % 65521; } return (s2 << 16) + s1; }
Under OnPlayerDisconnect:
pawn Код:
{ new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"data"); INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]); INI_Close(File); return 1; }
|
Sir, i already tried that but not working.
Re: [HELP]Need help with skin saving and loading! -
[MM]RoXoR[FS] - 28.06.2012
pawn Код:
enum PlayerInfo
{
Skin //User's Skin
}
pawn Код:
public loadaccount_user(playerid, name[], value[])
{
INI_Int("Skin",pInfo[playerid][Skin]);//Get Player Skin
return 1;
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
if(fexist(Path(playerid)))
{
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file,"Player's Data");
INI_WriteInt(file,"Skin",pInfo[playerid][Skin]);// To save skin and all other things
INI_Close(file);
return 1;
}
return 1;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == dregister)
{//After successful Register
INI_WriteInt(file,"Skin",0);//Save Skin
return 1;
}
if(dialogid == dlogin)
{//After successful Login
SetPlayerSkin(playerid,pInfo[playerid][Skin]);
}
}
pawn Код:
//Code after you select skin
pInfo[playerid][Skin] = GetPlayerSkin(playerd);
Re: [HELP]Need help with skin saving and loading! -
anito - 28.06.2012
Quote:
Originally Posted by [MM]RoXoR[FS]
pawn Код:
enum PlayerInfo {
Skin //User's Skin }
pawn Код:
public loadaccount_user(playerid, name[], value[]) {
INI_Int("Skin",pInfo[playerid][Skin]);//Get Player Skin return 1; }
pawn Код:
public OnPlayerDisconnect(playerid, reason) { if(fexist(Path(playerid))) { new INI:file = INI_Open(Path(playerid)); INI_SetTag(file,"Player's Data"); INI_WriteInt(file,"Skin",pInfo[playerid][Skin]);// To save skin and all other things INI_Close(file); return 1; } return 1; }
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(dialogid == dregister) {//After successful Register INI_WriteInt(file,"Skin",0);//Save Skin return 1; } if(dialogid == dlogin) {//After successful Login SetPlayerSkin(playerid,pInfo[playerid][Skin]); } }
pawn Код:
//Code after you select skin pInfo[playerid][Skin] = GetPlayerSkin(playerd);
|
I must be crazy, 'cuz i have all of those already. May I send you my .pwn so you can check it!
Re: [HELP]Need help with skin saving and loading! -
phillip875 - 28.06.2012
Don't add everything,
just take the little bits inside of the public and add it your own
Re: [HELP]Need help with skin saving and loading! -
[MM]RoXoR[FS] - 28.06.2012
Quote:
Originally Posted by anito
I must be crazy, 'cuz i have all of those already. May I send you my .pwn so you can check it!
|
Actually , you dont need permission to PM me.
Just do it if you wish.