29.09.2011, 15:50
Hey, it won't save my skin :///
This is urgent, please help... rep ++ for whoever does
SCRIPT:
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;
}