User connect bug with .iniґs
#3

Here some parts of the source code of my script:

Код:
public OnPlayerLogin(playerid,password[])
{

SetTimer("firsttimer",20000,0);
new tmp2[256];
new string2[64];
new playername2[MAX_PLAYER_NAME];
//new Labeltext[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername2, sizeof(playername2));
format(string2, sizeof(string2), "/Accounts/%s.ini", playername2);
new File: UserFile = fopen(string2, io_read);
if ( UserFile )
{
new PassData[128];
new keytmp[256], valtmp[256];
//new names[128];
fread( UserFile , PassData , sizeof( PassData ) );
keytmp = ini_GetKey( PassData );
if( strcmp( keytmp , "Key" , true ) == 0 )
{
valtmp = ini_GetValue( PassData );
strmid(PlayerInfo[playerid][pKey], valtmp, 0, strlen(valtmp)-1, 255);
}
if(strcmp(PlayerInfo[playerid][pKey],password, true ) == 0 )
{
new key[ 256 ] , val[ 256 ];
new Data[ 256 ];
while ( fread( UserFile , Data , sizeof( Data ) ) )
{
key = ini_GetKey( Data );
if( strcmp( key , "Level" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pLevel] = strval( val ); }
if( strcmp( key , "AdminLevel" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pAdmin] = strval( val ); }
if( strcmp( key , "DonateRank" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pDonateRank] = strval( val ); }
if( strcmp( key , "UpgradePoints" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][gPupgrade] = strval( val ); }
if( strcmp( key , "ConnectedTime" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pConnectTime] = strval( val ); }
if( strcmp( key , "Registered" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pReg] = strval( val ); }
if( strcmp( key , "Sex" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pSex] = strval( val ); }
}//end while
fclose(UserFile);
}
else
{
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYL E_INPUT,"Login","Das Passwort ist nicht korrekt! Bitte gib nun dein richtiges Passwort ein:","Login","Abbrechen");
//fclose(UserFile);
gPlayerLogTries[playerid] += 1;
if(gPlayerLogTries[playerid] == 1)
{
SendClientMessage(playerid,COLOR_GREEN,"Falsches Passwort! [1/4]");
}
if(gPlayerLogTries[playerid] == 2)
{
SendClientMessage(playerid,COLOR_YELLOW,"Falsches Passwort! [2/4]");
}
if(gPlayerLogTries[playerid] == 3)
{
SendClientMessage(playerid,TEAM_ORANGE_COLOR,"Fals ches Passwort! [3/4]");
}
if(gPlayerLogTries[playerid] == 4)
{
SendClientMessage(playerid,COLOR_RED,"Falsches Passwort! [4/4]");
Ban(playerid);
}
return 1;
}

SetPlayerWantedLevel(playerid,WantedLevel[playerid]/10);

PlayerInfo[playerid][pAdjustable] = 0;
ResetPlayerMoney(playerid);
ConsumingMoney[playerid] = 1;
GivePlayerMoney(playerid,PlayerInfo[playerid][pCash]);
CurrentMoney[playerid] = PlayerInfo[playerid][pCash];


format(string2, sizeof(string2), "SERVER: Willkommen %s",playername2);
SendClientMessage(playerid, COLOR_WHITE,string2);
printf("%s has logged in.",playername2);
SetSpawnInfo(playerid, PlayerInfo[playerid][pTeam], PlayerInfo[playerid][pModel], PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z], 1.0, -1, -1, -1, -1, -1, -1);
if(gTeam[playerid] == 0)
{
gTeam[playerid] = 3;
}
else
{
gTeam[playerid] = PlayerInfo[playerid][pTeam];
}
gPlayerLogged[playerid] = 1;
SpawnPlayer(playerid);
format(tmp2, sizeof(tmp2), "~w~Willkommen ~n~~b~ %s", playername2);
DateProp(playerid);
OnPlayerSave(playerid);
SetTimerEx("UnsetFirstSpawn", 5000, false, "i", playerid);
TogglePlayerSpectating(playerid, 0);
GameTextForPlayer(playerid, tmp2, 5000, 1);
//SendClientMessage(playerid, COLOR_YELLOW, motd);
}
return 1;
}
Код:
public OnPlayerRegister(playerid, password[])
{
if(IsPlayerConnected(playerid))
{
new string3[32];
new playername3[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername3, sizeof(playername3));
format(string3, sizeof(string3), "/Accounts/%s.ini", playername3);
new File: hFile = fopen(string3, io_write);
if (hFile)
{
strmid(PlayerInfo[playerid][pKey], password, 0, strlen(password), 255);
new var[32];
format(var, 32, "Key=%s\n", PlayerInfo[playerid][pKey]);fwrite(hFile, var);
PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
format(var, 32, "Level=%d\n",PlayerInfo[playerid][pLevel]);fwrite(hFile, var);
format(var, 32, "AdminLevel=%d\n",PlayerInfo[playerid][pAdmin]);fwrite(hFile, var);
format(var, 32, "DonateRank=%d\n",PlayerInfo[playerid][pDonateRank]);fwrite(hFile, var);
fclose(hFile);
SendClientMessage(playerid, COLOR_WHITE, "Du hast dich erfolgreich registriert.");
SendClientMessage(playerid, COLOR_WHITE, "Du kannst dich jetzt einloggen");
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYL E_INPUT,"Login","Bitte logge dich in deinen Account ein!","Login","Abbrechen");
//PlayerInfo[playerid][pReg] = 0;
}
}
return 1;
}
Код:
if(fexist(string))
{
new joinstr[200];
new sendername[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendername, sizeof(sendername));
gPlayerAccount[playerid] = 1;
format(joinstr, sizeof(joinstr), "|_________________ Willkommen zurьck %s _________________|",sendername);
SendClientMessage(playerid, COLOR_DBLUE, joinstr);
SendClientMessage(playerid, COLOR_WHITE, "Bitte logge dich jetzt in deinen Account ein um spielen zu kцnnen.");
SendClientMessage(playerid, COLOR_WHITE, "INFO: Du hast maximal 4 Versuche dein Passwort richtig einzugeben!");
return 1;
}
else
{
new joinstr[200];
new sendername[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendername, sizeof(sendername));
gPlayerAccount[playerid] = 0;
format(joinstr, sizeof(joinstr), "|______________ Willkommen auf dem Server %s ______________|",sendername);
SendClientMessage(playerid, COLOR_DBLUE, joinstr);
SendClientMessage(playerid, COLOR_WHITE, "Dein Name wurde nicht gefunden, bitte registriere dich.");
return 1;
}
}
Reply


Messages In This Thread
User connect bug with .iniґs - by xxandi - 28.08.2011, 13:51
Re: User connect bug with .iniґs - by Emmet_ - 28.08.2011, 14:50
AW: User connect bug with .iniґs - by xxandi - 28.08.2011, 15:43
AW: User connect bug with .iniґs - by xxandi - 28.08.2011, 17:00

Forum Jump:


Users browsing this thread: 1 Guest(s)