Dialog won't show on spawn -
Gerira Gaijin - 17.01.2012
Well, I'm editing a FS, which is used for updates to some stuff, as I don't have access to the .pwn of the gamemode. Anyway, I want that if the player is an admin, a dialog would show for him telling him to set up a PIN number, or if he has one to input it. It's an AdminPIN system.
But the dialog won't show.
pawn Код:
public OnPlayerSpawn(playerid)
{
if(LoginSpawn[playerid] == true)
{
if(pInfo[playerid][pAdminLevel] > 0){
SetTimerEx("AdminVerify", 5000, false, "i", playerid);
return 0;
}
}
return 1;
}
public AdminVerify(playerid)
{
if(pInfo[playerid][pAdminPIN] == 0)
{
LoginSpawn[playerid] = false;
return ShowPlayerDialog(playerid,ADMINPIN_INPUT,DIALOG_STYLE_INPUT,"Set your administrator account PIN","Please enter an administrator PIN number, which you will use on every login (4 digit number only):","Set","");
}
LoginSpawn[playerid] = false;
return ShowPlayerDialog(playerid,ADMINPIN_DIALOG,DIALOG_STYLE_INPUT,"Enter administrator PIN","Please enter your administration PIN number:","Confirm","");
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == ADMINPIN_INPUT){
new pin;
if(!response) return Kick(playerid);
pin = strval(inputtext);
if(!IsNumeric(inputtext) || !strlen(inputtext) || pin < 1000 || pin > 9999) return ShowPlayerDialog(playerid,ADMINPIN_INPUT,DIALOG_STYLE_INPUT,"Set your administrator account PIN","Please enter an administrator PIN number, which you will use on every login (4 digit number only):","Set","");
pInfo[playerid][pAdminPIN] = strval(inputtext);
return 1;
}
if(dialogid == ADMINPIN_INPUT){
new pin;
if(!response) return Kick(playerid);
pin = strval(inputtext);
if(!IsNumeric(inputtext) || !strlen(inputtext) || pin < 1000 || pin > 9999) return ShowPlayerDialog(playerid,ADMINPIN_DIALOG,DIALOG_STYLE_INPUT,"Enter administrator PIN","Please enter your administration PIN number:","Confirm","");
if(strval(inputtext) != pInfo[playerid][pAdminPIN]) return Kick(playerid);
}
return 1;
}
This is how I load my variables:
pawn Код:
public LoadPlayer(playerid)
{
// Unload notes
format(pInfo[playerid][pNote1], 100, "");
format(pInfo[playerid][pNote2], 100, "");
format(pInfo[playerid][pNote3], 100, "");
format(pInfo[playerid][pNote4], 100, "");
format(pInfo[playerid][pNote5], 100, "");
pInfo[playerid][fsFaction] = -1;
pInfo[playerid][pParkingTicket1] = INVALID_PARKING_TICKET;
pInfo[playerid][pAdminLevel] = 0;
pInfo[playerid][pAdminPIN] = 0;
// Unload variables
sirenvehid[playerid] = 0;
PlayerUsingSiren[playerid] = false;
sirenobjid[playerid] = 0;
LoginSpawn[playerid] = true;
new usfile[128];
format(usfile, sizeof(usfile), "Accounts/%s.ini", pName[playerid]);
new File:UserFile = fopen(usfile, io_read); // Open the file
new key[256], val[256];
new Data[256];
if(UserFile){
while (fread(UserFile, Data, sizeof(Data)))
{ // LOAD FROM ORIGIONAL USERFILES
key = ini_GetKey(Data);
if(strcmp(key ,"AdminLevel" ,true ) == 0) { val = ini_GetValue(Data); pInfo[playerid][pAdminLevel] = strval(val);}
if(strcmp(key ,"Faction" ,true ) == 0) { val = ini_GetValue(Data); pInfo[playerid][fsFaction] = strval(val);}
}
fclose(UserFile);
}
format(usfile, sizeof(usfile), "AccountsUpdate/%s.ini", pName[playerid]);
UserFile = fopen(usfile, io_read); // Open the file
if(UserFile){
while (fread(UserFile, Data, sizeof(Data)))
{ // LOAD FROM NEW USERFILES FOR UPDATES
key = ini_GetKey(Data);
if(strcmp(key ,"AdminPIN" ,true ) == 0) { val = ini_GetValue(Data); pInfo[playerid][pAdminPIN] = strval(val);}
if(strcmp(key ,"Note1" ,true ) == 0) { val = ini_GetValue(Data); strmid(pInfo[playerid][pNote1],val,0,strlen(val)-1,32);}
if(strcmp(key ,"Note2" ,true ) == 0) { val = ini_GetValue(Data); strmid(pInfo[playerid][pNote2],val,0,strlen(val)-1,32);}
if(strcmp(key ,"Note3" ,true ) == 0) { val = ini_GetValue(Data); strmid(pInfo[playerid][pNote3],val,0,strlen(val)-1,32);}
if(strcmp(key ,"Note4" ,true ) == 0) { val = ini_GetValue(Data); strmid(pInfo[playerid][pNote4],val,0,strlen(val)-1,32);}
if(strcmp(key ,"Note5" ,true ) == 0) { val = ini_GetValue(Data); strmid(pInfo[playerid][pNote5],val,0,strlen(val)-1,32);}
if(strcmp(key ,"ParkingTicket1" ,true ) == 0) { val = ini_GetValue(Data); pInfo[playerid][pParkingTicket1] = strval(val);}
}
fclose(UserFile);
}
return 1;
}
It saves the PIN as "0", as I set it. But the dialog won't show, I have no idea why. Dialog ID's are 101, and 102.
Re: Dialog won't show on spawn -
Gerira Gaijin - 18.01.2012
Bump, anyone? Please?
Re: Dialog won't show on spawn -
thimo - 18.01.2012
You returned 0 i think thats the problem...
Re: Dialog won't show on spawn -
mineralo - 18.01.2012
pawn Код:
public AdminVerify(playerid)
{
if(pInfo[playerid][pAdminPIN] == 0)
{
LoginSpawn[playerid] = false;
ShowPlayerDialog(playerid,ADMINPIN_INPUT,DIALOG_STYLE_INPUT,"Set your administrator account PIN","Please enter an administrator PIN number, which you will use on every login (4 digit number only):","Set","");
}
else
{
LoginSpawn[playerid] = false;
ShowPlayerDialog(playerid,ADMINPIN_DIALOG,DIALOG_STYLE_INPUT,"Enter administrator PIN","Please enter your administration PIN number:","Confirm","");
}
return 1;
}
try this whithout returns
Re: Dialog won't show on spawn -
Gerira Gaijin - 18.01.2012
Okay, it worked. But now it won't kick a player if he types in a wrong password :/
pawn Код:
if(dialogid == ADMINPIN_INPUT){
if(!response) return Kick(playerid);
if(!strlen(inputtext)) return ShowPlayerDialog(playerid,ADMINPIN_DIALOG,DIALOG_STYLE_INPUT,"Enter administrator PIN","Please enter your administration PIN number:","Confirm","");
if(strlen(inputtext) > 32) return ShowPlayerDialog(playerid,ADMINPIN_DIALOG,DIALOG_STYLE_INPUT,"Enter administrator PIN","Please enter your administration PIN number:","Confirm","");
if(strcmp(inputtext, pInfo[playerid][pAdminPIN], false)) return Kick(playerid);
return 1;
}