jeudi 8 janvier 2015

Login/Register Dialog bug

player can be spawned without registration i think is dialog bug help mee and tell me what i need to post



code:


Code:



#define DIALOG_REGISTER 1995

#define DIALOG_LOGIN 1996

#define JDIALOGS 2000

#define DIALOG_PRIVATE_MESSAGE 1997




Code:



public OnPlayerConnect(playerid)

{



GameTextForPlayer(playerid,"~w~WELCOME TO ~N~~r~TERRORISTS ~N~VS. ~n~~B~COPS!",3000,4);

//Capturezones//

SetPlayerMapIcon(playerid, 2, 405.8832,2437.1450,16.5000, 19, MAPICON_GLOBAL);

GangZoneShowForAll(Zone[CAPZONE], 0x00000043);

IsPlayerCapturing[playerid][CAPZONE] = 0;

CountVar[playerid][CAPZONE] = 25;

if(tCP[CAPZONE] == NONE) GangZoneShowForAll(Zone[CAPZONE], -66);

else if(tCP[CAPZONE] == C1) GangZoneShowForAll(Zone[CAPZONE], C_GZ_COLOR);

else if(tCP[CAPZONE] == T1) GangZoneShowForAll(Zone[CAPZONE], T_GZ_COLOR);

//--//

new score[128];

format(score, sizeof(score), "~y~Score: ~w~%d",GetPlayerScore(playerid));

ScoreTextdraw[playerid] = TextDrawCreate(534.000000, 385.000000, "~y~Score :~w~");

TextDrawBackgroundColor(ScoreTextdraw[playerid], 255);

TextDrawFont(ScoreTextdraw[playerid], 2);

TextDrawLetterSize(ScoreTextdraw[playerid], 0.200000, 1.300000);

TextDrawColor(ScoreTextdraw[playerid], -1);

TextDrawSetOutline(ScoreTextdraw[playerid], 0);

TextDrawSetProportional(ScoreTextdraw[playerid], 1);

TextDrawSetShadow(ScoreTextdraw[playerid], 1);

TextDrawSetSelectable(ScoreTextdraw[playerid], 0);



new kills[128];

format(kills, sizeof(kills), "~g~Kills: ~w~%d", pInfo[playerid][Kills]);

KillsTextdraw[playerid] = TextDrawCreate(534.000000, 400.000000, "~g~Kills :~w~");

TextDrawBackgroundColor(KillsTextdraw[playerid], 255);

TextDrawFont(KillsTextdraw[playerid], 2);

TextDrawLetterSize(KillsTextdraw[playerid], 0.200000, 1.300000);

TextDrawColor(KillsTextdraw[playerid], -1);

TextDrawSetOutline(KillsTextdraw[playerid], 0);

TextDrawSetProportional(KillsTextdraw[playerid], 1);

TextDrawSetShadow(KillsTextdraw[playerid], 1);

TextDrawSetSelectable(KillsTextdraw[playerid], 0);



new deaths[128];

format(deaths, sizeof(deaths), "~r~Deaths: ~w~%d", pInfo[playerid][Deaths]);

DeathsTextdraw[playerid] = TextDrawCreate(534.000000, 415.000000, "~r~Deaths :~w~");

TextDrawBackgroundColor(DeathsTextdraw[playerid], 255);

TextDrawFont(DeathsTextdraw[playerid], 2);

TextDrawLetterSize(DeathsTextdraw[playerid], 0.200000, 1.300000);

TextDrawColor(DeathsTextdraw[playerid], -1);

TextDrawSetOutline(DeathsTextdraw[playerid], 0);

TextDrawSetProportional(DeathsTextdraw[playerid], 1);

TextDrawSetShadow(DeathsTextdraw[playerid], 1);

TextDrawSetSelectable(DeathsTextdraw[playerid], 0);





new ratio[128];

format(ratio, sizeof(ratio), "~b~Kills: ~w~%d", FloatInfo[playerid][Kills]/FloatInfo[playerid][Deaths]);

RatioTextdraw[playerid] = TextDrawCreate(534.000000, 430.000000, "~b~Ratio :~w~");

TextDrawBackgroundColor(RatioTextdraw[playerid], 255);

TextDrawFont(RatioTextdraw[playerid], 2);

TextDrawLetterSize(RatioTextdraw[playerid], 0.200000, 1.300000);

TextDrawColor(RatioTextdraw[playerid], -1);

TextDrawSetOutline(RatioTextdraw[playerid], 0);

TextDrawSetProportional(RatioTextdraw[playerid], 1);

TextDrawSetShadow(RatioTextdraw[playerid], 1);

TextDrawSetSelectable(RatioTextdraw[playerid], 0);



TextDrawShowForPlayer(playerid, Welcome);

TextDrawShowForPlayer(playerid, Textdraw0);

TextDrawShowForPlayer(playerid, CvT);

TextDrawShowForPlayer(playerid, OG);

TextDrawShowForPlayer(playerid, register1);



if(IsPlayerNPC(playerid)) return 1;

#if SpecTextDraw == true

CreateSpecTD(playerid);

#endif

new Jfile[100],pIP[16],Jstr[128];

strdel(aka,0,256);

GetPlayerIp(playerid,pIP,16);

GetPlayerIp(playerid,playerIP,16);

format(Jfile,sizeof(Jfile),"JLadmin/Logs/aka.ini");

INI_ParseFile(Jfile,"GetAkaLog");

ResetVariables(playerid);

if(strlen(aka) < 3)

{

format(Jfile,sizeof(Jfile),"JLadmin/Logs/aka.ini");

new INI:AKA = INI_Open(Jfile);

INI_WriteString(AKA, pIP, GetName(playerid));

INI_Close(AKA);

}

else if(strfind(aka, GetName(playerid), true) == -1)

{

format(Jfile,sizeof(Jfile),"JLadmin/Logs/aka.ini");

format(Jstr,sizeof(Jstr),"%s,%s", aka, GetName(playerid));

new INI:AKA = INI_Open(Jfile);

INI_WriteString(AKA, pIP, Jstr);

INI_Close(AKA);

}

if(strlen(aka) > 70)

{

strmid(Jstring,aka,0,70);

format(Jstr, sizeof(Jstr),"Sign in >> Player: %s - IP: %s - AKA: %s", GetName(playerid),playerIP , Jstring);

SendToAdmins(Cmdcolor,Jstr);

strmid(Jstring,aka,70,sizeof(aka));

format(Jstr, sizeof(Jstr),"%s", Jstring);

SendToAdmins(Cmdcolor,Jstr);

}

else

{

if(strlen(aka) > 2) format(Jstr, sizeof(Jstr),"Sign in >> Player: %s - IP: %s - AKA: %s", GetName(playerid),playerIP , aka);

else format(Jstr, sizeof(Jstr),"Sign in >> Player: %s - IP: %s - AKA: No aka found!", GetName(playerid),playerIP);

SendToAdmins(Cmdcolor,Jstr);

}

format(Jfile, 100, ACCOUNTS_PATH, GetName(playerid));

if(!fexist(Jfile))

{

format(Jstring, sizeof(Jstring),"Nick name \"%s\" isn't registered. Please register your nick name to save your status\nEnter the password:", GetName(playerid));

if(MustRegister == 1) ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"Register an account!", Jstring, "Register", "Kick");

SendClientMessage(playerid,red,"Nick name isn't registered!");

SendClientMessage(playerid,lighterblue,"Please register to create an account (/register)");

}

else

{

pInfo[playerid][Registered] = 1;

format(Jfile, 100, ACCOUNTS_PATH, GetName(playerid));

INI_ParseFile(Jfile, "GetPlayerInfo", .bExtra = true, .extra = playerid);

if(AutoLogin == 1 && (!strcmp(pIP, pInfo[playerid][IP],true) && pInfo[playerid][pAutoLogin] == 1))

{

format(Jfile, 100, ACCOUNTS_PATH, GetName(playerid));

INI_ParseFile(Jfile, "LoginPlayer", .bExtra = true, .extra = playerid);

SetPlayerScore(playerid, pInfo[playerid][Score]);

GivePlayerMoney(playerid, pInfo[playerid][Cash]);

pInfo[playerid][Logged] = 1;

if(pInfo[playerid][pLevel] >= 1)

{

switch(pInfo[playerid][pLevel])

{

case 1: LevelName = ADMIN_LEVEL_1;

case 2: LevelName = ADMIN_LEVEL_2;

case 3: LevelName = ADMIN_LEVEL_4;

case 4: LevelName = ADMIN_LEVEL_3;

case 5: LevelName = ADMIN_LEVEL_5;

default: LevelName = ADMIN_LEVEL_6;

}

format(Jstring, sizeof(Jstring),"Welcome back, You have been automatically logged in! | Level: %d (%s)", pInfo[playerid][pLevel], LevelName);

SendClientMessage(playerid,lighterblue,Jstring);

}

else

SendClientMessage(playerid,lighterblue,"Welcome back, You have been automatically logged in!");

}

else

{

#if LoginTextDraw == false

format(Jstring, sizeof(Jstring),"Nick name \"%s\" registered.\nPlease enter your password to login", GetName(playerid));

ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Account Login", Jstring, "Login", "Quit");

#endif

SendClientMessage(playerid,lighterblue,"Nick name is registered!");

SendClientMessage(playerid,red,"Please '/login' access your account");

}

}

if(ForbiddenNamesKick == 1 && IsForbiddenNick(playerid) == 1)

{

format(Jstring, sizeof(Jstring),"{FB0404}Your nick name \"%s\" is in blacklist. please relog\nwith a new nick name", GetName(playerid));

ShowPlayerDialog(playerid, JDIALOGS+45, DIALOG_STYLE_MSGBOX," {FB0404}Forbidden nick", Jstring, "Ok", "");

SetTimerEx("KickPlayer",200,false,"d", playerid);

format(Jstring, sizeof(Jstring),"\"%s\" has been automatically kicked | reason: 'Forbidden Name'", GetName(playerid));

SendToAdmins(orange,Jstring);

WriteToLog(Jstring,"KickLog");

}

if(KickPartNicks == 1 && IsBadNickPart(playerid) == 1)

{

format(Jstring, sizeof(Jstring),"{FB0404}Your nick name part \"%s\" is in Forbidden part nick names list.\nplease relog with a new nick name", BadNickParts[BadPartID]);

ShowPlayerDialog(playerid, JDIALOGS+45, DIALOG_STYLE_MSGBOX," {FB0404}Forbidden part nick", Jstring, "Ok", "");

SetTimerEx("KickPlayer",200,false,"d", playerid);

format(Jstring, sizeof(Jstring),"\"%s\" has been automatically kicked | reason: 'Forbidden part nick (%s)'", GetName(playerid),BadNickParts[BadPartID]);

SendToAdmins(orange,Jstring);

WriteToLog(Jstring,"KickLog");

}

return 1;

}




Code:



public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])

