27.05.2017, 12:18
i have Create my registered system but when other one create acc old one pass dose not work and cash also not load need help plz
these are my codes kindly help
PHP код:
#define DIALOG_REGISTER 0
#define DIALOG_LOGIN 1
#define WHITE "{FFFFFF}"
#define RED "{F81414}"
#define GREEN "{00FF22}"
#define LIGHTBLUE "{00CED1}"
#define PATH "/Users/%.ini"
enum pInfo
{
pName[MAX_PLAYER_NAME],
pPass,
pScore,
pAdmin,
pDonator,
pDeaths,
pKills,
pNOPM,
pRank,
pCash,
pClothes,
pBanned,
pTeleport,
pRegistered,
pSpawned,
pReputation
}
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("Score",PlayerInfo[playerid][pScore]);
INI_Int("AdminLevel",PlayerInfo[playerid][pAdmin]);
INI_Int("Donator",PlayerInfo[playerid][pDonator]);
INI_Int("Nopm",PlayerInfo[playerid][pNOPM]);
INI_Int("Kills",PlayerInfo[playerid][pKills]);
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
INI_Int("Rank",PlayerInfo[playerid][pRank]);
INI_Int("Money",PlayerInfo[playerid][pCash]);
INI_Int("Reputation",PlayerInfo[playerid][pReputation]);
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;
}
/*Credits to Dracoblue*/
stock udb_hash(buf[]) {
new length=strlen(buf);
new s1 = 1;
new s2 = 0;
new n;
for (n=0; n<length; n++)
{
s1 = (s1 + buf[n]) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
GetVehicleModelIDFromName(vname[])
{
for(new i = 0; i < 211; i++)
{
if(strfind(VehicleNames[i], vname, true) != -1)
return i + 400;
}
return -1;
}
stock GetXYInFrontOfPlayer(playerid, &Float:x2, &Float:y2, Float:distance)
{
new Float:a;
GetPlayerPos(playerid, x2, y2, a);
GetPlayerFacingAngle(playerid, a);
if(GetPlayerVehicleID(playerid))
{
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
}
x2 += (distance * floatsin(-a, degrees));
y2 += (distance * floatcos(-a, degrees));
}
if(fexist(UserPath(playerid)))
{
PlayerInfo[playerid][pRegistered] = 1;
}
else
{
PlayerInfo[playerid][pRegistered] = 0;
}
if(PlayerInfo[playerid][pRegistered] == 1)
{
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = PlayerInfo[playerid][pName]);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""WHITE"Login",""WHITE"Type your password below to login in Your Account.","Login","Quit");
}
else
{
SendClientMessage(playerid, COLOR_ORANGE,"This Acount is Not Registered please Play 3 Minutes to Register your Account!");
}
}
if(PlayerInfo[playerid][pRegistered] == 1)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"AdminLevel",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File,"Score",PlayerInfo[playerid][pScore]);
INI_WriteInt(File,"Donator",PlayerInfo[playerid][pDonator]);
INI_WriteInt(File,"NOPM",PlayerInfo[playerid][pNOPM]);
INI_WriteInt(File,"Reputation",PlayerInfo[playerid][pReputation]);
INI_Close(File);
}
if(PlayerInfo[playerid][pRegistered] == 0)
{
SetTimerEx("Registration",180000,false,"i",playerid);
}
forward Registration(playerid);
public Registration(playerid)
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""WHITE"Registering...",""WHITE"Welcome to Aldrago's DeathMatch Paradise Version(0.1) \n\n Your Account is Not Registered That Means You are new Player \n if You Have Already a Account Then Quit and Join from it \n\n Type a Password to Registered Your Account","Register","Quit");
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, ""WHITE"Registering...",""RED"You have entered an invalid password.\n"WHITE"Type your password below to register a new account.","Register","Quit");
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,"AdminLevel",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_WriteInt(File,"Score",0);
INI_WriteInt(File,"Donator",0);
INI_WriteInt(File,"Nopm",0);
INI_WriteInt(File,"Rank",0);
INI_WriteInt(File,"Registered",0);
INI_WriteInt(File,"Reputation",0);
INI_Close(File);
PlayerInfo[playerid][pRegistered] = 1;
GivePlayerMoney(playerid, 50000);
print("Account Has been Registered");
}
}
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 = PlayerInfo[playerid][pName]);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
if(PlayerInfo[playerid][pAdmin] == 1) SendClientMessage(playerid, COLOR_WHITE,"Login as {00CED1}Server Admin");
else
if(PlayerInfo[playerid][pAdmin] == 2) SendClientMessage(playerid, COLOR_WHITE,"Login as {00CED1}Co-Owner");
else
if(PlayerInfo[playerid][pAdmin] == 3) SendClientMessage(playerid, COLOR_WHITE,"Login as {00CED1}Owner");
else
if(PlayerInfo[playerid][pDonator] == 1) SendClientMessage(playerid, COLOR_WHITE,"Login as {00FF22}Donator Player");
else
SendClientMessage(playerid, COLOR_WHITE,"Login as {00CED1}Registered Player");
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""WHITE"Login",""RED"You have entered an incorrect password.\n"WHITE"Type your password below to login.","Login","Quit");
}
return 1;
}
}
}
return 1;
}