03.10.2017, 04:28
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:
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....
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.
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 sqlConnection, MySQL_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_WARNING, LOG_TYPE_HTML);
sqlConnection = mysql_connect(SQL_HOST, SQL_USER, SQL_DATABASE, SQL_PASSWORD);
return true;
}
public OnGameModeExit()
{
mysql_close(sqlConnection);
return true;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
public OnPlayerConnect(playerid)
{
DefaultPlayerValues(playerid);
DoesPlayerExist(playerid);
return true;
}
Server:DoesPlayerExist(playerid)
{
new query[128];
mysql_format(sqlConnection, query, sizeof(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 (Name, Password, RegIP) VALUES('%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: %d | 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;
}
}