Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Seifistration System with login menu by Seif
- GUI modifications by erorcun
- */
- /*x---------------------------------Important-------------------------------------x*/
- //**INCLUDES**//
- #include <a_samp>
- //**PRAGMAS**//
- //**MISC**//
- /*x---------------------------------Defining-------------------------------------x*/
- //**COLORS*//
- #define GREEN 0x21DD00FF
- #define RED 0xE60000FF
- #define ADMIN_RED 0xFB0000FF
- #define YELLOW 0xFFFF00FF
- #define ORANGE 0xF97804FF
- #define LIGHTRED 0xFF8080FF
- #define LIGHTBLUE 0x00C2ECFF
- #define PURPLE 0xB360FDFF
- #define PLAYER_COLOR 0xFFFFFFFF
- #define BLUE 0x1229FAFF
- #define LIGHTGREEN 0x38FF06FF
- #define DARKPINK 0xE100E1FF
- #define DARKGREEN 0x008040FF
- #define ANNOUNCEMENT 0x6AF7E1FF
- #define COLOR_SYSTEM 0xEFEFF7AA
- #define GREY 0xCECECEFF
- #define PINK 0xD52DFFFF
- #define DARKGREY 0x626262FF
- #define AQUAGREEN 0x03D687FF
- #define NICESKY 0x99FFFFAA
- #define WHITE 0xFFFFFFFF
- ////**MISC**//
- #define ACCOUNTS_FOLDER "/sAccounts/%s.ini"
- #define FAILED_LOGIN_THRESHOLD 3
- #define SAVING_MONEY_SCORE_FIGHT_DRUNK 1
- #define SAVING_POS 1
- #define SAVING_WEAPON 1
- #define SAVING_ARMOUR 1
- #define SAVING_HEALTH 1
- //**VARIABLES**//
- enum aInfo
- {
- aPassword[128],
- aLogged,
- };
- enum aPos
- {
- aPosX, // To get the player's position from the ini file
- aPosY, // To get the player's position from the ini file
- aPosZ, // To get the player's position from the ini file
- aAngle, // To get the player's position from the ini file
- };
- new AccountInfo[MAX_PLAYERS][aInfo];
- new WeaponInfo[MAX_PLAYERS][12];
- new AmmoInfo[MAX_PLAYERS][12];
- new PositionInfo[MAX_PLAYERS][aPos];
- new register[MAX_PLAYERS];
- new login[MAX_PLAYERS];
- new failedlogin[MAX_PLAYERS] = 0;
- forward OnPlayerUpdate(playerid);
- new SAVE_MONEY_SCORE_FIGHT_DRUNK = SAVING_MONEY_SCORE_FIGHT_DRUNK, SAVE_POS = SAVING_POS, SAVE_WEAPON = SAVING_WEAPON, SAVE_ARMOUR = SAVING_ARMOUR, SAVE_HEALTH = SAVING_HEALTH;
- /*x---------------------------------CallBacks-------------------------------------x*/
- public OnGameModeInit()
- {
- SendRconCommand("reloadfs SeifistrationAdv");
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- AccountInfo[playerid][aLogged] = 0;
- failedlogin[playerid] = 0;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- OnPlayerUpdate(playerid);
- AccountInfo[playerid][aLogged] = 0;
- register[playerid] = 0;
- login[playerid] = 0;
- failedlogin[playerid] = 0;
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- new string[128];
- format(string, sizeof(string), ACCOUNTS_FOLDER, name);
- if (AccountInfo[playerid][aLogged] == 0)
- {
- if (!fexist(string))
- {
- new kayitmsg[256];
- format(kayitmsg,256,"Welcome to the server\n\n%s please open a new account\n\nEnter the new password:",name);
- ShowPlayerDialog(playerid,12345,DIALOG_STYLE_INPUT,"Register",kayitmsg,"Register","Quit");
- register[playerid] = 1;
- login[playerid] = 0;
- }
- else if (fexist(string))
- {
- new girismsg[256];
- format(girismsg,256,"Welcome to the server\n\nUser Name: %s\n\nEnter your password:",name);
- ShowPlayerDialog(playerid,12346,DIALOG_STYLE_INPUT,"Login",girismsg,"Login","Quit");
- register[playerid] = 0;
- login[playerid] = 1;
- }
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- new Float:x, Float:y, Float:z, Float:angle, Float:armour, Float:health;
- if (response == 1)
- {
- if(dialogid == 12345)
- {
- if(strlen(inputtext))
- {
- Encrypt(inputtext);
- new player[MAX_PLAYER_NAME];
- GetPlayerName(playerid, player, 50);
- new string3[32];
- new playername3[MAX_PLAYER_NAME];
- GetPlayerName(playerid, playername3, sizeof(playername3));
- format(string3, sizeof(string3), ACCOUNTS_FOLDER, playername3);
- new ip[20];
- GetPlayerIp(playerid,ip,sizeof(ip));
- new File: hFile = fopen(string3, io_write);
- if (hFile)
- {
- strmid(AccountInfo[playerid][aPassword], inputtext, 0, strlen(inputtext), 255);
- new var[128];
- format(var, 128, "Password=%s\n", AccountInfo[playerid][aPassword]);fwrite(hFile, var);
- format(var, 128, "IP=%s\n",ip);fwrite(hFile, var);
- if(SAVE_MONEY_SCORE_FIGHT_DRUNK == 1)
- {
- format(var, 128, "Money=%d\n",GetPlayerMoney(playerid));fwrite(hFile, var);
- format(var, 128, "Score=%d\n",GetPlayerScore(playerid));fwrite(hFile, var);
- format(var, 128, "DrunkLevel=%d\n",GetPlayerDrunkLevel(playerid));fwrite(hFile, var);
- format(var, 128, "FightStyle=%d\n",GetPlayerFightingStyle(playerid));fwrite(hFile, var);
- }
- if(SAVE_POS == 1)
- {
- GetPlayerPos(playerid, x, y, z);
- GetPlayerFacingAngle(playerid, angle);
- format(var, 128, "PositionX=%f\n",x);fwrite(hFile, var);
- format(var, 128, "PositionY=%f\n",y);fwrite(hFile, var);
- format(var, 128, "PositionZ=%f\n",z);fwrite(hFile, var);
- format(var, 128, "Angle=%f\n",angle);fwrite(hFile, var);
- format(var, 128, "Interior=%d\n",GetPlayerInterior(playerid));fwrite(hFile, var);
- }
- if(SAVE_ARMOUR == 1)
- {
- GetPlayerArmour(playerid, armour);
- format(var, 128, "Armour=%f\n",armour);fwrite(hFile, var);
- }
- if(SAVE_HEALTH == 1)
- {
- GetPlayerHealth(playerid, health);
- format(var, 128, "Health=%f\n",health);fwrite(hFile, var);
- }
- if(SAVE_WEAPON == 1)
- {
- for(new slot = 0; slot != 12; slot++)
- {
- GetPlayerWeaponData(playerid, slot, WeaponInfo[playerid][slot], AmmoInfo[playerid][slot]);
- }
- for(new slot = 0; slot != 12; slot++)
- {
- format(var, 128, "Weapon%d=%d\n", slot, WeaponInfo[playerid][slot]);fwrite(hFile, var);
- format(var, 128, "Weapon%dAmmo=%d\n", slot, AmmoInfo[playerid][slot]);fwrite(hFile, var);
- }
- format(var, 128, "ArmedWeapon=%d\n",GetPlayerWeapon(playerid));fwrite(hFile, var);
- }
- fclose(hFile);
- printf("%s is signed up.",playername3);
- SendClientMessage(playerid, GREEN, "|- Have you registered. You can login now. -|");
- new girismsg[256];
- format(girismsg,256,"Welcome to the server\n\nUser Name: %s\n\nEnter your password:",playername3);
- ShowPlayerDialog(playerid,12346,DIALOG_STYLE_INPUT,"Login",girismsg,"Login","Quit");
- login[playerid] = 1;
- register[playerid] = 0;
- }
- }
- else if(!strlen(inputtext))
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- new kayitmsg[256];
- format(kayitmsg,256,"Welcome to the server\n\n%s please open a new account\n\nEnter the new password:",name);
- ShowPlayerDialog(playerid,12345,DIALOG_STYLE_INPUT,"Register",kayitmsg,"Register","Quit");
- register[playerid] = 1;
- login[playerid] = 0;
- }
- }
- if(dialogid == 12346)
- {
- Encrypt(inputtext);
- new string2[128];
- new playername2[MAX_PLAYER_NAME];
- GetPlayerName(playerid, playername2, sizeof(playername2));
- format(string2, sizeof(string2), ACCOUNTS_FOLDER, 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 , "Password" , true ) == 0 )
- {
- valtmp = ini_GetValue( PassData );
- strmid(AccountInfo[playerid][aPassword], valtmp, 0, strlen(valtmp)-1, 255);
- }
- if(strcmp(AccountInfo[playerid][aPassword],inputtext, true ) == 0)
- {
- if(strlen(inputtext))
- {
- for(new p = 0; p < strlen(AccountInfo[playerid][aPassword]); p++)
- {
- inputtext[p] = '?';
- }
- new key[256] , val[256];
- new Data[256];
- while ( fread( UserFile , Data , sizeof( Data ) ) )
- {
- key = ini_GetKey( Data );
- if(SAVE_MONEY_SCORE_FIGHT_DRUNK == 1)
- {
- if( strcmp( key , "Money" , true ) == 0 )
- {
- val = ini_GetValue( Data );
- ResetPlayerMoney(playerid);
- GivePlayerMoney(playerid,strval(val));
- }
- if( strcmp( key , "Score" , true ) == 0 )
- {
- val = ini_GetValue( Data );
- SetPlayerScore(playerid,strval(val));
- }
- if( strcmp( key , "DrunkLevel" , true ) == 0 )
- {
- val = ini_GetValue( Data );
- SetPlayerDrunkLevel(playerid,strval(val));
- }
- if( strcmp( key , "FightStyle" , true ) == 0 )
- {
- val = ini_GetValue( Data );
- SetPlayerFightingStyle(playerid,strval(val));
- }
- }
- if(SAVE_POS == 1)
- {
- if( strcmp( key , "PositionX" , true ) == 0 )
- {
- val = ini_GetValue( Data );
- PositionInfo[playerid][aPosX] = strval(val);
- }
- if( strcmp( key , "PositionY" , true ) == 0 )
- {
- val = ini_GetValue( Data );
- PositionInfo[playerid][aPosY] = strval(val);
- }
- if( strcmp( key , "PositionZ" , true ) == 0 )
- {
- val = ini_GetValue( Data );
- PositionInfo[playerid][aPosZ] = strval(val);
- }
- SetPlayerPos(playerid, PositionInfo[playerid][aPosX], PositionInfo[playerid][aPosY], PositionInfo[playerid][aPosZ]);
- if( strcmp( key , "Angle" , true ) == 0 )
- {
- val = ini_GetValue( Data );
- PositionInfo[playerid][aAngle] = strval(val);
- }
- if( strcmp( key , "Interior" , true ) == 0 )
- {
- val = ini_GetValue( Data );
- SetPlayerInterior(playerid, strval(val));
- }
- SetPlayerFacingAngle(playerid, PositionInfo[playerid][aAngle]);
- }
- if(SAVE_HEALTH == 1)
- {
- if( strcmp( key , "Health" , true ) == 0 )
- {
- val = ini_GetValue( Data );
- SetPlayerHealth(playerid, strval(val));
- }
- }
- if(SAVE_ARMOUR == 1)
- {
- if( strcmp( key , "Armour" , true ) == 0 )
- {
- val = ini_GetValue( Data );
- SetPlayerArmour(playerid, strval(val));
- }
- }
- if(SAVE_WEAPON == 1)
- {
- new silah[128];
- new mermi[128];
- ResetPlayerWeapons(playerid);
- for(new slot = 0; slot != 12; slot++)
- {
- format(silah,sizeof(silah),"Weapon%s",slot);
- if( strcmp( key , silah, true ) == 0 )
- {
- val = ini_GetValue( Data );
- strmid(WeaponInfo[playerid][slot], val, 0, strlen(val));
- }
- }
- for(new slot = 0; slot != 12; slot++)
- {
- format(mermi,sizeof(mermi),"Weapon%sAmmo",slot);
- if( strcmp( key , mermi, true ) == 0 )
- {
- val = ini_GetValue( Data );
- strmid(AmmoInfo[playerid][slot], val, 0, strlen(val));
- }
- }
- for(new slot = 0; slot != 12; slot++)
- {
- GivePlayerWeapon(playerid, WeaponInfo[playerid][slot], AmmoInfo[playerid][slot]);
- }
- if( strcmp( key , "ArmedWeapon" , true ) == 0 )
- {
- val = ini_GetValue( Data );
- SetPlayerArmedWeapon(playerid, strval(val));
- }
- }
- }
- register[playerid] = 0;
- login[playerid] = 0;
- AccountInfo[playerid][aLogged] = 1;
- printf("%s is logged in.",playername2);
- fclose(UserFile);
- }
- }
- else
- {
- if(strlen(inputtext))
- {
- new girismsg[256];
- printf("%s is used the wrong password.",playername2);
- format(girismsg,256,"WRONG PASSWORD\n\nPlease enter your password:");
- ShowPlayerDialog(playerid,12347,DIALOG_STYLE_INPUT,"Login",girismsg,"Login","Quit");
- login[playerid] = 1;
- register[playerid] = 0;
- failedlogin[playerid]++;
- fclose(UserFile);
- return 1;
- }
- }
- if(!strlen(inputtext))
- {
- new girismsg[256];
- printf("%s did not enter the password.",playername2);
- format(girismsg,256,"WRONG PASSWORD\n\nPlease enter your password:");
- ShowPlayerDialog(playerid,12347,DIALOG_STYLE_INPUT,"Login",girismsg,"Login","Quit");
- login[playerid] = 1;
- register[playerid] = 0;
- failedlogin[playerid]++;
- fclose(UserFile);
- return 1;
- }
- }
- }
- if(dialogid == 12347)
- {
- Encrypt(inputtext);
- new string2[128];
- new playername2[MAX_PLAYER_NAME];
- GetPlayerName(playerid, playername2, sizeof(playername2));
- format(string2, sizeof(string2), ACCOUNTS_FOLDER, 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 , "Password" , true ) == 0 )
- {
- valtmp = ini_GetValue( PassData );
- strmid(AccountInfo[playerid][aPassword], valtmp, 0, strlen(valtmp)-1, 255);
- }
- if(strcmp(AccountInfo[playerid][aPassword],inputtext, true ) == 0)
- {
- if(strlen(inputtext))
- {
- for(new p = 0; p < strlen(AccountInfo[playerid][aPassword]); p++)
- {
- inputtext[p] = '?';
- }
- new key[256] , val[256];
- new Data[256];
- while ( fread( UserFile , Data , sizeof( Data ) ) )
- {
- key = ini_GetKey( Data );
- if(SAVE_MONEY_SCORE_FIGHT_DRUNK == 1)
- {
- if( strcmp( key , "Money" , true ) == 0 )
- {
- val = ini_GetValue( Data );
- ResetPlayerMoney(playerid);
- GivePlayerMoney(playerid,strval(val));
- }
- if( strcmp( key , "Score" , true ) == 0 )
- {
- val = ini_GetValue( Data );
- SetPlayerScore(playerid,strval(val));
- }
- if( strcmp( key , "DrunkLevel" , true ) == 0 )
- {
- val = ini_GetValue( Data );
- SetPlayerDrunkLevel(playerid,strval(val));
- }
- if( strcmp( key , "FightStyle" , true ) == 0 )
- {
- val = ini_GetValue( Data );
- SetPlayerFightingStyle(playerid,strval(val));
- }
- }
- if(SAVE_POS == 1)
- {
- if( strcmp( key , "PositionX" , true ) == 0 )
- {
- val = ini_GetValue( Data );
- PositionInfo[playerid][aPosX] = strval(val);
- }
- if( strcmp( key , "PositionY" , true ) == 0 )
- {
- val = ini_GetValue( Data );
- PositionInfo[playerid][aPosY] = strval(val);
- }
- if( strcmp( key , "PositionZ" , true ) == 0 )
- {
- val = ini_GetValue( Data );
- PositionInfo[playerid][aPosZ] = strval(val);
- }
- SetPlayerPos(playerid, PositionInfo[playerid][aPosX], PositionInfo[playerid][aPosY], PositionInfo[playerid][aPosZ]);
- if( strcmp( key , "Angle" , true ) == 0 )
- {
- val = ini_GetValue( Data );
- PositionInfo[playerid][aAngle] = strval(val);
- }
- if( strcmp( key , "Interior" , true ) == 0 )
- {
- val = ini_GetValue( Data );
- SetPlayerInterior(playerid, strval(val));
- }
- SetPlayerFacingAngle(playerid, PositionInfo[playerid][aAngle]);
- }
- if(SAVE_HEALTH == 1)
- {
- if( strcmp( key , "Health" , true ) == 0 )
- {
- val = ini_GetValue( Data );
- SetPlayerHealth(playerid, strval(val));
- }
- }
- if(SAVE_ARMOUR == 1)
- {
- if( strcmp( key , "Armour" , true ) == 0 )
- {
- val = ini_GetValue( Data );
- SetPlayerArmour(playerid, strval(val));
- }
- }
- if(SAVE_WEAPON == 1)
- {
- new silah[128];
- new mermi[128];
- ResetPlayerWeapons(playerid);
- for(new slot = 0; slot != 12; slot++)
- {
- format(silah,sizeof(silah),"Weapon%s",slot);
- if( strcmp( key , silah, true ) == 0 )
- {
- val = ini_GetValue( Data );
- strmid(WeaponInfo[playerid][slot], val, 0, strlen(val));
- }
- }
- for(new slot = 0; slot != 12; slot++)
- {
- format(mermi,sizeof(mermi),"Weapon%sAmmo",slot);
- if( strcmp( key , mermi, true ) == 0 )
- {
- val = ini_GetValue( Data );
- strmid(AmmoInfo[playerid][slot], val, 0, strlen(val));
- }
- }
- for(new slot = 0; slot != 12; slot++)
- {
- GivePlayerWeapon(playerid, WeaponInfo[playerid][slot], AmmoInfo[playerid][slot]);
- }
- if( strcmp( key , "ArmedWeapon" , true ) == 0 )
- {
- val = ini_GetValue( Data );
- SetPlayerArmedWeapon(playerid, strval(val));
- }
- }
- }
- register[playerid] = 0;
- login[playerid] = 0;
- AccountInfo[playerid][aLogged] = 1;
- printf("%s is logged in.",playername2);
- fclose(UserFile);
- }
- }
- else
- {
- if(strlen(inputtext))
- {
- new girismsg[256];
- printf("%s is used the wrong password.",playername2);
- format(girismsg,256,"WRONG PASSWORD\n\nPlease enter your password:");
- if(FAILED_LOGIN_THRESHOLD == failedlogin[playerid])
- {
- Kick(playerid);
- }
- else
- {
- ShowPlayerDialog(playerid,12347,DIALOG_STYLE_INPUT,"Login",girismsg,"Login","Quit");
- login[playerid] = 1;
- register[playerid] = 0;
- failedlogin[playerid]++;
- }
- fclose(UserFile);
- return 1;
- }
- }
- if(!strlen(inputtext))
- {
- new girismsg[256];
- printf("%s did not enter the password.",playername2);
- format(girismsg,256,"WRONG PASSWORD\n\nPlease enter your password:");
- if(FAILED_LOGIN_THRESHOLD == failedlogin[playerid])
- {
- Kick(playerid);
- }
- else
- {
- ShowPlayerDialog(playerid,12347,DIALOG_STYLE_INPUT,"Login",girismsg,"Login","Quit");
- login[playerid] = 1;
- register[playerid] = 0;
- failedlogin[playerid]++;
- }
- fclose(UserFile);
- return 1;
- }
- }
- }
- }
- else return Kick(playerid);
- return 0;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- return 1;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(IsPlayerAdmin(playerid))
- {
- if(strcmp(cmdtext, "/savepos", true) == 0)
- {
- if(SAVE_POS == 0)
- {
- SendClientMessage(playerid,GREEN,"Automatic position saving enabled!");
- SAVE_POS = 1;
- }
- else if(SAVE_POS == 1)
- {
- SendClientMessage(playerid,RED,"Automatic position saving disabled!");
- SAVE_POS = 0;
- }
- return 1;
- }
- if(strcmp(cmdtext, "/savewep", true) == 0)
- {
- if(SAVE_WEAPON == 0)
- {
- SendClientMessage(playerid,GREEN,"Automatic weapon saving enabled!");
- SAVE_WEAPON = 1;
- }
- else if(SAVE_WEAPON == 1)
- {
- SendClientMessage(playerid,RED,"Automatic weapon saving disabled!");
- SAVE_WEAPON = 0;
- }
- return 1;
- }
- if(strcmp(cmdtext, "/savearmo", true) == 0)
- {
- if(SAVE_ARMOUR == 0)
- {
- SendClientMessage(playerid,GREEN,"Automatic armour saving enabled!");
- SAVE_ARMOUR = 1;
- }
- else if(SAVE_ARMOUR == 1)
- {
- SendClientMessage(playerid,RED,"Automatic armour saving disabled!");
- SAVE_ARMOUR = 0;
- }
- return 1;
- }
- if(strcmp(cmdtext, "/saveheal", true) == 0)
- {
- if(SAVE_HEALTH == 0)
- {
- SendClientMessage(playerid,GREEN,"Automatic health saving enabled!");
- SAVE_HEALTH = 1;
- }
- else if(SAVE_HEALTH == 1)
- {
- SendClientMessage(playerid,RED,"Automatic health saving disabled!");
- SAVE_HEALTH = 0;
- }
- return 1;
- }
- }
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
- 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 OnPlayerUpdate(playerid)
- {
- new Float:x, Float:y, Float:z, Float:angle, Float:armour, Float:health;
- if(IsPlayerConnected(playerid))
- {
- if(AccountInfo[playerid][aLogged] == 1)
- {
- new string3[128];
- new playername3[MAX_PLAYER_NAME];
- GetPlayerName(playerid, playername3, sizeof(playername3));
- format(string3, sizeof(string3), ACCOUNTS_FOLDER, playername3);
- new ip[20];
- GetPlayerIp(playerid,ip,sizeof(ip));
- new File: hFile = fopen(string3, io_write);
- if (hFile)
- {
- new var[128];
- format(var, 128, "Password=%s\n", AccountInfo[playerid][aPassword]);fwrite(hFile, var);
- format(var, 128, "IP=%s\n",ip);fwrite(hFile, var);
- if(SAVE_MONEY_SCORE_FIGHT_DRUNK == 1)
- {
- format(var, 128, "Money=%d\n",GetPlayerMoney(playerid));fwrite(hFile, var);
- format(var, 128, "Score=%d\n",GetPlayerScore(playerid));fwrite(hFile, var);
- format(var, 128, "DrunkLevel=%d\n",GetPlayerDrunkLevel(playerid));fwrite(hFile, var);
- format(var, 128, "FightStyle=%d\n",GetPlayerFightingStyle(playerid));fwrite(hFile, var);
- }
- if(SAVE_POS == 1)
- {
- GetPlayerPos(playerid, x, y, z);
- GetPlayerFacingAngle(playerid, angle);
- format(var, 128, "PositionX=%f\n",x);fwrite(hFile, var);
- format(var, 128, "PositionY=%f\n",y);fwrite(hFile, var);
- format(var, 128, "PositionZ=%f\n",z);fwrite(hFile, var);
- format(var, 128, "Angle=%f\n",angle);fwrite(hFile, var);
- format(var, 128, "Interior=%d\n",GetPlayerInterior(playerid));fwrite(hFile, var);
- }
- if(SAVE_ARMOUR == 1)
- {
- GetPlayerArmour(playerid, armour);
- format(var, 128, "Armour=%f\n",armour);fwrite(hFile, var);
- }
- if(SAVE_HEALTH == 1)
- {
- GetPlayerHealth(playerid, health);
- format(var, 128, "Health=%f\n",health);fwrite(hFile, var);
- }
- if(SAVE_WEAPON == 1)
- {
- for(new slot = 0; slot != 12; slot++)
- {
- GetPlayerWeaponData(playerid, slot, WeaponInfo[playerid][slot], AmmoInfo[playerid][slot]);
- }
- for(new slot = 0; slot != 12; slot++)
- {
- format(var, 128, "Weapon%d=%d\n", slot, WeaponInfo[playerid][slot]);fwrite(hFile, var);
- format(var, 128, "Weapon%dAmmo=%d\n", slot, AmmoInfo[playerid][slot]);fwrite(hFile, var);
- }
- format(var, 128, "ArmedWeapon=%d\n",GetPlayerWeapon(playerid));fwrite(hFile, var);
- }
- fclose(hFile);
- }
- }
- }
- return 1;
- }
- Encrypt(string[])
- {
- for(new x=0; x < strlen(string); x++)
- {
- string[x] += (3^x) * (x % 15);
- if(string[x] > (0xff))
- {
- string[x] -= 256;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement