easyDialog -
v4yne1 - 16.03.2019
i made log/reg system by using easyDialog.inc and by reading this
https://sampforum.blast.hk/showthread.php?tid=524344 tutorial as a guide.
now, my problem is that everything is bugged af. when i want to press quit, server doesnt kick me. it just continues to another dialog.
for example, I have an intro dialog to say hi to the player and etc. if the player wants to continue with registration process he should press 'Go'
Код:
public OnPlayerConnect(playerid)
{
TogglePlayerSpectating(playerid, 1);
if(fexist(UserPath(playerid)))
{
LoginAttempts[playerid] = 0;
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
Dialog_Show(playerid, DialogLogin, DIALOG_STYLE_PASSWORD, "Login", "Type in your password below in order to login.", "Login", "Quit");
}
else
{
Dialog_Show(playerid, DialogIntro, DIALOG_STYLE_MSGBOX, "Hello", "Welcome to our server. Press 'Go' in order to start registration!", "Go", "Quit");
}
return 1;
}
and if the player decides to leave he should press quit, of course...
but in my situation both of the buttons continue with dialogs.
dialogs dont even check my input for password, age, gender... I can just spam enter on my keyboard without any input until it stops on Age dialog - where of course nothing happens.
is the easyDialog.inc bugged or is it just my bad?
registration process should go like this: intro dialog > password > gender > age
btw thanks a lot guys for helping me, i hope im not annoying
here is my code:
Код:
Dialog:DialogAge(playerid, dialogid, response, listitem, inputtext[])
{
if(!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) Dialog_Show(playerid, DialogAge, DIALOG_STYLE_INPUT, "Choose your character's age [3/3]", "Type in your age!\nValid age: "#MIN_AGE" - "#MAX_AGE"", "End", "Quit");
if(strlen(inputtext))
{
new age = strval(inputtext);
if(age < MIN_AGE || age > MAX_AGE)
{
Dialog_Show(playerid, DialogAge, DIALOG_STYLE_INPUT, "Choose your character's age [3/3]", "Type in your age!\nValid age: "#MIN_AGE" - "#MAX_AGE"", "End", "Quit");
}
else
{
PlayerInfo[playerid][Age] = age;
new string[64];
format(string, sizeof(string), ""SERVER"Your age is %d", age);
SendClientMessage(playerid, -1, string);
SaveAccountStats(playerid);
GivePlayerMoney(playerid, STARTING_MONEY);
SendClientMessage(playerid, -1, ""SERVER"You got "#STARTING_MONEY" as starting money!");
}
}
}
return 1;
}
Dialog:DialogGender(playerid, dialogid, response, listitem, inputtext[])
{
if(!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext))
{
Dialog_Show(playerid, DialogGender, DIALOG_STYLE_INPUT, "Choose your character's gender [2/3]", "Type in your gender!\nValid genders: 'male' ; 'female'", "Next", "Quit");
}
if (!strcmp(inputtext, "male"))
{
PlayerInfo[playerid][Gender] = 1;
SendClientMessage(playerid, -1, "You are a male");
Dialog_Show(playerid, DialogAge, DIALOG_STYLE_INPUT, "Choose your character's age [3/3]", "Type in your age!\nValid age: "#MIN_AGE" - "#MAX_AGE"", "End", "Quit");
}
else if (!strcmp(inputtext, "female"))
{
PlayerInfo[playerid][Gender] = 2;
SendClientMessage(playerid, -1, "You are a female");
Dialog_Show(playerid, DialogAge, DIALOG_STYLE_INPUT, "Choose your character's age [3/3]", "Type in your age!\nValid age: "#MIN_AGE" - "#MAX_AGE"", "End", "Quit");
}
else
{
return Dialog_Show(playerid, DialogGender, DIALOG_STYLE_INPUT, "Choose your character's gender [2/3]", "Type in your gender!\nValid genders: 'male' ; 'female'", "Next", "Quit");
}
}
return 1;
}
Dialog:DialogPassword(playerid, dialogid, response, listitem, inputtext[])
{
if(!response) return Kick(playerid);
if(response)
{
if (!(MIN_PASSWORD_LENGTH <= strlen(inputtext) <= MAX_PASSWORD_LENGTH))
{
Dialog_Show(playerid, DialogPassword, DIALOG_STYLE_PASSWORD, "Choose your password [1/3]", "You typed in an invalid password!", "Next", "Quit");
SendClientMessage(playerid, -1, "Invalid password length, must be between "#MIN_PASSWORD_LENGTH" - "#MAX_PASSWORD_LENGTH" characters.");
}
new hash[129];
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
WP_Hash(hash, sizeof(hash), inputtext);
INI_WriteString(File,"Password", hash);
INI_WriteInt(File,"Admin", 0);
INI_WriteInt(File,"Gender", 0);
INI_WriteInt(File,"Age", 0);
INI_WriteInt(File,"Money", 0);
INI_WriteFloat(File,"PosX", 0);
INI_WriteFloat(File,"PosY", 0);
INI_WriteFloat(File,"PosZ", 0);
INI_WriteInt(File,"InteriorID", 0);
INI_WriteInt(File,"Skin", 0);
INI_WriteInt(File,"Kills", 0);
INI_WriteInt(File,"Deaths", 0);
INI_Close(File);
pNewlyRegged[playerid] = true;
Dialog_Show(playerid, DialogGender, DIALOG_STYLE_INPUT, "Choose your character's gender [2/3]", "Type in your gender!\nValid genders: 'male' ; 'female'", "Next", "Quit");
}
return 1;
}
Dialog:DialogIntro(playerid, dialogid, response, listitem, inputtext[])
{
if(!response) return Kick(playerid);
if(response)
{
SendClientMessage(playerid, -1, "You accepted our rules and began registration process.");
Dialog_Show(playerid, DialogPassword, DIALOG_STYLE_PASSWORD, "Choose your password [1/3]", "Type in your password!\nBe careful!", "Next", "Quit");
}
return 1;
}
Re: easyDialog -
antixgaming - 16.03.2019
It is probably the script's fault.
Re: easyDialog -
v4yne1 - 16.03.2019
Quote:
Originally Posted by antixgaming
It is probably the script's fault.
|
you mean include's ?
Re: easyDialog -
antixgaming - 16.03.2019
Yes. I recommend that you use OnDialogResponse and ShowPlayerDialog. That's far more less confusing.
Re: easyDialog -
v4yne1 - 16.03.2019
i don't understand when to use 'case:' / 'switch' / 'if(dialogid == id)'
Re: easyDialog -
antixgaming - 16.03.2019
Look up to the tutorials. There are plenty of them.
Re: easyDialog -
v4yne1 - 16.03.2019
still can't get it
is it all the same? just matter of speed?
edit: let's look at my example, why would i use
switch for register and login dialog and
if for dialog age and gender
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_AGE)
{
TogglePlayerSpectating(playerid, false);
if(!response)
{
Kick(playerid); //If the player clicks the second button
}
else
{
if(strlen(inputtext))
{
new age = strval(inputtext);
if(age > 100 || age < 16) //If the age doesn't meet the requirements (change to whatever you want)
{
ShowPlayerDialog(playerid, DIALOG_AGE, DIALOG_STYLE_INPUT, "Age","How old is your character?\nYour character's age must be between 16 and 100.","Proceed","Quit");
}
else //If the player types a age that meets the requirements
{
PlayerInfo[playerid][pAge] = age; //Sets the player's age
new
string[ 64 ]
;
format(string, sizeof(string), "{3685BA}SERVER: {FFFFFF}You are %d years old.",age);
SendClientMessage(playerid, -1, string);
GivePlayerCash(playerid, 15000); //Gives a $15,000 ammount of starting cash
SaveAccountStats(playerid); //Saves the player's account stats
SpawnPlayer(playerid); //Spawns the player
SetTimer("SpectateFix", 350, false); //Fixes a bug that needs this timer in order to successfully use mSelection
}
}
else
{
return 0;
}
}
}
if(dialogid == DIALOG_SEX)
{
if(response)
{
PlayerInfo[playerid][pSex] = 1; // Male = 1
SendClientMessage(playerid, -1, "{3685BA}SERVER: {FFFFFF}You have set your character's gender. You are a male.");
ShowPlayerDialog(playerid, DIALOG_AGE, DIALOG_STYLE_INPUT, "Age","How old is your character?\nYour character's age must be between 16 and 100.","Proceed","Quit"); //After the sex selection, you're sent to the age selection dialog
}
else
{
PlayerInfo[playerid][pSex] = 2; //Female = 2
SendClientMessage(playerid, -1, "{3685BA}SERVER: {FFFFFF}You have set your character's gender. You are a female.");
ShowPlayerDialog(playerid, DIALOG_AGE, DIALOG_STYLE_INPUT, "Age","How old is your character?\nYour character's age must be between 16 and 100.","Proceed","Quit");//After the sex selection, you're sent to the age selection dialog
}
}
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid); //If the player clicks the second button
if(response) //If he clicks the first button
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registering","You have entered an invalid password.\nType your password below to register a new account.","Register","Quit"); //This happens if the user has input no password. You can add limits here.
new buf[129]; //Now we'll use our Whirlpool hashing
new INI:File = INI_Open(UserPath(playerid)); //Opening the user file
INI_SetTag(File,"data"); //Settings tags
WP_Hash(buf, sizeof(buf), inputtext); //Hashing the inputtext (password)
INI_WriteString(File,"Password", buf); //Writes a string, the password, hashed
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Skin",0);
INI_WriteInt(File,"Sex",0);
INI_WriteInt(File,"Age",0);
INI_WriteFloat(File,"Pos_x",0);
INI_WriteFloat(File,"Pos_y",0);
INI_WriteFloat(File,"Pos_z",0);
INI_WriteInt(File,"Deaths",0);
INI_WriteInt(File,"Kills",0);
INI_Close(File);
pNewlyRegged[playerid] = true; //Changing the value of our boolean
ShowPlayerDialog(playerid, DIALOG_SEX, DIALOG_STYLE_MSGBOX, "Sex","What is the gender of your character?","Male","Female"); //After the registration, you must select your gender
}
}
case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid ); //If the player clicks the second button
if( response )
{
new hashpass[129];
WP_Hash(hashpass,sizeof(hashpass),inputtext);
if(!strcmp(hashpass, PlayerInfo[playerid][pPass], false)) //Compares the inputtext to the player's pass, pPass.
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
TogglePlayerSpectating(playerid, false);
SetTimerEx("UnsetFirstSpawn", 5000, false, "i", playerid); //We're using this for other purposes, to fix a bug in skin selection (OnPlayerRequestClass)
Logged[ playerid ] = 1; //giving the 1 ("true") value to our variable "Logged"
GivePlayerCash(playerid, PlayerInfo[playerid][pCash]); //Gives the player the cash he has
SetSpawnInfo(playerid, 0 /*Because the player has no team*/, PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z], 1.0, -1, -1, -1, -1, -1, -1); //Sets the player's spawn information
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","You have entered an incorrect password.\nType your password below to login.","Login","Quit"); //If the player has entered an invalid password, he's prompted to retype his password
}
return 1;
}
}
}
return 1;
}
from tutorial
Re: easyDialog -
antixgaming - 16.03.2019
You don't have to use switch.
Re: easyDialog -
v4yne1 - 16.03.2019
ehh.. it was my bad.
my checkings for password, age, gender were fkd up. i fixed it. thanks though