small bug -
mineralo - 02.01.2012
hi, I use dudb date base, I made login and register system, and wor great but if somebody registered log in server and if he/she push on cancel he/she get kick ( how I wanted ) but all his/her stuff get delete, what to do?
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOG_LOG:
{
if(!response) return Kick(playerid);
if(response)
{
if(udb_CheckLogin(PlayerName(playerid),inputtext))
{
LoadPlayer(playerid);
Logged[playerid]=true;
SendClientMessage(playerid,COLOR_GREEN,"( ! ) Access granted ! You're now logged in !");
return 1;
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOG, DIALOG_STYLE_INPUT,"Welcome to Spring Wood RPG","You have entered an incorrect password.\nType your password below to login.","Login","Quit");
}
}
}
case DIALOG_REG:
{
if(!response) return Kick(playerid);
if(response)
{
if(udb_Create(PlayerName(playerid),inputtext))
{
RemoveJob(playerid);
SetJob(playerid,1);
ResetPlayerECash(playerid);
GivePlayerECash(playerid, 25);
SavePlayer(playerid);
ShowPlayerDialog(playerid, DIALOG_LOG, DIALOG_STYLE_INPUT,"Welcome to Spring Wood RPG","You have successfully registered !\nType your password below to login.","Login","Quit");
return 1;
}}}}
return 1;
}
Re: small bug -
Thunderbolt - 02.01.2012
Try this:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOG_LOG:
{
if(!response) return Kick(playerid);
if(response)
{
if(udb_CheckLogin(PlayerName(playerid),inputtext))
{
LoadPlayer(playerid);
Logged[playerid]=true;
SendClientMessage(playerid,COLOR_GREEN,"( ! ) Access granted ! You're now logged in !");
return 1;
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOG, DIALOG_STYLE_INPUT,"Welcome to Spring Wood RPG","You have entered an incorrect password.\nType your password below to login.","Login","Quit");
}
}
}
case DIALOG_REG:
{
if(!response)
{
SavePlayer(playerid);
Kick(playerid);
}
if(response)
{
if(udb_Create(PlayerName(playerid),inputtext))
{
RemoveJob(playerid);
SetJob(playerid,1);
ResetPlayerECash(playerid);
GivePlayerECash(playerid, 25);
SavePlayer(playerid);
ShowPlayerDialog(playerid, DIALOG_LOG, DIALOG_STYLE_INPUT,"Welcome to Spring Wood RPG","You have successfully registered !\nType your password below to login.","Login","Quit");
return 1;
}}}}
return 1;
}
What I changed is, the form of !response and added SavePlayer(playerid); to save the DATA - Then kick.
Re: small bug -
BlackWolf120 - 02.01.2012
yep, that should work.
In case it shouldnt, delay the kick with a timer so the entered data is saved first before the kick.
And please, indend ur code better next time, trust me, it is more important then u think it is.
At the beginning i also didnt give a f*** about it but some weeks ago i had to go throught 100k script lines and fix all the code indendation to make a "growing" script readable.
Do it from the beginning on and prevent a lot of work later
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOG_LOG:
{
if(!response)return Kick(playerid);
if(response)
{
if(udb_CheckLogin(PlayerName(playerid),inputtext))
{
LoadPlayer(playerid);
Logged[playerid]=true;
SendClientMessage(playerid,COLOR_GREEN,"( ! ) Access granted ! You're now logged in !");
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOG, DIALOG_STYLE_INPUT,"Welcome to Spring Wood RPG","You have entered an incorrect password.\nType your password below to login.","Login","Quit");
}
}
}
case DIALOG_REG:
{
if(!response)
{
SavePlayer(playerid);
Kick(playerid);
}
if(response)
{
if(udb_Create(PlayerName(playerid),inputtext))
{
RemoveJob(playerid);
SetJob(playerid,1);
ResetPlayerECash(playerid);
GivePlayerECash(playerid, 25);
SavePlayer(playerid);
ShowPlayerDialog(playerid, DIALOG_LOG, DIALOG_STYLE_INPUT,"Welcome to Spring Wood RPG","You have successfully registered !\nType your password below to login.","Login","Quit");
}
}
}
}
return 1;
}