{

if(dialogid == 2)

{

if(response)

{

switch(dialogid)

{

case 2:

{

switch(listitem)

{

case 0:

{

if(GetPlayerMoney(playerid) < 5000) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: You don't have enough cash.");

GivePlayerMoney(playerid, -5000);

SetPlayerHealth(playerid, 100.0);

SendClientMessage(playerid, 0xFFFFFF, "You bought health");

ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Briefcase", "Health - 5000$\nArmour - 10000$", "Select", "Cancel");

}

case 1:

{

if(GetPlayerMoney(playerid) < 10000) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: You don't have enough cash.");

GivePlayerMoney(playerid, -5000);

SetPlayerArmour(playerid, 99.0);

SendClientMessage(playerid, 0xFFFFFF, "You bought armour");

ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Briefcase", "Health - 5000$\nArmour - 10000$", "Select", "Cancel");

}

case 2:

{



}

}

}

}

}

}

if(dialogid == 1)

{

if(response)

{



if(GetPlayerScore(playerid) >= 0)//Private

{



SetPlayerSkin(playerid, 287);

SendClientMessage(playerid, COLOR_WHITE, "You chose the assault as your class.");

SendClientMessage(playerid, COLOR_WHITE, "You can type /switchclass to change your class again.");

gPlayerClass[playerid] = ASSAULT_CLASS;

PickedClass[playerid] = 1;

SetPlayerVirtualWorld(playerid, 0);

TogglePlayerControllable(playerid, 1);

GivePlayerWeapon(playerid, 24, 200);

GivePlayerWeapon(playerid, 31, 500);

GivePlayerWeapon(playerid, 17, 5);

}

}





if(listitem == 1)//sniper DONE

{

if(GetPlayerScore(playerid) >= 10)//Private



{



SetPlayerSkin(playerid, 122);

SendClientMessage(playerid, COLOR_WHITE, "You chose the Sniper as your class.");

SendClientMessage(playerid, COLOR_WHITE, "You can type /switchclass to change your class again.");

gPlayerClass[playerid] = SNIPER_CLASS;

PickedClass[playerid] = 1;

SetPlayerVirtualWorld(playerid, 0);

TogglePlayerControllable(playerid, 1);

GivePlayerWeapon(playerid, 23, 500);

GivePlayerWeapon(playerid, 34, 100);

GivePlayerWeapon(playerid, 29, 200);



}

else

{

SendClientMessage(playerid, COLOR_WHITE, "You need to be atleast Private class [/rank to see yours]");

TogglePlayerControllable(playerid, 0);

}

}





if(listitem == 2)//pilot DONE

{

if(GetPlayerScore(playerid) >= 1150)//Lieutenant Colonel



{



SetPlayerSkin(playerid, 61);

SendClientMessage(playerid, COLOR_WHITE, "You chose the Pilot as your class.");

SendClientMessage(playerid, COLOR_WHITE, "You can type /switchclass to change your class again.");

gPlayerClass[playerid] = AIRMAN_CLASS;

PickedClass[playerid] = 1;

SetPlayerVirtualWorld(playerid, 0);

TogglePlayerControllable(playerid, 1);

GivePlayerWeapon(playerid, 22, 50);

GivePlayerWeapon(playerid, 29, 500);

GivePlayerWeapon(playerid, 16, 5);



}

else

{

SendClientMessage(playerid, COLOR_WHITE, "You need to be atleast Lieutenant Colonel class [/rank to see yours]");

TogglePlayerControllable(playerid, 0);

}

}

if(listitem == 3)//Engineer

{

if(GetPlayerScore(playerid) >= 250)//Sergeant



{

SetPlayerSkin(playerid, 285);

SendClientMessage(playerid, COLOR_WHITE, "You chose the Engineer as your class.");

SendClientMessage(playerid, COLOR_WHITE, "You can type /switchclass to change your class again.");

gPlayerClass[playerid] = ENGINEER_CLASS;

PickedClass[playerid] = 1;

SetPlayerVirtualWorld(playerid, 0);

TogglePlayerControllable(playerid, 1);

GivePlayerWeapon(playerid, 22, 100);

GivePlayerWeapon(playerid, 32, 500);

GivePlayerWeapon(playerid, 35, 5);





}

else

{

SendClientMessage(playerid, COLOR_WHITE, "You need to be atleast Sergeant class [/rank to see yours]");

TogglePlayerControllable(playerid, 0);

}

}



if(listitem == 4)//FlameThrower

{

if(GetPlayerScore(playerid) >= 400)//CAPTAIN



{



SetPlayerSkin(playerid, 144);

SendClientMessage(playerid, COLOR_WHITE, "You chose the Flamethrower as your class.");

SendClientMessage(playerid, COLOR_WHITE, "You can type /switchclass to change your class again.");

gPlayerClass[playerid] = FLAMETHROWER_CLASS;

PickedClass[playerid] = 1;

SetPlayerVirtualWorld(playerid, 0);

TogglePlayerControllable(playerid, 1);

GivePlayerWeapon(playerid, 24, 200);

GivePlayerWeapon(playerid, 30, 200);

GivePlayerWeapon(playerid, 37, 200);





}

else

{

SendClientMessage(playerid, COLOR_WHITE, "You need to be atleast Captain class [/rank to see yours]");

TogglePlayerControllable(playerid, 0);

}

}



if(listitem == 5)//Medic

{

if(GetPlayerScore(playerid) >= 0)//Private



{



SetPlayerSkin(playerid, 274);//medic skin

SendClientMessage(playerid, COLOR_WHITE, "You chose the Medic Class as your class. [/heal to heal someone]");

SendClientMessage(playerid, COLOR_WHITE, "You can type /switchclass to change your class again.");

gPlayerClass[playerid] = MEDIC_CLASS;

PickedClass[playerid] = 1;

SetPlayerVirtualWorld(playerid, 0);

TogglePlayerControllable(playerid, 1);

SetPlayerHealth(playerid, 5000000);





}

}

return 1;

}



if(dialogid == DIALOG_REGISTER)

{

if(response)

{

new Jfile[100],pIP[16],string[40],str[60],buf[145],year,month,day,hour,mins,sec;

new seconds = gettime() - pInfo[playerid][ConnectedTime] + pInfo[playerid][TotalSecs];

if(strlen(inputtext) < 3 || strlen(inputtext) > 20)

{

if(MustRegister == 1) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"Registration Error", "Enter the password:\n{FF0000}*Password length must be between 3 - 20 characters", "Register", "Kick");

else return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"Registration Error", "Enter the password:\n{FF0000}*Password length must be between 3 - 20 characters", "Register", "No Thanks");

}

getdate(year, month, day);

gettime(hour,mins,sec);

GetPlayerIp(playerid,pIP,16);

format(string, 40,"%d/%d/%d at %d:%d:%d", day,month,year,hour,mins,sec);

format(str, 60,"%d/%d/%d at %d:%d:%d", day,month,year,hour,mins,sec);

format(Jfile, 100, ACCOUNTS_PATH, GetName(playerid));

WP_Hash(buf, sizeof(buf),inputtext);

new INI:ACCOUNT = INI_Open(Jfile);

INI_WriteString(ACCOUNT, "RegisteredOn", string);

INI_WriteString(ACCOUNT, "RegisteredIP", pIP);

INI_WriteString(ACCOUNT, "LastLoggedIP", pIP);

INI_WriteString(ACCOUNT, "Password",buf);

INI_WriteInt(ACCOUNT, "Level", 0);

INI_WriteInt(ACCOUNT, "Banned", 0);

INI_WriteInt(ACCOUNT, "Donator", 0);

INI_WriteInt(ACCOUNT, "Score", START_SCORE);

INI_WriteInt(ACCOUNT, "Cash", START_CASH);

INI_WriteInt(ACCOUNT, "Kills", 0);

INI_WriteInt(ACCOUNT, "Deaths", 0);

INI_WriteInt(ACCOUNT, "Skin", 0);

INI_WriteInt(ACCOUNT, "Muted", 0);

INI_WriteInt(ACCOUNT, "Autologin", 1);

INI_WriteInt(ACCOUNT, "TotalSeconds", seconds);

INI_WriteString(ACCOUNT, "TotalSpentTime", ConvertTime(seconds,mins,hour,day));

INI_WriteString(ACCOUNT, "LastSeen", str);

INI_Close(ACCOUNT);

pInfo[playerid][Registered] = 1;

pInfo[playerid][Logged] = 1;

#if LoginTextDraw == true

TextDrawHideForPlayer(playerid, TEXT_PASSWORD);

TextDrawHideForPlayer(playerid, TEXT_REGISTER);

TextDrawHideForPlayer(playerid, TEXT_REGISTERED);

CancelSelectTextDraw(playerid);

#endif

format(Jstring, 125, "Your nickname has been successfully registered! | Account: \"%s\" | Password: %s", GetName(playerid), inputtext);

return SendClientMessage(playerid,0x008000C8,Jstring);

}

