pawn Code:
298.public OnPlayerConnect(playerid)
299.{
300. new string[256];
301. new playrname[MAX_PLAYER_NAME];
302. new planame[MAX_PLAYER_NAME];
303. new connect[128], string2[256];
304. new pName[MAX_PLAYER_NAME];
305. new jstring[48];
306.
307. GetPlayerName(playerid, planame, sizeof(planame));
308. GetPlayerName(playerid, playrname, sizeof(playrname));
309. GetPlayerName(playerid, pName, sizeof(pName));
310. format(connect, sizeof(string), "Admin/Users/%s.djson", playrname);
311. format(string2, sizeof(string2), "Admin/Users/%s.djson", playrname);
312.
313. PlayerInfo[playerid][pLevel] = 0;
314. PlayerInfo[playerid][pKills] = 0;
315. PlayerInfo[playerid][pDeaths] = 0;
316. PlayerInfo[playerid][pCash] = 0;
317.
318. gPlayerLogged[playerid] = 0;
319.
320. format(jstring, sizeof(jstring), "***%s has joined the server.", pName);
321. SendClientMessageToAll(0xAAAAAAAA, jstring);
322.
323. if(fexist(connect))
324. {
325. new tmp[50],tmp2[256];
326. GetPlayerIp(playerid,tmp,50);
327. tmp2 = dini_Get(connect,"IP");
328. if(!strcmp(tmp,tmp2,true))
329. {
330. format(string, sizeof(string), "[SUCESS]%s, you have been automatically logged in.", playrname);
331. SendClientMessage(playerid, COLOR_GREEN, string);
332. gPlayerLogged[playerid] = 1;
333. new playername2[MAX_PLAYER_NAME];
334. GetPlayerName(playerid, playername2, sizeof(playername2));
335. format(string2, sizeof(string2), "Admin/Users/%s.ini", playername2);
336. new File: UserFile = fopen(string2, io_read);
337. if ( UserFile )
338. {
339. new PassData[256];
340. new keytmp[256], valtmp[256];
341. fread( UserFile , PassData , sizeof( PassData ) );
342. keytmp = ini_GetKey( PassData );
343. if( strcmp( keytmp , "Password" , true ) == 0 )
344. {
345. valtmp = ini_GetValue( PassData );
346. strmid(PlayerInfo[playerid][pPassword], valtmp, 0, strlen(valtmp)-1, 255);
347. new key[ 256 ] , val[ 256 ];
348. new Data[ 256 ];
349. while ( fread( UserFile , Data , sizeof( Data ) ) )
350. {
351. key = ini_GetKey( Data );
352. if( strcmp( key , "Level" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pLevel] = strval( val ); }
353. if( strcmp( key , "Kills" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pKills] = strval( val ); }
354. if( strcmp( key , "Deaths" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pDeaths] = strval( val ); }
355. if( strcmp( key , "Money" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pCash] = strval( val ); }
356. }
357. fclose(UserFile);
358. gPlayerLogged[playerid] = 1;
359. }
360. }
361. }
362. else
363. {
364. gPlayerAccount[playerid] = 1;
365. format(string, sizeof(string), "[SERVER]Welcome back %s! Please login.", playrname);
366. SendClientMessage(playerid, COLOR_YELLOW, string);
367. gPlayerLogged[playerid] = 0;
368. return 1;
369. }
370. }
371. else
372. {
373. gPlayerAccount[playerid] = 0;
374. format(string, sizeof(string),"[SERVER]Account %s isn\'t registered. Register using /register password", playrname);
375. SendClientMessage(playerid, COLOR_YELLOW,string);
376. gPlayerLogged[playerid] = 0;
377. return 1;
378. }
379. return 1;
380.}