Won't save skin ?? HELP?? -
BigAl - 29.09.2011
Hey, it won't save my skin :///
This is urgent, please help... rep ++ for whoever does
SCRIPT:
pawn Код:
public OnPlayerConnect(playerid)
{
pLogged[playerid] = 0;
#if defined AUTOLOGIN
new tmpIP[16];
GetPlayerIp(playerid, tmpIP, sizeof(tmpIP));
#endif
if(fexist(PlayerPath(playerid)))
{
INI_ParseFile(PlayerPath(playerid), "UserDataLoad_%s", .bExtra = true, .extra = playerid);
#if defined AUTOLOGIN
if(strcmp(tmpIP, pIP[playerid], true) == 0)
{
pLogged[playerid] = 1;
SetPlayerScore(playerid, pInfo[playerid][Score]);
GivePlayerMoney(playerid, pInfo[playerid][Cash]);
SetPlayerSkin(playerid, pInfo[playerid][Skin]);
SendClientMessage(playerid, COLOR_GREEN, "You have been automatically logged in. [IP Match]");
return 1;
}
#endif
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", "Please enter your password below to login", "Login", "Quit");
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Register", "Player enter your desired password below to register!", "Register", "Quit");
}
SetSpawnInfo(playerid, pInfo[playerid][Skin], 1, -1514.9274,2525.9253,55.7668, 12.5629, 0, 0, 0, 0, 0, 0);
SetTimer("score", 600000, true);
return 1;
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
if(pLogged[playerid] == 1) {
new INI:iFile = INI_Open(PlayerPath(playerid));
INI_SetTag(iFile,"data");
INI_WriteInt(iFile,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(iFile,"Score",GetPlayerScore(playerid));
INI_WriteInt(iFile, "Team",GetPlayerTeam(playerid));
INI_WriteInt(iFile, "Skin", GetPlayerSkin(playerid)); // LET ME TRY o.o sure :)that will work, alright then :) how wouldI save the skin...?
INI_Close(iFile);
}
pLogged[playerid] = 0;
return 1;
}
pawn Код:
case DIALOG_REGISTER:
{
GetPlayerIp(playerid,pIP[playerid],16);
if(!response) Kick(playerid);
if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register","Please enter a password.","Register","Leave");
new INI:iFile = INI_Open(PlayerPath(playerid)); //Making the INI file and writing settings
INI_SetTag(iFile,"data");
INI_WriteInt(iFile,"Pass",udb_hash(inputtext));
#if defined AUTOLOGIN
INI_WriteString(iFile,"IP",pIP[playerid]);
#endif
INI_WriteInt(iFile,"Cash",REGISTERED_MONEY);
INI_WriteInt(iFile,"Score",0);
INI_WriteInt(iFile,"Team",-1);
INI_WriteInt(iFile,"Skin",-1); //is that it?? O.o just an invalid one and now it will save the skin?
INI_Close(iFile);
pLogged[playerid] = 1;
new iStr[128];
format(iStr,sizeof(iStr),"You've successfully registered with the password \"%s\".",inputtext);
SendClientMessage(playerid,COLOR_YELLOW,iStr);
return 1;
}
case DIALOG_LOGIN:
{
if(!response) Kick(playerid);
new iStr[128],gTries;
if(gTries == 0) gTries = 1;
if(gTries == 3) { // 3 tries = kick
new pName[30];
GetPlayerName(playerid,pName,sizeof(pName));
format(iStr,sizeof(iStr),"%s has been kicked for exceeding login tries.",pName);
SendClientMessageToAll(COLOR_RED,iStr);
return Kick(playerid);
}
if(!strlen(inputtext)) {
format(iStr,sizeof(iStr),"Please enter your password. Tries: %i/3",gTries);
return ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login",iStr,"Login","Leave");
}
if(udb_hash(inputtext) == pInfo[playerid][Pass]) {
pLogged[playerid] = 1;
SendClientMessage(playerid,COLOR_YELLOW,"You've successfully logged in.");
SetPlayerScore(playerid,pInfo[playerid][Score]); //Loading player score
GivePlayerMoney(playerid,pInfo[playerid][Cash]); //Loading player money
SetPlayerSkin(playerid, pInfo[playerid][Skin]); //
SetPlayerTeam(playerid, pInfo[playerid][Team]); // will that set the team upon login? yep
} else {
format(iStr,sizeof(iStr),"Incorrect password. Tries: %i/3",gTries);
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register",iStr,"Login","Leave");
gTries++;
return 1;
}
}
pawn Код:
forward UserDataLoad_data(playerid,name[],value[]);
public UserDataLoad_data(playerid,name[],value[]) {
INI_Int("Pass",pInfo[playerid][Pass]);
INI_String("IP",pIP[playerid],16);
INI_Int("Admin",pInfo[playerid][Admin]);
INI_Int("Cash",pInfo[playerid][Cash]);
INI_Int("Score",pInfo[playerid][Score]);
INI_Int("Banned",pInfo[playerid][Banned]);
INI_Int("Skin",pInfo[playerid][Skin]);
INI_Int("Team",pInfo[playerid][Team]);
return 1;
}
Re: Won't save skin ?? HELP?? -
Kingunit - 29.09.2011
Use this as /setskin:
pawn Код:
//-----[Setskin]-----
CMD:setskin(playerid,params[])
{
if(PlayerInfo[playerid][Admin] < 4) return SendClientMessage(playerid,COLOR_RED,".:: You are not authorized to use this command ::.");
new targetid,skin;
if(sscanf(params,"ud",targetid,skin)) SendClientMessage(playerid,WHITE,""#COL_DGREY"[CMD] / "#COL_SGREY"[PlayerID/PartOfName] [Skin]");
else if(targetid == INVALID_PLAYER_ID) SendClientMessage(playerid,COLOR_ORANGE,""#COL_ORANGE"[ERROR] "#COL_LRED"Player not connected!");
else if(skin > 299 || skin < 1) return SendClientMessage(playerid, COLOR_RED, ".:: Error: Invalid skin ID! ::.");
else
{
SetPlayerSkin(targetid,skin);
pInfo[targetid][Skin] = skin;
}
return 1;
}
I had that bug too. Use your own colors etc. Edit it a little bit.
Re: Won't save skin ?? HELP?? -
BigAl - 29.09.2011
I don't want it as a command, because I am making roleplay script... I want it to work upon connect... or do I have to do it that way?
Re: Won't save skin ?? HELP?? -
Kingunit - 29.09.2011
Try using that command. Set your skin, and relog. 99% sure it's working then.
// I will post my thing in a second.
Top:
OnPlayerDisconnect:
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
SaveUserDate(playerid);
if(!GMXing) SaveUserDate(playerid);
return 1;
}
OnPlayerSpawn
pawn Код:
public OnPlayerSpawn(playerid)
{
SetPlayerSkin(playerid, PlayerInfo[playerid][Skin]);
return 1;
}
Register part:
pawn Код:
INI_WriteInt(File,"Skin",7);
LoadUser
pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Skin",PlayerInfo[playerid][Skin]);
return 1;
}
SaveUserDate
pawn Код:
forward SaveUserDate(playerid);
public SaveUserDate(playerid)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Skin",GetPlayerSkin(playerid));
INI_Close(File);
return true;
}
SetSkin
pawn Код:
CMD:setskin(playerid,params[])
{
if(PlayerInfo[playerid][Adminlevel] < 4) return SendClientMessage(playerid,COLOR_RED,".:: You are not authorized to use this command ::.");
new targetid,skin;
if(sscanf(params,"ud",targetid,skin)) SendClientMessage(playerid,WHITE,""#COL_DGREY"[CMD] / "#COL_SGREY"[PlayerID/PartOfName] [Skin]");
else if(targetid == INVALID_PLAYER_ID) SendClientMessage(playerid,COLOR_ORANGE,""#COL_ORANGE"[ERROR] "#COL_LRED"Player not connected!");
else if(skin > 299 || skin < 1) return SendClientMessage(playerid, COLOR_RED, ".:: Error: Invalid skin ID! ::.");
else
{
SetPlayerSkin(targetid,skin);
SaveUserDate(targetid);
PlayerInfo[targetid][Skin] = skin;
}
return 1;
}
I was using that. Worked perfect, Also saving at GMX since I had alot of strugs with that.
Re: Won't save skin ?? HELP?? -
Kingunit - 29.09.2011
Updated, do not forget to edit it to make it compatible for your gamemode.
Re: Won't save skin ?? HELP?? -
iPLEOMAX - 29.09.2011
You're supposed to put: "SetPlayerSkin(playerid, pInfo[playerid][Skin]);" in OnPlayerSpawn.
OnPlayerConnect won't do anything for setting skin..