Need help with my registration + login system
#1

Hey guys,

Well, I just make a registratie + auto login system, I fixed a lot of errors + warnings, but by this errors I dont have any idea how to fix this...
Oh and, when I just type /register without password my account has been registered and auto logged in, but thats not cool, Players must be type a password by 3 to 20 letters.
If they do that dont they must be get a message: Sorry, you must be type a password with 3 to 20 letters..
Or anything, Understand?


This are the errors that I have:

Quote:

C:\Users\Edward\Desktop\Samp\pawno\reg.pwn(165) : error 017: undefined symbol "filename"
C:\Users\Edward\Desktop\Samp\pawno\reg.pwn(167) : error 017: undefined symbol "INI_CheckLogin"
C:\Users\Edward\Desktop\Samp\pawno\reg.pwn(170) : error 017: undefined symbol "ini_encode"
C:\Users\Edward\Desktop\Samp\pawno\reg.pwn(172) : error 017: undefined symbol "INI_Set"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.

Line 165:
Quote:

if(fexist(filename[] )) return SendClientMessage(playerid,COLOR_ORANGE,"This account doesn't exist, please use /register <password>.");

Line 167:
Quote:

if (INI_CheckLogin(name,params))

Line 170:
Quote:

format(file,sizeof(file),"%s.ini",ini_encode(name) );

Line 172:
Quote:

INI_Set(file,"ip",tmp3);

And finally this is the script self:

PHP код:
#include <a_samp>
#include <YSI\y_ini>
#include <ZCMD>
//------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
new Failed[MAX_PLAYERS];
//------------------------------------------------------------------------------
//Defines
//------------------------------------------------------------------------------
#define COLOR_GREEN 0x00FF04FF
#define COLOR_RED 0xFF0000FF
#define COLOR_YELLOW 0xFFFB00FF
#define COLOR_ORANGE 0xFFA200FF
#define COLOR_GREY 0xBABABAFF
#define Login(playerid);
#pragma tabsize 0
#define PATH "/Users/%s.ini"
//------------------------------------------------------------------------------
enum pInfo
{
    
pPass,
    
pLoggedIn,
    
pSkin,
    
pColor,
    
pCash,
    
pAdmin,
    
pKills,
    
pDeaths,
    
pIP[20],
    
LoggedIn
}
new 
PlayerInfo[MAX_PLAYERS][pInfo];
//------------------------------------------------------------------------------
forward LoadUser_data(playerid,name[],value[]);
public 
LoadUser_data(playerid,name[],value[])
{
     
INI_Int("Password",PlayerInfo[playerid][pPass]);
     
INI_Int("LoggedIn",PlayerInfo[playerid][pLoggedIn]);
     
INI_Int("Skin",PlayerInfo[playerid][pSkin]);
    
INI_Int("Color",PlayerInfo[playerid][pColor]);
    
INI_Int("Cash",PlayerInfo[playerid][pCash]);
    
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    
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=0n<lengthn++)
    {
        
s1 = (s1 buf[n]) % 65521;
        
s2 = (s2 s1)     % 65521;
    }
    return (
s2 << 16) + s1;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// OnPlayerConnect (Register, Login, Auto Login...
//------------------------------------------------------------------------------
public OnPlayerConnect(playerid)
{
    if(
fexist(UserPath(playerid)))
    {
        
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra true, .extra playerid);
            new 
tmpip[20];
            
GetPlayerIp(playerid,tmpip,20);
                       if(!
strcmp(tmpip,PlayerInfo[playerid][pIP],true))
                    {
                    
Login(playerid);
                    
SendClientMessage(playerid,COLOR_GREEN,"You have been automatically logged in.");
                    }
            else
            {
            
SendClientMessage(playerid,COLOR_ORANGE,"There was something wrong, you are not automatically logged in. Please /login.");
            }
    }
    else
    {
        
SendClientMessage(playerid,COLOR_ORANGE,"Welcome, you are NOT registered. Please /register.");
    }
        return 
