04.02.2010, 10:14
here:
I have everything defined, no errors but whats the prob?It dont save a file or nothin, it asks for u to register, i register next time i log it asks to register again :S
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(dialogid == 1 && response) { new tmppass[64]; strmid(tmppass, inputtext, 0, strlen(inputtext), 255); //Encrypt(tmppass); OnPlayerLogin(playerid,tmppass); } if(dialogid == 2 && response) { if(strlen(inputtext)) { new sendername[MAX_PLAYER_NAME]; new string2[56]; GetPlayerName(playerid, sendername, sizeof(sendername)); format(string2, sizeof(string2), "%s.ini", sendername); new File: hFile = fopen(string2, io_read); if (hFile) { SendClientMessage(playerid, COLOR_YELLOW, "That Username is already taken, please choose a different one."); fclose(hFile); Kick(playerid); return 1; } new tmppass[64]; strmid(tmppass, inputtext, 0, strlen(inputtext), 255); //Encrypt(tmppass); // OnPlayerRegister(playerid,tmppass); } } return 1; } public OnPlayerClickPlayer(playerid, clickedplayerid, source) { return 1; } //====================== Admin publics/Player publics =========================// /*Encrypt(string[]) { for(new x=0; x < strlen(string); x++) { string[x] += (3^x) * (x % 15); if(string[x] > (0xff)) { string[x] -= 256; } } } */ //=============================== Stocks ============================// stock ini_GetKey( line[] ) { new keyRes[256]; keyRes[0] = 0; if ( strfind( line , "=" , true ) == -1 ) return keyRes; strmid( keyRes , line , 0 , strfind( line , "=" , true ) , sizeof( keyRes) ); return keyRes; } stock ini_GetValue( line[] ) { new valRes[256]; valRes[0]=0; if ( strfind( line , "=" , true ) == -1 ) return valRes; strmid( valRes , line , strfind( line , "=" , true )+1 , strlen( line ) , sizeof( valRes ) ); return valRes; } public split(const strsrc[], strdest[][], delimiter) { new i, li; new aNum; new len; while(i <= strlen(strsrc)){ if(strsrc[i]==delimiter || i==strlen(strsrc)){ len = strmid(strdest[aNum], strsrc, li, i, 128); strdest[aNum][len] = 0; li = i+1; aNum++; } i++; } return 1; } public OnPlayerLogin(playerid,password[]) { // new tmp2[256]; new string2[64]; new playername2[MAX_PLAYER_NAME]; new playernamesplit[3][MAX_PLAYER_NAME]; GetPlayerName(playerid, playername2, sizeof(playername2)); split(playername2, playernamesplit, '_'); format(string2, sizeof(string2), "users/%s.ini", playername2); new File: UserFile = fopen(string2, io_read); if ( UserFile ) { new PassData[256]; new keytmp[256], valtmp[256]; fread( UserFile , PassData , sizeof( PassData ) ); keytmp = ini_GetKey( PassData ); if( strcmp( keytmp , "Key" , true ) == 0 ) { valtmp = ini_GetValue( PassData ); strmid(PlayerInfo[playerid][pPass], valtmp, 0, strlen(valtmp)-1, 255); } if(strcmp(PlayerInfo[playerid][pPass],password, true ) == 0 ) { new key[ 256 ] , val[ 256 ]; new Data[ 256 ]; while ( fread( UserFile , Data , sizeof( Data ) ) ) { key = ini_GetKey( Data ); if( strcmp( key , "Activity" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pActivity] = strval( val ); } if( strcmp( key , "AdminLevel=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pAdmin] = strval( val ); } if( strcmp( key , "Money=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pMoney] = strval( val ); } if( strcmp( key , "Registered=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pRegistered] = strval( val ); } if( strcmp( key , "GangID=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGang] = strval( val ); } if( strcmp( key , "GMember" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGangMember] = strval( val ); } if( strcmp( key , "GLeader" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGangLeader] = strval( val ); } if( strcmp( key , "Muted" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pMuted] = strval( val ); } if( strcmp( key , "FactionID" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pFaction] = strval( val ); } if( strcmp( key , "FMember=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pFactionMember] = strval( val ); } if( strcmp( key , "FLeader=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pFactionLeader] = strval( val ); } if( strcmp( key , "GunSkills=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGunSkills] = strval( val ); } if( strcmp( key , "Gun=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGun] = strval( val ); } if( strcmp( key , "Gun2=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGun2] = strval( val ); } if( strcmp( key , "Gun3=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGun3] = strval( val ); } if( strcmp( key , "Gun4=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGun4] = strval( val ); } if( strcmp( key , "GunAmmo=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGunAmmo] = strval( val ); } if( strcmp( key , "GunAmmo2=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGunAmmo2] = strval( val ); } if( strcmp( key , "GunAmmo3=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGunAmmo3] = strval( val ); } if( strcmp( key , "GunAmmo4=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pGunAmmo4] = strval( val ); } if( strcmp( key , "CarLicense=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pCarLicense] = strval( val ); } if( strcmp( key , "FlyingLicense=" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pFlyingLicense] = strval( val ); } } fclose(UserFile);//close the file after everything has been read in the while } else { new loginstring[128]; new loginname[64]; GetPlayerName(playerid,loginname,sizeof(loginname)); format(loginstring,sizeof(loginstring),"WRONG PASSWORD\nPlease enter the correct password:",loginname); ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"Login",loginstring,"Login","Exit"); fclose(UserFile); gPlayerLogTries[playerid] += 1; if(gPlayerLogTries[playerid] == 3) { Ban(playerid); } return 1; } new string3[56]; SendClientMessage(playerid,COLOR_DBLUE,"|--- Welcome to Gen RP ---|"); format(string3, sizeof(string3), "You have %d Activity Points",PlayerInfo[playerid][pActivity]); SendClientMessage(playerid,COLOR_LIGHTBLUE, string3); if(PlayerInfo[playerid][pGang] >= 0) { new string1[50]; new string02[67]; format(string1, sizeof(string1)," Gang ID: %d",PlayerInfo[playerid][pGang]); SendClientMessage(playerid,COLOR_LIGHTBLUE,string1); format(string02, sizeof(string02),"Money: %d",PlayerInfo[playerid][pMoney]); SendClientMessage(playerid,COLOR_LIGHTBLUE,string02); } return 1; } return 1; }