/Login /Register
#1

Hello guys I'm following this video on ******* about a login/ register system with mysql i follow all step and its not working can you explain me why please?

Errors and warnings here:

Код:
C:\Users\Jaua\Downloads\gta-rp\gamemodes\LIMPIO.pwn(38) : error 017: undefined symbol "SQL_DATA"
C:\Users\Jaua\Downloads\gta-rp\gamemodes\LIMPIO.pwn(41) : error 017: undefined symbol "MAX"
C:\Users\Jaua\Downloads\gta-rp\gamemodes\LIMPIO.pwn(53) : error 017: undefined symbol "LOG_ERROR"
C:\Users\Jaua\Downloads\gta-rp\gamemodes\LIMPIO.pwn(55) : warning 213: tag mismatch
C:\Users\Jaua\Downloads\gta-rp\gamemodes\LIMPIO.pwn(61) : warning 213: tag mismatch
C:\Users\Jaua\Downloads\gta-rp\gamemodes\LIMPIO.pwn(82) : warning 219: local variable "query" shadows a variable at a preceding level
C:\Users\Jaua\Downloads\gta-rp\gamemodes\LIMPIO.pwn(83) : warning 213: tag mismatch
C:\Users\Jaua\Downloads\gta-rp\gamemodes\LIMPIO.pwn(83) : error 037: invalid string (possibly non-terminated string)
C:\Users\Jaua\Downloads\gta-rp\gamemodes\LIMPIO.pwn(83) : error 017: undefined symbol "SELECT"
C:\Users\Jaua\Downloads\gta-rp\gamemodes\LIMPIO.pwn(83) : error 017: undefined symbol "id"
C:\Users\Jaua\Downloads\gta-rp\gamemodes\LIMPIO.pwn(83) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


7 Errors.
video here: https://www.youtube.com/watch?v=-qIy...aIZlsB&index=1

Here all my code, i follow all the step but i dont know why is not working....
PHP код:
********************************************************************************
                            
GRAND THEFT AUTO ROLEPLAY PROJECT
********************************************************************************
                                    
