30.07.2012, 15:46
hey all i have one problem i have register/login system using <YSI\y_ini> include i have one problem after join and create file in users and then reconnect and leave again have a clone bug here is reg/log system code
and after all in mu Users folder file have this
see this
Please help i give Rep
PHP код:
#include <a_samp>
#include <YSI\y_ini>
#include <dudb>
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define DIALOG_SUCCESS_1 3
#define DIALOG_SUCCESS_2 4
#define COL_WHITE "{FFFFFF}"
#define COL_RED "{F81414}"
#define COL_GREEN "{00FF22}"
#define COL_LIGHTBLUE "{00CED1}"
#define PATH "/Users/%s.ini"
#pragma unused ret_memcpy
enum pInfo
{
pPass,
pCash,
pAdmin,
pKills,
pDeaths,
pLevel,
Credits,
Xp,
Extra1,
Extra2,
Extra3,
Extra4,
Extra5,
Hungry,
Heroin,
Weed,
Material,
Police,
CIA,
Army,
Medic,
Fire,
News,
Goverment,
Licenser,
Piss,
CarLic,
TruckLic,
HeliLic,
BikeLic,
GunLic,
LawLic,
Passport,
Radio,
Jobs,
Faction,
Wanted,
Skill
}
new PlayerInfo[MAX_PLAYERS][pInfo];
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Password",PlayerInfo[playerid][pPass]);
INI_Int("Cash",PlayerInfo[playerid][pCash]);
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
INI_Int("Kills",PlayerInfo[playerid][pKills]);
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
INI_Int("Level",PlayerInfo[playerid][pLevel]);
INI_Int("Credits",PlayerInfo[playerid][Credits]);
INI_Int("Xp",PlayerInfo[playerid][Xp]);
INI_Int("Extra1",PlayerInfo[playerid][Extra1]);
INI_Int("Extra2",PlayerInfo[playerid][Extra2]);
INI_Int("Extra3",PlayerInfo[playerid][Extra3]);
INI_Int("Extra4",PlayerInfo[playerid][Extra4]);
INI_Int("Extra5",PlayerInfo[playerid][Extra5]);
INI_Int("Hungry",PlayerInfo[playerid][Hungry]);
INI_Int("Heroin",PlayerInfo[playerid][Heroin]);
INI_Int("Weed",PlayerInfo[playerid][Weed]);
INI_Int("Material",PlayerInfo[playerid][Material]);
INI_Int("Police",PlayerInfo[playerid][Police]);
INI_Int("CIA",PlayerInfo[playerid][CIA]);
INI_Int("Army",PlayerInfo[playerid][Army]);
INI_Int("Medic",PlayerInfo[playerid][Medic]);
INI_Int("Fire",PlayerInfo[playerid][Fire]);
INI_Int("News",PlayerInfo[playerid][News]);
INI_Int("Goverment",PlayerInfo[playerid][Goverment]);
INI_Int("Licenser",PlayerInfo[playerid][Licenser]);
INI_Int("Piss",PlayerInfo[playerid][Piss]);
INI_Int("Car License",PlayerInfo[playerid][CarLic]);
INI_Int("Truck License",PlayerInfo[playerid][TruckLic]);
INI_Int("Heli License",PlayerInfo[playerid][HeliLic]);
INI_Int("Bike License",PlayerInfo[playerid][BikeLic]);
INI_Int("Gun License",PlayerInfo[playerid][GunLic]);
INI_Int("Law License",PlayerInfo[playerid][LawLic]);
INI_Int("Passport",PlayerInfo[playerid][Passport]);
INI_Int("Radio",PlayerInfo[playerid][Radio]);
INI_Int("Jobs",PlayerInfo[playerid][Jobs]);
INI_Int("Faction",PlayerInfo[playerid][Faction]);
INI_Int("Wanted Level",PlayerInfo[playerid][Wanted]);
INI_Int("Skill Point",PlayerInfo[playerid][Skill]);
return 1;
}
stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),PATH,playername);
return string;
}
public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Логин",""COL_WHITE"Попълнете паролата си преди да се логнете.","Логин","Излез");
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Регистриране...",""COL_WHITE"Попълнете паролата си преди да регистрирате нов акаунт.","Регистриране","Излез");
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File,"Level",PlayerInfo[playerid][pLevel]);
INI_WriteInt(File,"Credits",PlayerInfo[playerid][Credits]);
INI_WriteInt(File,"Xp",PlayerInfo[playerid][Xp]);
INI_WriteInt(File,"Extra1",PlayerInfo[playerid][Extra1]);
INI_WriteInt(File,"Extra2",PlayerInfo[playerid][Extra2]);
INI_WriteInt(File,"Extra3",PlayerInfo[playerid][Extra3]);
INI_WriteInt(File,"Extra4",PlayerInfo[playerid][Extra4]);
INI_WriteInt(File,"Extra5",PlayerInfo[playerid][Extra5]);
INI_WriteInt(File,"Hungry",PlayerInfo[playerid][Hungry]);
INI_WriteInt(File,"Heroin",PlayerInfo[playerid][Heroin]);
INI_WriteInt(File,"Weed",PlayerInfo[playerid][Weed]);
INI_WriteInt(File,"Material",PlayerInfo[playerid][Material]);
INI_WriteInt(File,"Police",PlayerInfo[playerid][Police]);
INI_WriteInt(File,"CIA",PlayerInfo[playerid][CIA]);
INI_WriteInt(File,"Army",PlayerInfo[playerid][Army]);
INI_WriteInt(File,"Medic",PlayerInfo[playerid][Medic]);
INI_WriteInt(File,"Fire",PlayerInfo[playerid][Fire]);
INI_WriteInt(File,"News",PlayerInfo[playerid][News]);
INI_WriteInt(File,"Goverment",PlayerInfo[playerid][Goverment]);
INI_WriteInt(File,"Licenser",PlayerInfo[playerid][Licenser]);
INI_WriteInt(File,"Piss",PlayerInfo[playerid][Piss]);
INI_WriteInt(File,"Car License",PlayerInfo[playerid][CarLic]);
INI_WriteInt(File,"Truck License",PlayerInfo[playerid][TruckLic]);
INI_WriteInt(File,"Heli License",PlayerInfo[playerid][HeliLic]);
INI_WriteInt(File,"Bike License",PlayerInfo[playerid][BikeLic]);
INI_WriteInt(File,"Gun License",PlayerInfo[playerid][GunLic]);
INI_WriteInt(File,"Law License",PlayerInfo[playerid][LawLic]);
INI_WriteInt(File,"Passport",PlayerInfo[playerid][Passport]);
INI_WriteInt(File,"Radio",PlayerInfo[playerid][Radio]);
INI_WriteInt(File,"Jobs",PlayerInfo[playerid][Jobs]);
INI_WriteInt(File,"Faction",PlayerInfo[playerid][Faction]);
INI_WriteInt(File,"Wanted Level",GetPlayerWantedLevel(playerid));
INI_WriteInt(File,"Skill Point",PlayerInfo[playerid][Skill]);
INI_Close(File);
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Регистриране...",""COL_RED"Въвели сте грешна парола.\n"COL_WHITE"Попълнете паролата си преди да регистрирате нов акаунт.","Регистрирай","Излез");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_WriteInt(File,"Level",0);
INI_WriteInt(File,"Vip",0);
INI_WriteInt(File,"Credits",0);
INI_WriteInt(File,"Xp",0);
INI_WriteInt(File,"Extra1",0);
INI_WriteInt(File,"Extra2",0);
INI_WriteInt(File,"Extra3",0);
INI_WriteInt(File,"Extra4",0);
INI_WriteInt(File,"Extra5",0);
INI_WriteInt(File,"Hungry",0);
INI_WriteInt(File,"Heroin",0);
INI_WriteInt(File,"Weed",0);
INI_WriteInt(File,"Material",0);
INI_WriteInt(File,"Police",0);
INI_WriteInt(File,"CIA",0);
INI_WriteInt(File,"Army",0);
INI_WriteInt(File,"Medic",0);
INI_WriteInt(File,"Fire",0);
INI_WriteInt(File,"News",0);
INI_WriteInt(File,"Goverment",0);
INI_WriteInt(File,"Licenser",0);
INI_WriteInt(File,"Piss",0);
INI_WriteInt(File,"Car License",0);
INI_WriteInt(File,"Truck License",0);
INI_WriteInt(File,"Heli License",0);
INI_WriteInt(File,"Bike Lecense",0);
INI_WriteInt(File,"Gun License",0);
INI_WriteInt(File,"Law License",0);
INI_WriteInt(File,"Passport",0);
INI_WriteInt(File,"Time Played",0);
INI_WriteInt(File,"Radio",0);
INI_WriteInt(File,"Jobs",0);
INI_WriteInt(File,"Faction",0);
INI_WriteInt(File,"Wanted Level",0);
INI_WriteInt(File,"Skill Point",0);
INI_Close(File);
SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Успешно!",""COL_GREEN"Чудесно! Вашия акаунт е създаден успешно и работи. Релогнете за да запишете статистиката си!","Ok","");
}
}
case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Успешно!",""COL_GREEN"Вие успешно се логнахте!","Ok","");
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Логин",""COL_RED"Вие сте въвели грешна парола.\n"COL_WHITE"Попълнете паролата си преди да се логнете.","Логин","Излез");
}
return 1;
}
}
}
return 1;}
PHP код:
[data]
Password = ********
Cash = 153886
Admin = 8
Kills = 0
Deaths = 0
Level = 5
Credits = 0
Xp = 0
Extra1 = 0
Extra2 = 0
Extra3 = 0
Extra4 = 0
Extra5 = 0
Hungry = 94
Heroin = 0
Weed = 0
Material = 0
Police = 5
CIA = 0
Army = 0
Medic = 0
Fire = 0
News = 0
Goverment = 0
Licenser = 0
Piss = 0
Car License = 0
Truck License = 0
Heli License = 0
Bike License = 0
Gun License = 0
Law License = 0
Passport = 0
Radio = 0
Jobs = 0
Faction = 0
Wanted Level = 0
Skill Point = 0
Car License = 0
Truck License = 0
Heli License = 0
Bike License = 0
Gun License = 0
Law License = 0
Wanted Level = 0
Skill Point = 0
PHP код:
Car License = 0
Truck License = 0
Heli License = 0
Bike License = 0
Gun License = 0
Law License = 0
Passport = 0
Radio = 0
Jobs = 0
Faction = 0
Wanted Level = 0
Skill Point = 0
Car License = 0
Truck License = 0
Heli License = 0
Bike License = 0
Gun License = 0
Law License = 0
Wanted Level = 0