29.08.2012, 10:40
Hello guys can you check these codes for me and tell me what is wrong when i join the server it tells me to login it should display register not login!
my OnPlayerConnect
My OnDialogResponse
My Register_Player and Login_Player
And guys please tell me if there are any thing i can make to improve performance.
Thanks in advance.
my OnPlayerConnect
pawn Код:
if(fexist(UserPath(playerid)))
{
format(Str, sizeof(Str), "{FFFF00}Your Name : {FFFFFF}%s\n\n{FFFF00}Your IP : {FFFFFF}%s\n\n{FFFFFF}Hello And Welcome To {FF0000}Destiny Deathmatch{FFFFFF} In Order\n{FFFFFF}To Play Please Create An Account By Typing A Passowrd\n{FFFFFF}Below In The Box\n\n{FF0000}Note : {FFFFFF}You Can Play As A Guest But You Will Have Limited Features\n\n", pName, IP);
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Create An Account", Str, "Register", "Guest");
}
else
{
format(Str, sizeof(Str), "{FFFF00}Your Name : {FFFFFF}%s\n\n{FFFF00}Your IP : {FFFFFF}%s\n\n{FFFFFF}Welcome Back To {FF0000}Destiny Deathmatch{FFFFFF} Please Sign In\n{FFFFFF} By Using The Password Below That You Used While Registering\n{FFFFFF} In Order To Procceed\n\n", pName, IP);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", Str, "Login", "Leave");
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
// - - General Variables - - //
new pName[MAX_PLAYER_NAME], IP[16];
GetPlayerName(playerid, pName, sizeof(pName));
GetPlayerIp(playerid, IP, sizeof(IP));
// - - - - - - - - - - - - - //
switch(dialogid)
{
case DIALOG_REGISTER:
{
if(response)
{
if(!strlen(inputtext) || strlen(inputtext) > 100)
{
SendClientMessage(playerid, -1, "{FF0000}Error : {FFFFFF}Your Password Needs To Be Between {FF0000}(1 - 100){FFFFFF} Characters");
}
Register_Player(playerid, inputtext);
SendClientMessage(playerid, -1, "{FFFF00}D-DM : {FFFFFF}You Have Registered {00FF00}Successfully{FFFFFF} Welcome Abroad");
}
}
case DIALOG_LOGIN:
{
if(response)
{
if(!strcmp(inputtext, "Password", false))
{
new Str[400];
SendClientMessage(playerid, -1, "{FF0000}Error : {FFFFFF}The Password You Typed Is {FF0000}Incorrect");
format(Str, sizeof(Str), "{FFFF00}Your Name : {FFFFFF}%s\n\n{FFFF00}Your IP : {FFFFFF}%s\n\n{FFFFFF}Welcome Back To {FF0000}Destiny Deathmatch{FFFFFF} Please Sign In\n{FFFFFF} By Using The Password Below That You Used While Registering\n{FFFFFF} In Order To Procceed\n\n", pName, IP);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", Str, "Login", "Leave");
}
Login_Player(playerid);
SendClientMessage(playerid, -1, "{FFFF00}D-DM : {FFFFFF}You Have Logged In {00FF00}Successfully{FFFFFF} Welcome Back");
}
}
}
return 1;
}
pawn Код:
stock Register_Player(playerid, password[])
{
// - - Global Variables - - //
new Str[128], File:Handle;
// - - - - - - - - - - - - //
if(fexist(UserPath(playerid)))
{
fremove(UserPath(playerid));
}
// - - - - - - - - - - - - //
Handle = fopen(UserPath(playerid), io_append);
// - - - - - - - - - - - - //
format(Str, sizeof(Str), "Password %s\r\n", password);
fwrite(Handle, Str);
// - - - - - - - - - - - - //
format(Str, sizeof(Str), "Admin %s\r\n", PlayerInfo[playerid][pAdmin]);
fwrite(Handle, Str);
// - - - - - - - - - - - - //
format(Str, sizeof(Str), "Money %s\r\n", PlayerInfo[playerid][pMoney]);
fwrite(Handle, Str);
// - - - - - - - - - - - - //
format(Str, sizeof(Str), "Score %s\r\n", PlayerInfo[playerid][pScore]);
fwrite(Handle, Str);
// - - - - - - - - - - - - //
format(Str, sizeof(Str), "Deaths %s\r\n", PlayerInfo[playerid][pDeaths]);
// - - - - - - - - - - - - //
format(Str, sizeof(Str), "Kills %s\r\n", PlayerInfo[playerid][pKills]);
fwrite(Handle, Str);
// - - - - - - - - - - - - //
format(Str, sizeof(Str), "CBChannel %s\r\n", PlayerInfo[playerid][pCBChannel]);
fwrite(Handle, Str);
// - - - - - - - - - - - - //
format(Str, sizeof(Str), "PosX %f\r\n", PlayerInfo[playerid][PosX]);
fwrite(Handle, Str);
// - - - - - - - - - - - - //
format(Str, sizeof(Str), "PosY %f\r\n", PlayerInfo[playerid][PosY]);
fwrite(Handle, Str);
// - - - - - - - - - - - - //
format(Str, sizeof(Str), "PosZ %f\r\n", PlayerInfo[playerid][PosZ]);
fwrite(Handle, Str);
// - - - - - - - - - - - - //
format(Str, sizeof(Str), "PosA %f\r\n", PlayerInfo[playerid][PosA]);
fwrite(Handle, Str);
// - - - - - - - - - - - - //
fclose(Handle);
// - - - - - - - - - - - - //
return 1;
}
//------------------------------------------------------------------------------
stock Login_Player(playerid)
{
// - - General Variables - - //
new File:Handle, Str[128], Var[128], Val[128];
// - - - - - - - - - - - - //
if(!fexist(UserPath(playerid)))
{
return 0;
}
// - - - - - - - - - - - - //
Handle = fopen(UserPath(playerid), io_read);
// - - - - - - - - - - - - //
while(fread(Handle, Str))
{
if(sscanf(Str, "s[128]s[128]", Var, Val))
{
if(!strcmp(Var, "Password", true))
{
format(PlayerInfo[playerid][pPassword], 50, "%s", Val);
}
else if(!strcmp(Var, "Admin", true))
{
PlayerInfo[playerid][pAdmin] = strval(Val);
}
else if(!strcmp(Var, "Money", true))
{
PlayerInfo[playerid][pMoney] = strval(Val);
}
else if(!strcmp(Var, "Score", true))
{
PlayerInfo[playerid][pScore] = strval(Val);
}
else if(!strcmp(Var, "Deaths", true))
{
PlayerInfo[playerid][pDeaths] = strval(Val);
}
else if(!strcmp(Var, "Kills", true))
{
PlayerInfo[playerid][pKills] = strval(Val);
}
else if(!strcmp(Var, "CBChannel", true))
{
PlayerInfo[playerid][pCBChannel] = strval(Val);
}
else if(!strcmp(Var, "PosX", true))
{
PlayerInfo[playerid][PosX] = floatstr(Val);
}
else if(!strcmp(Var, "PosY", true))
{
PlayerInfo[playerid][PosY] = floatstr(Val);
}
else if(!strcmp(Var, "PosZ", true))
{
PlayerInfo[playerid][PosZ] = floatstr(Val);
}
else if(!strcmp(Var, "Posa", true))
{
PlayerInfo[playerid][PosA] = floatstr(Val);
}
}
}
// - - - - - - - - - - - - //
fclose(Handle);
// - - - - - - - - - - - - //
return 1;
}
Thanks in advance.