[FIXED] save skin after server restart -
backnot - 20.08.2012
Fixed. See my last msg to know the solution . Thanks all.
I did it by other way .
So far so good.
When I relog / log out and log in again / my skin is SAVED .
When I restart my server / /gmx / my skin is CJ again :X
My OLD codes:
OnPlayerConnect
Код:
{
new file[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), "\\users\\%s.ini", pname);
if(dini_Exists(file))
{
SetTimerEx("SpawnSave", 100, false, "d", playerid);
}
OnPlayerSpawn
Код:
{
new file[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), "\\users\\%s.ini", pname);
if(dini_Exists(file))
{
SetTimerEx("SpawnSave", 100, false, "d", playerid);
}
OnPlayerDisconnect
Код:
{
new file[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), "\\users\\%s.ini", pname);//leader the name of your folder in scriptfiles
if(!dini_Exists(file))
dini_Create(file);
dini_IntSet(file, "skin", GetPlayerSkin(playerid));
}
End of the script
Код:
forward SpawnSave(playerid);
public SpawnSave(playerid)
{
new file[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), "\\users\\%s.ini", pname);
SetPlayerSkin(playerid, dini_Int(file, "skin"));
return 1;
}
------------------------------------------------------------------
NEW*
Model = skin
pModel = skin
So , my Model is my Skin . I bough skin id 181 from the clothes shop and restarts the server . I saw my .ini file . Model = 181 . My model was SAVED . When I log in i was with the CJ again . I tried 3 types of codes . My model is saved but it doesn't want to give it to me like SetPlayerSkin , etc.
CMD:buyclothes
Код:
PlayerInfo[playerid][pModel] = skin;
SetPlayerSkin(playerid, skin);
My NEW Codes are:
OnPlayerConnect
Код:
("PlayerInfo[playerid][pModel]", GetPlayerSkin(playerid));
PlayerInfo[playerid][pModel] = skin;
SetPlayerSkin(playerid, skin);
SetPlayerSkin(playerid, PlayerInfo[playerid][pModel]);
LoadChar();
Код:
("PlayerInfo[playerid][pModel]", GetPlayerSkin(playerid));
PlayerInfo[playerid][pModel] = skin;
SetPlayerSkin(playerid, skin);
SetPlayerSkin(playerid, PlayerInfo[playerid][pModel]);
Request class
Код:
("PlayerInfo[playerid][pModel]", GetPlayerSkin(playerid));
PlayerInfo[playerid][pModel] = skin;
SetPlayerSkin(playerid, skin);
SetPlayerSkin(playerid, PlayerInfo[playerid][pModel]);
SpawnPlayer(playerid);
Spawn Char();
Код:
new skin;
PlayerInfo[playerid][pModel] = skin;
SetPlayerSkin(playerid, skin);
If I see CJ skin again I will smash my PC , I swear
Please help (:
Re: [Dini] save skin after logout -
avivelkayam - 20.08.2012
if you have file to player you can set a Key "Skin" and to set him -1 (this is when he is not saved the skin)
when he save the skin command or somethink
you can set the key "Skin" to the skin of the player
and in OnPlayerSpawn you check if the Key "Skin" != -1 than you set the skin of what the value in the key "Skin"
Re: [Dini] save skin after logout -
detter - 20.08.2012
I assume you have some exp. with dini...
on top of your script
Код:
new setSkin = 0; // to check if player skin is need to be changed
you need to put in OnPlayerDisconnect
Код:
new pname[MAX_PLAYER_NAME], path[128];
GetPlayerName(playerid, pname, sizeof(pname));
format(path, sizeof(path), "/Players/%s.ini", pname); // folder where you keep your player files..
dini_IntSet(path ,"skin" ,pInfo[playerid][skin]); // just change pInfo or skin if your player enum is diffrent...
then when your player is connected you need to load skin from file and set him that skin
now , if you use dialgos for login you need to put this under dialogResponse ,else you can put this under
OnPlayerConnect..
Код:
new pname[MAX_PLAYER_NAME], path[128];
GetPlayerName(playerid, pname, sizeof(pname));
format(path, sizeof(path), "/Players/%s.ini", pname); // folder where you keep your player files..
pInfo[playerid][skin] = dini_Int(path ,"skin"); // this loads value of "skin" from player.ini file ,change this if needed...
setSkin[playerid] = 1;
and last..
OnPlayerUpdate
Код:
if(setSkin[playerid] == 1)
{
SetPlayerSkin(playerid ,pInfo[playerid][skin]);
setSkin[playerid] = 0
}
Re: [Dini] save skin after logout -
backnot - 21.08.2012
It doesn't work.
It's giving me errors.
When I fix them , My skin is not saved . It is setting me CJ or the truth ( id 0 and id 1 )
Re: [Dini] save skin after logout -
detter - 21.08.2012
It should work!
is your folder, where you keep your players, called "Player" ?
Re: [Dini] save skin after logout -
backnot - 21.08.2012
No it is /users .
I did it by other way .
So far so good.
When I relog / log out and log in again / my skin is SAVED .
When I restart my server / /gmx / my skin is CJ again :X
My codes:
OnPlayerConnect
Код:
{
new file[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), "\\users\\%s.ini", pname);
if(dini_Exists(file))
{
SetTimerEx("SpawnSave", 100, false, "d", playerid);
}
OnPlayerSpawn
Код:
{
new file[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), "\\users\\%s.ini", pname);
if(dini_Exists(file))
{
SetTimerEx("SpawnSave", 100, false, "d", playerid);
}
OnPlayerDisconnect
Код:
{
new file[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), "\\users\\%s.ini", pname);//leader the name of your folder in scriptfiles
if(!dini_Exists(file))
dini_Create(file);
dini_IntSet(file, "skin", GetPlayerSkin(playerid));
}
End of the script
Код:
forward SpawnSave(playerid);
public SpawnSave(playerid)
{
new file[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), "\\users\\%s.ini", pname);
SetPlayerSkin(playerid, dini_Int(file, "skin"));
return 1;
}
Re: [Dini] save skin after logout -
backnot - 21.08.2012
@detter
Your code's errors:
Код:
D:\DOCUME~1\Alex19\MYDOCU~1\ZGAMIN~1.3E\GAMEMO~1\ZRP.pwn(2769) : error 017: undefined symbol "skin"
D:\DOCUME~1\Alex19\MYDOCU~1\ZGAMIN~1.3E\GAMEMO~1\ZRP.pwn(17308) : error 028: invalid subscript (not an array or too many subscripts): "setSkin"
D:\DOCUME~1\Alex19\MYDOCU~1\ZGAMIN~1.3E\GAMEMO~1\ZRP.pwn(17308) : warning 215: expression has no effect
D:\DOCUME~1\Alex19\MYDOCU~1\ZGAMIN~1.3E\GAMEMO~1\ZRP.pwn(17308) : error 001: expected token: ";", but found "]"
D:\DOCUME~1\Alex19\MYDOCU~1\ZGAMIN~1.3E\GAMEMO~1\ZRP.pwn(17308) : error 029: invalid expression, assumed zero
D:\DOCUME~1\Alex19\MYDOCU~1\ZGAMIN~1.3E\GAMEMO~1\ZRP.pwn(17308) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
5 Errors.
2769
Код:
dini_IntSet(path ,"skin" ,PlayerInfo[playerid][skin]); // just change pInfo or skin if your player enum is diffrent...
17308
Код:
{
//skins
17308: if(setSkin[playerid] == 1)
{
SetPlayerSkin(playerid ,PlayerInfo[playerid][skin]);
setSkin[playerid] = 0
}
}
Re: [Dini] save skin after logout -
detter - 21.08.2012
you need to add in your player enum variabla called skin
next add ; ,i somehow missed on line 17311...
Re: [Dini] save skin after logout -
grand.Theft.Otto - 21.08.2012
This is the easiest and simplest way I did it with dini, so maybe try removing all the stuff you did and do it this way:
pawn Код:
// put this in your register command ( isnt required but you can use it )
dUserSetINT(GetPlayerName(playerid)).("savedskin",0);
// put this in onplayerspawn , if logged in , it will get their skin and save it into their userfile
if(PlayerInfo[playerid][LoggedIn] == 1)
{
dUserSetINT(GetPlayerName(playerid)).("savedskin", GetPlayerSkin(playerid));
}
// put this in onplayerrequestclass , it will set their saved skin in class selection and will be the only one available to choose
if(dUserINT(GetPlayerName(playerid)).("savedskin") >= 1)
{
SetPlayerSkin(playerid,dUserINT(GetPlayerName(playerid)).("savedskin"));
}
This is how I did it and works perfectly.
Change " PlayerInfo[playerid][LoggedIn] " to your log in variable
Re: [Dini] save skin after logout -
backnot - 22.08.2012
The topic is updated
Does anyone can help me ?
Re: [Dini] save skin after logout -
Unte99 - 22.08.2012
What the second slash supposed to mean ? By the way, your new script isn't any better.
OnPlayerConnect
Code:
LoadChar();
Code:
pawn Код:
PlayerInfo[playerid][pModel] = dini_Int(file, "skin");
OnPlayerSpawn
Code:
SpawnChar();
Code:
pawn Код:
SetPlayerSkin(playerid, PlayerInfo[playerid][pModel]);
Re: [Dini] save skin after logout -
TaLhA XIV - 22.08.2012
I don't know about dini but why don't you use y_ini?It is my personal opinion that you use y_ini.
Re: [Dini] save skin after logout -
Hyperfire - 22.08.2012
Do you still need help backnot? I have recently done stats saving using dini(i saw that you are using dini in your code) I have an easy way of setting almost any stat like player skin, health, armour etc. I can send you an example of my code if you still need help.
Re: [Dini] save skin after logout -
backnot - 23.08.2012
@unte - I have 2 warnings . The difference is that now I am with the Truth ( id 1 ) not CJ ( id 0 ) . After relog/server restart I'm with the old man.
Код:
D:\DOCUME~1\Alex19\MYDOCU~1\ZGAMIN~1.3E\GAMEMO~1\ZRP.pwn(2564) : warning 202: number of arguments does not match definition
D:\DOCUME~1\Alex19\MYDOCU~1\ZGAMIN~1.3E\GAMEMO~1\ZRP.pwn(2912) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
2 Warnings.
2564:
OnPlayerConnect
Код:
foreach(Player, i)
{
if(JoinMessages[i])
{
PlayAudioStreamForPlayer(i, string);
}
LoadChar();
}
OnPlayerSpawn
Код:
if(PlayerInfo[playerid][pLoggedIn] && PlayerInfo[playerid][pSpawn])
{
FalseBan[playerid] = 0;
SetTimerEx("FalseBanFix", 6000, false, "i", playerid);
SpawnChar();
@Hyper - yes please.
Re: [Dini] save skin after logout -
backnot - 23.08.2012
I fixed it . After 3 days trying I fixed it
With your help of course . I will give you / all / reps.
My final codes are:
OnPlayerSpawn
And at the End of OnPlayerSpawn
Код:
SetPlayerSkin(playerid, PlayerInfo[playerid][pModel]);
}
return 1;
}
OnPlayerConnect / somewhere at the middle /
Код:
ClearChar(playerid);
LoadChar();
OnGameModeInit
LoadChar();
Код:
PlayerInfo[playerid][pModel] = dini_Int(file, "Model");
SetPlayerSkin(playerid, PlayerInfo[playerid][pModel]);
You can lock the topic !