INCLUDES
*******************************************************************************/
#include <a_samp>
#include <zcmd>
#include <sscanf>
#include <YSI\y_ini>
#include <a_mysql>
#define Server:%0(%1) forward %0(%1); public %0(%1)
#define SQL_HOST "localhost"
#define SQL_USER "root"
#define SQL_DATABASE "tutorial"
#define SQL_PASSWORD ""
#define COLOR_WHITE     0xFFFFFF00
#define DIALOG_UNUSED   0
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN    2
enum PLAYER_DATA
{
    
pSQLID,
    
pAdminLevel
}
//Global Variavles
new sqlConnectionMySQL_Data[SQL_DATA];
//Player Variables
new bool:LoggedIn[MAX PLAYERS], PlayerData[MAX_PLAYERS][PLAYER_DATA];
main()
{
    print(
"\n----------------------------------");
    print(
" Blank Gamemode by your name here");
    print(
"----------------------------------\n");
}
public 
OnGameModeInit()
{
    
mysql_log(LOG_ERROR LOG_WARNINGLOG_TYPE_HTML);
    
    
sqlConnection mysql_connect(SQL_HOSTSQL_USERSQL_DATABASESQL_PASSWORD);
    return 
true;
}
public 
OnGameModeExit()
{
    
mysql_close(sqlConnection);
    return 
true;
}
public 
OnPlayerRequestClass(playeridclassid)
{
    
SetPlayerPos(playerid1958.37831343.157215.3746);
    
SetPlayerCameraPos(playerid1958.37831343.157215.3746);
    
SetPlayerCameraLookAt(playerid1958.37831343.157215.3746);
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    
DefaultPlayerValues(playerid);
    
    
DoesPlayerExist(playerid);
    return 
true;
}
Server:DoesPlayerExist(playerid)
{
    new 
query[128];
    
mysql_format(sqlConnectionquerysizeof(query), "SELECT id FROM players WHERE Name = '%e' LIMIT 1, GetName(playerid));
    mysql_pquery(sqlConnection, query, "
SQL_DoesPlayerExist", "i", playerid);
    return true;
}
Server:SQL_DoesPlayerExist(playerid)
{
    
     if(cache_num_rows(sqlConnection) != 0) // Exist
    {
        ShowLoginDialog(playerid, "");
    }
    else //Doesn't Exist
    {
        ShowRegisterDialog(playerid,"");
    }
    return true;
}
Server_ShowLoginDialog(playerid, error[])
{
    if(LoggedIn[playerid])
    return true;
    if(!strmatch(error, ""))
    {
        SendClientMessage(playerid, COLOR_WHITE, error);
    }
    ShowPlayerDialog(playerid, DIALOG_LOGIN DIALOG_STYLE_PASSWORD, "
Grand Theft Auto Roleplay Login", "Please enter your password below so you can login", "Login","Quit");
    
    return true;
}
Server:ShowRegisterDialog(playerid, error[])
{
    if(LoggedIn[playerid])return true;
    if(strcmp(error), ""))
    {
        SendClientMessage(playerid , COLOR_WHITE, error);
    }
    ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "
Grand Theft Auto Roleplay Register", "Please enter a password below so you can register your account with us", "Register", "Quit");
    return true;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_REGISTER;
        {
            if(!response)return Kick(playerid);
            if(strlen(inputtext) < 3 || strlen(inputtext) > 30)
            {
            ShowRegisterDialog(playerid, "
Password length must be above 3 characters and below 30 characters long");
            return true;
            }
            new query[128];
            mysql_format(sqlConnection, query, sizeof(query), "
INSERT INTO players (NamePasswordRegIPVALUES('%e'shal('%e'), '%e'", GetName(playerid), inputtext, GetIP(playerid));
            mysql_pquery(sqlConnection, query, "
SQL_OnAccountRegister", "i", playerid);
        }
        case DIALOG_LOGIN:
        {
            if(!response)return Kick(playerid);
            
            if(strlen(inputtext) < 3 || strlen(inputtext) > 30)
            {
                ShowLoginDialog(playerid, "
Password length must be above 3 characters and below 30 characters long");
                return true;
                }
            new query[128];
            mysql_format(sqlConnection, query, sizeof(query), "
SELECT id FROM players WHERE Name '%e' AND Password shal('%e'LIMIT 1", GetName(playerid), inputtext);
            mysql_pquery(sql_Connection, query, "
SQL_OnAccountLogin"i"playerid");
    }
    return false;
}
Server_SQL_OnAccountLogin(playerid)
{
    if(cache_num_rows() == 0)
    {
        ShowLoginDialog(playerid, "
Incorrect Password");
        return true;
    }
    PlayerData[playerid][pSQLID] = cache_get_field_content_int(0, "
id", sqlConnection);
    PlayerData[playerid][pAdminLevel] = cache_get_field_content_int(0, "
AdminLevel", sqlConnection);
    new string[128];
    format(string, sizeof(string), "
SQLID: %Admin: %d", PlayerData[playerid][pSQLID], PlayerData[playerid][pAdminLevel]);
    SendClientMessage(playerid, COLOR_WHITE, string);
    return true;
}
Server:SQL_OnAccountRegister(playerid)
{
    SendClientMessage(playerid, COLOR_WHITE, "
You have successfully registered to the server");
    DefaultPlayerValues(playerid);
    PlayerData[playerid][pSQLID] = cache_insert_id();
    return true;
}
public OnPlayerDisconnect(playerid, reason)
{
    DefaultPlayerValues(playerid);
    return true;
}
public OnPlayerUpdate(playerid)
{
    return 1;
}
Server:DefaultPlayerValues(playerid)
{
    PlayerData[playerid][pSQLID] = 0;
    PlayerData[playerid][pAdminLevel] = 0;
    return true;
}
//Stocks and other funtions
GetIP(playerid)
{
    new ip[20];
    GetPlayerIp(playerid, ip, sizeof(ip));
    return ip;
}
GetName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
stock strmatch(const String1[], const String2[])
{
    if ((strcmp(String1, String2, true, strlen(String2)) == 0) && (strlen(String2) == strlen(String1)))
    {
        return true;
    }
    else
    {
    return false;
    }

Reply
#2

Anyone know how can i solve this?
Reply
#3

PHP код:
/********************************************************************************
                            GRAND THEFT AUTO ROLEPLAY PROJECT
********************************************************************************
                                    INCLUDES
*******************************************************************************/
#include <a_samp>
#include <izcmd>
#include <sscanf2>
#include <YSI\y_ini>
#include <a_mysql>
#define Server:%0(%1) forward %0(%1); public %0(%1)
#define SQL_HOST "localhost"
#define SQL_USER "root"
#define SQL_DATABASE "tutorial"
#define SQL_PASSWORD ""
#define COLOR_WHITE     0xFFFFFF00
#define DIALOG_UNUSED   0
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN    2
enum PLAYER_DATA
{
    
pSQLID,
    
pAdminLevel
}
//Global Variavles
new MySQL:sqlConnection;
//new MySQL_Data[SQL_DATA]; // SQL_DATA isn't defined. You want an enum here  I suppose so Just comment out till you make one
//Player Variables
new bool:LoggedIn[MAX_PLAYERS], PlayerData[MAX_PLAYERS][PLAYER_DATA];
main()
{
    print(
"\n----------------------------------");
    print(
" Blank Gamemode by your name here");
    print(
"----------------------------------\n");
}
public 
OnGameModeInit()
{
    
mysql_log(ERROR WARNING);
    
sqlConnection mysql_connect(SQL_HOSTSQL_USERSQL_PASSWORDSQL_DATABASE);
    return 
true;
}
public 
OnGameModeExit()
{
    
mysql_close(sqlConnection);
    return 
true;
}
public 
OnPlayerRequestClass(playeridclassid)
{
    
SetPlayerPos(playerid1958.37831343.157215.3746);
    
SetPlayerCameraPos(playerid1958.37831343.157215.3746);
    
SetPlayerCameraLookAt(playerid1958.37831343.157215.3746);
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    
DefaultPlayerValues(playerid);
    
DoesPlayerExist(playerid);
    return 
true;
}
Server:DoesPlayerExist(playerid)
{
    new 
query[128];
    
mysql_format(sqlConnectionquerysizeof(query), "SELECT id FROM players WHERE Name = '%e' LIMIT 1"GetName(playerid));
    
mysql_pquery(sqlConnectionquery"SQL_DoesPlayerExist""i"playerid);
    return 
true;
}
Server:SQL_DoesPlayerExist(playerid)
{
     if(
cache_num_rows(sqlConnection) != 0// Exist
    
{
        
ShowLoginDialog(playerid"");
    }
    else 
//Doesn't Exist
    
{
        
ShowRegisterDialog(playerid,"");
    }
    return 
true;
}
Server_ShowLoginDialog(playeriderror[])
{
    if(
LoggedIn[playerid])
    return 
true;
    if(!
strmatch(error""))
    {
        
SendClientMessage(playeridCOLOR_WHITEerror);
    }
    
ShowPlayerDialog(playeridDIALOG_LOGIN DIALOG_STYLE_PASSWORD"Grand Theft Auto Roleplay - Login""Please enter your password below so you can login""Login","Quit");
    return 
true;
}
Server:ShowRegisterDialog(playeriderror[])
{
    if(
LoggedIn[playerid])return true;
    if(
strcmp(error), ""))
    {
        
SendClientMessage(playerid COLOR_WHITEerror);
    }
    
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_PASSWORD"Grand Theft Auto Roleplay - Register""Please enter a password below so you can register your account with us""Register""Quit");
    return 
true;
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch(
dialogid)
    {
        case 
DIALOG_REGISTER;
        {
            if(!
response)return Kick(playerid);
            if(
strlen(inputtext) < || strlen(inputtext) > 30)
            {
            
ShowRegisterDialog(playerid"Password length must be above 3 characters and below 30 characters long");
            return 
true;
            }
            new 
query[128];
            
mysql_format(sqlConnectionquerysizeof(query), "INSERT INTO players (Name, Password, RegIP) VALUES('%e', shal('%e'), '%e'"GetName(playerid), inputtextGetIP(playerid));
            
mysql_pquery(sqlConnectionquery"SQL_OnAccountRegister""i"playerid);
        }
        case 
DIALOG_LOGIN:
        {
            if(!
response)return Kick(playerid);
            if(
strlen(inputtext) < || strlen(inputtext) > 30)
            {
                
ShowLoginDialog(playerid"Password length must be above 3 characters and below 30 characters long");
                return 
true;
                }
            new 
query[128];
            
mysql_format(sqlConnectionquerysizeof(query), "SELECT id FROM players WHERE Name = '%e' AND Password = shal('%e') LIMIT 1"GetName(playerid), inputtext);
            
mysql_pquery(sql_Connectionquery"SQL_OnAccountLogin, "i", playerid");
    }
    return 
false;
}
Server_SQL_OnAccountLogin(playerid)
{
    if(
cache_num_rows() == 0)
    {
        
ShowLoginDialog(playerid"Incorrect Password");
        return 
true;
    }
    
PlayerData[playerid][pSQLID] = cache_get_field_content_int(0"id"sqlConnection);
    
PlayerData[playerid][pAdminLevel] = cache_get_field_content_int(0"AdminLevel"sqlConnection);
    new 
string[128];
    
format(stringsizeof(string), "SQLID: %d | Admin: %d"PlayerData[playerid][pSQLID], PlayerData[playerid][pAdminLevel]);
    
SendClientMessage(playeridCOLOR_WHITEstring);
    return 
true;
}
Server:SQL_OnAccountRegister(playerid)
{
    
SendClientMessage(playeridCOLOR_WHITE"You have successfully registered to the server");
    
DefaultPlayerValues(playerid);
    
PlayerData[playerid][pSQLID] = cache_insert_id();
    return 
true;
}
public 
OnPlayerDisconnect(playeridreason)
{
    
DefaultPlayerValues(playerid);
    return 
true;
}
public 
OnPlayerUpdate(playerid)
{
    return 
1;
}
Server:DefaultPlayerValues(playerid)
{
    
PlayerData[playerid][pSQLID] = 0;
    
PlayerData[playerid][pAdminLevel] = 0;
    return 
true;
}
//Stocks and other funtions
GetIP(playerid)
{
    new 
ip[20];
    
GetPlayerIp(playeridipsizeof(ip));
    return 
ip;
}
GetName(playerid)
{
    new 
name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));
    return 
name;
}
stock strmatch(const String1[], const String2[])
{
    if ((
strcmp(String1String2truestrlen(String2)) == 0) && (strlen(String2) == strlen(String1)))
    {
        return 
true;
    }
    else
    {
    return 
false;
    }

Try that
You're using the latest mysql version right?
Reply
#4

Write your own Login/Register system instead of copying somebody else's, trust me you will get so much further with it. You'll never learn how to script or work with a specific language if you dont write just spice up things ...
Reply
#5

At case dialog register delete that semi colon( ; ) at end and put basic colon ( : )
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)