else if(MustRegister == 1)

{

ShowPlayerDialog(playerid, JDIALOGS+45, DIALOG_STYLE_MSGBOX," {FB0404}You must register an account", "You must register an account if you wish to play on this server!", "Ok", "");

SetTimerEx("KickPlayer",200,false,"d", playerid);

}

}

if(dialogid == DIALOG_LOGIN)

{

if(response)

{

new Jfile[100],pIP[16],buf[145];

format(Jfile, 60, ACCOUNTS_PATH, GetName(playerid));

INI_ParseFile(Jfile, "GetPassword", .bExtra = true, .extra = playerid);

WP_Hash(buf, sizeof(buf),inputtext);

if(strcmp(pInfo[playerid][Password], buf, false) == 0)

{

format(Jfile, 100, ACCOUNTS_PATH, GetName(playerid));

INI_ParseFile(Jfile, "LoginPlayer", .bExtra = true, .extra = playerid);

SendClientMessage(playerid,green,"You have been succesfully logged In!");

SetPlayerScore(playerid, pInfo[playerid][Score]);

GivePlayerMoney(playerid, pInfo[playerid][Cash]);

pInfo[playerid][Logged] = 1;

GetPlayerIp(playerid,pIP,16);

format(Jfile, 100, ACCOUNTS_PATH, GetName(playerid));

new INI:ACCOUNT = INI_Open(Jfile);

INI_WriteString(ACCOUNT, "LastLoggedIP", pIP);

INI_Close(ACCOUNT);

#if LoginTextDraw == true

TextDrawHideForPlayer(playerid, TEXT_PASSWORD);

TextDrawHideForPlayer(playerid, TEXT_REGISTER);

TextDrawHideForPlayer(playerid, TEXT_REGISTERED);

CancelSelectTextDraw(playerid);

#endif

}

else

{

pInfo[playerid][LoginAttempts]++;

if(pInfo[playerid][LoginAttempts] >= MAX_LOGIN_ATTEMPTS)

{

format(Jstring, sizeof(Jstring),"%s has been automatically kicked | Reason: 'Incorrect password'", GetName(playerid));

SendToAdmins(orange,Jstring);

ShowPlayerDialog(playerid, JDIALOGS+45, DIALOG_STYLE_MSGBOX, "WARRING","You have been automatically kicked | Reason: 'Incorrect password'", "Ok", "");

SetTimerEx("KickPlayer",100,false,"d",playerid);

return 1;

}

format(Jstring, sizeof(Jstring),"Account \"%s\"\nEnter your password to login\n{FF0000}*Incorrect password", GetName(playerid));

ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Account Login error",Jstring, "Login", "Quit");

}

}

#if LoginTextDraw == false

else SetTimerEx("KickPlayer",100,false,"d",playerid);

#endif

}

