07.04.2011, 01:52
can someone fix this so that the dialog actually shows wen the player connecps please?
PPLLEEAASSEE HHEELLPP!!!!!!!!!!!!!!!!!!!!
pawn Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#include <YSI/y_ini>
#include <foreach>
native WP_Hash(buffer[], len, const str[]); //Whirlpool native
#define RED 0xFF0000FF
#define USER_FILE "MAdmin/Users/%s.ini"
#define limegreen 0x00FF00FF
#define blue 0x375FFFFF
enum gPInfo
{
Logged,
Regged,
Level,
Score,
Cash,
Deaths,
Kills,
Muted,
Jailed,
};
new PInfo[MAX_PLAYERS][gPInfo];
main()
{
print("MADMIN2 LOADED!");
}
public OnFilterScriptInit()
{
print("MADMIN2 LOADED!");
return 1;
}
public OnPlayerConnect(playerid)
{
PInfo[playerid][Kills] = 0;
PInfo[playerid][Deaths] = 0;
new name[25], file[128]; //Create our variables
GetPlayerName(playerid,name,sizeof(name)); //Store the player's name in the name variable
format(file,sizeof(file), USER_FILE,name); //Formatting where the file is
if(fexist(file)) //If the player's userfile IS found
{
SendClientMessage(playerid,limegreen,"You are registered, please login");
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered", "Type your password below", "Login", "Quit");
PInfo[playerid][Regged] = 1;
PInfo[playerid][Logged] = 0;
}
if(!fexist(file)) //If the userfile is NOT found. Note the ! means "no"
{
SendClientMessage(playerid,limegreen,"You are not registered, please register");
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "You are not registered", "Type your password below", "Register", "Quit"); //It will show the player a dialog. With id 1.
PInfo[playerid][Regged] = 0;
PInfo[playerid][Logged] = 0;
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new name[25], file[128]; //Create our variables
GetPlayerName(playerid,name,sizeof(name)); //Store the player's name in the name variable
format(file,sizeof(file), USER_FILE,name); //Formatting where the file is
PInfo[playerid][Score] = GetPlayerScore(playerid);
PInfo[playerid][Cash] = GetPlayerMoney(playerid);
if(fexist(file)) //If the player's userfile IS found
{
new INI:Acc = INI_Open(file); //Opens a new INI file. file is formatted above.
INI_WriteInt(Acc,"Regged",1);
INI_WriteInt(Acc,"Level",PInfo[playerid][Level]);
INI_WriteInt(Acc,"Score",PInfo[playerid][Score]);
INI_WriteInt(Acc,"Cash",PInfo[playerid][Cash]);
INI_WriteInt(Acc,"Kills",PInfo[playerid][Kills]);
INI_WriteInt(Acc,"Deaths",PInfo[playerid][Deaths]);
INI_Close(Acc); //Closes the file
}
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
PInfo[playerid][Deaths] ++;
PInfo[killerid][Kills] ++;
return 1;
}
public OnPlayerText(playerid, text[])
{
if(PInfo[playerid][Muted] == 1)
{
SendClientMessage(playerid, RED, "You are muted. STFU!");
return 0;
}
return 0;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 1) //The register dialog
{
new name[25], file[128]; //Variables
GetPlayerName(playerid, name, sizeof(name)); //Name
format(file, sizeof(file),USER_FILE, name); //File
if (!strlen(inputtext)) return //If there is nothing in the textbox
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "You are not registered", "Type your password below", "Register"," ");
new INI:Acc = INI_Open(file); //Opens a new INI file. file is formatted above.
INI_WriteString(Acc, "Password", inputtext); //Writes the password
INI_WriteInt(Acc,"Logged",1); //Sets all the variables.
INI_WriteInt(Acc,"Regged",1);
INI_WriteInt(Acc,"Level",0);
INI_WriteInt(Acc,"VIP",0);
INI_WriteInt(Acc,"Score",0);
INI_WriteInt(Acc,"Cash",0);
INI_WriteInt(Acc,"Kills",0);
INI_WriteInt(Acc,"Deaths",0);
INI_Close(Acc); //Closes the file
SendClientMessage(playerid,limegreen,"You have successfully registered!");
PInfo[playerid][Regged] = 1;
PInfo[playerid][Logged] = 1;
}
else if(dialogid == 2)
{
new name[MAX_PLAYERS], file[128], string[70],pass[128];
GetPlayerName(playerid,name,sizeof(name));
format(file,sizeof file,USER_FILE,name);
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered", "Type your password below", "Login", "Quit");
INI_ParseFile(file, "LoginAcc", false, true, playerid, true, false); //This will call a function to parse "file"GetPVarString(playerid,"pPass",pass,sizeof(pass)); //Gets the player variable
if(strcmp(inputtext, pass, false)) // If the inputtext and the password in the file DONT match
{
SendClientMessage(playerid, RED, "Incorrect Password!");
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered", "Type your password below", "Login", "Quit");
}
else //otherwise
{
PInfo[playerid][Logged] = 1;
PInfo[playerid][Regged] = 1;
new INI:Acc = INI_Open(file);
INI_WriteInt(Acc,"Logged",1);
INI_Close(Acc);
if(PInfo[playerid][Level] == 0) SendClientMessage(playerid,limegreen,"You have logged in as a Normal Player");
if(PInfo[playerid][Level] == 1) SendClientMessage(playerid,limegreen,"You have logged in as a Level 1 Admin");
if(PInfo[playerid][Level] == 2) SendClientMessage(playerid,limegreen,"You have logged in as a Level 2 Admin");
if(PInfo[playerid][Level] == 3) SendClientMessage(playerid,limegreen,"You have logged in as a Level 3 Admin");
if(PInfo[playerid][Level] == 4) SendClientMessage(playerid,limegreen,"You have logged in as a Level 4 Admin");
if(PInfo[playerid][Level] == 5) SendClientMessage(playerid,limegreen,"You have logged in as a Level 5 Admin");
SendClientMessage(playerid,limegreen,string);
GivePlayerMoney(playerid,PInfo[playerid][Cash]);
SetPlayerScore(playerid,PInfo[playerid][Score]);
}
}
return 1;
}
forward LoginAcc(playerid, name[ ], value[ ]); //Always forward new functions
public LoginAcc(playerid, name[ ], value[ ]) //The function here is to login the account that just connected
{
if(!strcmp(name, "Password", false))
{
SetPVarString(playerid,"pPass",value); //Sets the player variable to what is after Password
}
if(!strcmp(name, "Level", false))
{
PInfo[playerid][Level] = strval(value); //This Level variable is set to the value in the userfile
}
if(!strcmp(name, "Cash", false))
{
PInfo[playerid][Cash] = strval(value);
}
if(!strcmp(name, "Score", false))
{
PInfo[playerid][Score] = strval(value);
}
if(!strcmp(name, "Kills", false))
{
PInfo[playerid][Kills] = strval(value);
}
if(!strcmp(name, "Deaths", false))
{
PInfo[playerid][Deaths] = strval(value);
}
return 1;
}
stock IsValidSkin(SkinID)
{
if((SkinID == 0)||(SkinID == 7)||(SkinID >= 9 && SkinID <= 41)||(SkinID >= 43 && SkinID <= 64)||(SkinID >= 66 && SkinID <= 73)||(SkinID >= 75 && SkinID <= 85)||(SkinID >= 87 && SkinID <= 118)||(SkinID >= 120 && SkinID <= 148)||(SkinID >= 150 && SkinID <= 207)||(SkinID >= 209 && SkinID <= 264)||(SkinID >= 274 && SkinID <= 288)||(SkinID >= 290 && SkinID <= 299)) return true;
else return false;
}
PPLLEEAASSEE HHEELLPP!!!!!!!!!!!!!!!!!!!!