1;}
//------------------------------------------------------------------------------
// OnPlayerDisconnect
//------------------------------------------------------------------------------
public OnPlayerDisconnect(playeridreason)
{
    new 
INI:File INI_Open(UserPath(playerid));
    
INI_SetTag(File,"data");
    
INI_WriteInt(File,"Skin",GetPlayerSkin(playerid));
    
INI_WriteInt(File,"Color",GetPlayerColor(playerid));
    
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    
INI_Close(File);
    return 
1;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// OnPlayerDeath +kills +Deaths etc..
//------------------------------------------------------------------------------
public OnPlayerDeath(playeridkilleridreason)
{
    
PlayerInfo[killerid][pKills]++;
    
PlayerInfo[playerid][pDeaths]++;
    return 
1;
}
//==============================================================================
//------------------------------------------------------------------------------
// Register command (/register)
//------------------------------------------------------------------------------
CMD:register(playerid,params[])
{
        new 
name[90];
        
GetPlayerIp(playerid,PlayerInfo[playerid][pIP],20);
        
GetPlayerName(playerid,name,sizeof(name));
        if (
PlayerInfo[playerid][LoggedIn] == 1) return SendClientMessage(playerid,COLOR_GREEN,"You have been succesfully logged in.");
        if (
fexist(UserPath(playerid))) return SendClientMessage(playerid,COLOR_ORANGE,"Sorry, this account is already exists, please login or choose another nickname.");
        if (
strlen(params) == 0) return SendClientMessage(playerid,COLOR_ORANGE,"You must be type /register <password>");
          new 
INI:File;
          if((
File INI_Open(UserPath(playerid))))
          {        new 
ip[100],tmp[260];
                  
INI_SetTag(File,"data");
                
GetPlayerIp(playerid,ip,100);
                
INI_WriteString(File,"ip",tmp);
                
INI_WriteInt(File,"Skin",0);
                
INI_WriteInt(File,"Color",0);
                
INI_WriteInt(File,"Cash",0);
                
INI_WriteInt(File,"Admin",0);
                
INI_WriteInt(File,"Kills",0);
                
INI_WriteInt(File,"Deaths",0);
                   
PlayerInfo[playerid][LoggedIn] = 1;
                
SendClientMessage(playerid,COLOR_GREEN"You have been succesfully registered and logged in.");
                
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
                return 
1;
        }
        return 
1;
}
//------------------------------------------------------------------------------
// Login command (/login)
//------------------------------------------------------------------------------
CMD:login(playerid,params[])
{
        new 
name[24];
        
GetPlayerIp(playerid,PlayerInfo[playerid][pIP],20);
        
GetPlayerName(playerid,name,sizeof(name));
        if (
PlayerInfo[playerid][LoggedIn] == 1) return SendClientMessage(playerid,COLOR_ORANGE,"Sorry, you are already logged in.");
        if(
fexist(filename[] )) return SendClientMessage(playerid,COLOR_ORANGE,"This account doesn't exist, please use /register <password>.");
        if (
strlen(params)==0) return SendClientMessage(playerid,COLOR_ORANGE,"You must be type login <password>");
        if (
INI_CheckLogin(name,params))
        {
                new 
file[256], tmp3[100];
                
format(file,sizeof(file),"%s.ini",ini_encode(name));
                
GetPlayerIp(playerid,tmp3,100);
                
INI_Set(file,"ip",tmp3);
                
Login(playerid);
                
SendClientMessage(playerid,COLOR_GREEN,"You have been successfully logged in");
        }
        else
        {
                
Failed[playerid]++;
                if(
Failed[playerid] == 5)
                {
                        new 
string[128];
                        
format(stringsizeof(string), "%s has been kicked for bad login attempts.",name);
                        
SendClientMessageToAll(COLOR_REDstring);
                        
Kick(playerid);
                }
                return 
SendClientMessage(playerid,COLOR_ORANGE,"Login failed! incorrect password.");
        }
        return 
1;

I hope anyone know this problem, and can help me out of this.

Thanks for reading,

Mickos0087
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)