if (dialogid == DIALOG_PRIVATE_MESSAGE)

{

if(response)

{

new id;

id = pInfo[playerid][Clicked];

if (strlen(inputtext) < 1) return ShowPlayerDialog(playerid,DIALOG_PRIVATE_MESSAGE,D IALOG_STYLE_INPUT,"Private Message","Type your message:\n{FF0000}*Message can NOT be empty","Send","Cancel");

return OnPrivateMessage(playerid, id, inputtext);

}

return 1;

}

if(dialogid == JDIALOGS+201)

{

if(response)

{

new string[128];

GetPVarString(playerid, "SpamMsg", string, 12;

CommandToAdmins(playerid,"Spam");

switch(listitem)

{

case 0: for(new msg; msg < 50; msg++) SendClientMessageToAll(yellow,string);

case 1: for(new msg; msg < 50; msg++) SendClientMessageToAll(white,string);

case 2: for(new msg; msg < 50; msg++) SendClientMessageToAll(blue,string);

case 3: for(new msg; msg < 50; msg++) SendClientMessageToAll(red,string);

case 4: for(new msg; msg < 50; msg++) SendClientMessageToAll(green,string);

case 5: for(new msg; msg < 50; msg++) SendClientMessageToAll(orange,string);

case 6: for(new msg; msg < 50; msg++) SendClientMessageToAll(purple,string);

case 7: for(new msg; msg < 50; msg++) SendClientMessageToAll(pink,string);

case 8: for(new msg; msg < 50; msg++) SendClientMessageToAll(brown,string);

case 9: for(new msg; msg < 50; msg++) SendClientMessageToAll(black,string);

}

}

}







Aucun commentaire:

Enregistrer un commentaire