21.08.2012, 06:12
So I'm starting that login and register system..
Here we go
Compiling error:
Here we go
pawn Код:
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define DIALOG_SUCCESS_1 3
#define DIALOG_SUCCESS_2 4
#define PATH "/Administration/Users/%s.ini"
//======================================
new PlayerInfo[MAX_PLAYERS][pInfo];
//======================================
enum pInfo
{
pPass,
pScore,
pCash,
pKills,
pDeaths,
}
//=======================================
public OnPlayerConnect(playerid)
{
new pname[MAX_PLAYER_NAME], string[39 + MAX_PLAYER_NAME];
SendClientMessage(playerid,COLOR_GREEN,"Welcome to *************");
return 1;
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Welcome to ****","Type your password below to login.","Login","Quit");
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Welcome to *****","Type your password below to register a new account.","Register","Quit");
}
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "%s has Joined the server.", pname);
SendClientMessageToAll(COLOR_CYAN, string);
return 1;
}
//=====================================================
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\nType your password below to register a new account.","Register","Quit");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"Player Saved Data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Score",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_Close(File);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,"Register Menu","You have been registered","Ok","");
}
}
case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COLOR_WHITE"Login Menu","You have been logged in to your account","Ok","");
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login Menu","Wrong Password\nType your password below to login into your account","Login","Quit");
}
return 1;
}
}
}
return 1;
}
//====================================================
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Password",PlayerInfo[playerid][pPass]);
INI_Int("Score",PlayerInfo[playerid][pScore]);
INI_Int("Cash",PlayerInfo[playerid][pCash]);
INI_Int("Kills",PlayerInfo[playerid][pKills]);
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
return 1;
}
stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),PATH,playername);
return string;
}
stock udb_hash(buf[]) {
new length=strlen(buf);
new s1 = 1;
new s2 = 0;
new n;
for (n=0; n<length; n++)
{
s1 = (s1 + buf[n]) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}
//===================================================
Код:
D:\SAMP\Server\SARP\gamemodes\SARP.pwn(40) : error 017: undefined symbol "pInfo" D:\SAMP\Server\SARP\gamemodes\SARP.pwn(40) : error 009: invalid array size (negative, zero or out of bounds) D:\SAMP\Server\SARP\gamemodes\SARP.pwn(61) : error 029: invalid expression, assumed zero D:\SAMP\Server\SARP\gamemodes\SARP.pwn(61 -- 62) : warning 215: expression has no effect D:\SAMP\Server\SARP\gamemodes\SARP.pwn(64) : warning 225: unreachable code D:\SAMP\Server\SARP\gamemodes\SARP.pwn(88) : error 001: expected token: "-string end-", but found "-identifier-" D:\SAMP\Server\SARP\gamemodes\SARP.pwn(88) : warning 215: expression has no effect D:\SAMP\Server\SARP\gamemodes\SARP.pwn(88) : error 001: expected token: ";", but found "-string-" D:\SAMP\Server\SARP\gamemodes\SARP.pwn(88) : warning 215: expression has no effect D:\SAMP\Server\SARP\gamemodes\SARP.pwn(88) : error 001: expected token: "-string end-", but found "-identifier-" D:\SAMP\Server\SARP\gamemodes\SARP.pwn(88) : fatal error 107: too many error messages on one line Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 7 Errors.