Jump to content
  • 0

Question

Posted

Salut! astazi am incercat sa mi fac un gamemode de la zero si logic am inceput cu un system de register si login si intampin aceste probleme dar prima data acesta este tot codul meu current: 

#include <a_samp>
#include <a_mysql>

new SQL = -1, gQuery[256], gString[256];

#define function%0(%1)   forward %0(%1);   public %0(%1)
#define SCM              SendClientMessage

#define COLOR_DARKRED    0xd80003FF

new
   incercariParola[MAX_PLAYERS]

enum pInfo {
   pSQLID,
   pName[MAX_PLAYER_NAME],
   pPassword[32],
   pEmail[32],
   pGender
}
new PlayerInfo[MAX_PLAYERS][pInfo];

enum {
   //Register
   DIALOG_REGISTER,
   DIALOG_EMAIL,
   DIALOG_GENDER,

   //Login
   DIALOG_LOGIN
}


main() { print("Gamemode-ul este in curs de procesare.."); }

public OnGameModeInit()
{
	SQL = mysql_connect("5.9.8.124", "u1715759_BXc9PBwXII", "s1715759_ringshield", "nN0wEys=sGic37abSLtj=Qj5");

	// Don't use these lines if it's a filterscript
	SetGameModeText("RING RPG");
	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	return 1;
}

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) {
   incercariParola[playerid] = 0;

   gQuery[0] = EOS;
   mysql_format(SQL, gQuery, sizeof(gQuery), "SELECT * FROM `users` WHERE `Name`='%s' LIMIT 1", GetName(playerid));
   mysql_tquery(SQL, gQuery, "checkAccount", "i", playerid);
   return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
   switch(dialogid) {
	  case DIALOG_REGISTER: {
		 if(!response)
			return Kick(playerid);

			if(strlen(inputtext) < 6 || strlen(inputtext) > 32)
			   return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Scrie o parola pentru a te putea inregistra (minim 6 caractere maxim 32):", "Select", "Cancel");

		 gQuery[0] = EOS;
		 mysql_format(SQL, gQuery, sizeof(gQuery), "INSERT INTO `users` (`Name`, `Password`) VALUES ('%s', '%s')", GetName(playerid), inputtext);
		 mysql_tquery(SQL, gQuery, "insertAccount, "i", playerid);

		 gString[0] = EOS;
		 format(gString, sizeof(gString), "Parola ta contine %d caractere", strlen(inputtext));
		 SCM(playerid, -1, gString);


		 format(PlayerInfo[playerid][pPassword], 32, inputtext);

		 ShowPlayerDialog(playerid, DIALOG_EMAIL, DIALOG_STYLE_INPUT, "Email", "Seteaza-ti adresa de email:", "Select", "Cancel");
	  }
	  case DIALOG_EMAIL: {
         if(!response)
			return Kick(playerid);

			if(strlen(inputtext) < 6 || strlen(inputtext) > 32)
			   return ShowPlayerDialog(playerid, DIALOG_EMAIL, DIALOG_STYLE_INPUT, "Email", "Seteaza-ti adresa de email:", "Select", "Cancel");

   		 gQuery[0] = EOS;
		 mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE `users` SET `Email`='%s' WHERE `ID`='%d'", inputtext, PlayerInfo[playerid][pSQLID]);
		 mysql_tquery(SQL, gQuery, "", "");

		 gString[0] = EOS;
		 format(gString, sizeof(gString), "Email setat: %s", inputtext);
		 SCM(playerid, -1, gString);


		 format(PlayerInfo[playerid][pEmail], 32, inputtext);

		 ShowPlayerDialog(playerid, DIALOG_GENDER, DIALOG_STYLE_MSGBOX, "Gender", "Seteaza-ti sexul:", "Masculin", "Feminin");
	  }
	  case DIALOG_GENDER: {
		 switch(response) {
			case 0: {
			   PlayerInfo[playerid][pGender] = 1;
			   SCM(playerid, -1, "Sex setat: Feminin");
			}
			case 1: {
			   PlayerInfo[playerid][pGender] = 0;
			   SCM(playerid, -1, "Sex setat: Masculin");
			}
		 }
         gQuery[0] = EOS;
		 mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE `users` SET `Gender`='%d' WHERE `ID`='%d'", PlayerInfo[playerid][pGender], PlayerInfo[playerid][pSQLID]);
		 mysql_tquery(SQL, gQuery, "", "");

		 SpawnPlayer(playerid);
	  }
	  case DIALOG_LOGIN: {
		 if(!response)
			return Kick(playerid);

			   mysql_format(SQL, gQuery, sizeof(gQuery), "SELECT * FROM `users` WHERE `Name`='%s' AND `Password`='%s' LIMIT 1", GetName(playerid), inputtext);
               mysql_tquery(SQL, gQuery, "onLogin", "i", playerid);
	  }
   }
   return 1;
}

function onLogin(playerid) {
   switch(cache_num_rows()) {
	  case 0: {
		 incercariParola[playerid] ++;

		 gString[0] = EOS;
		 format(gString, sizeof(gString), "Parola incorecta! (%d/3 incercari ramase)", incercariParola[playerid]);
		 SCM(playerid, COLOR_DARKRED, gString);

		 if(incercariParola[playerid] == 3) Kick(playerid);
		 else ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Scrie o parola pentru a te putea loga:", "Select", "Cancel");
	  }
	  case 1: {
		 new
			result[64];

			PlayerInfo[playerid][pSQLID]= cache_get_field_content_int(0, "ID");
			PlayerInfo[playerid][pGender]= cache_get_field_content_int(0, "Gender");

			cache_get_field_content(0, "Name", result); format(PlayerInfo[playerid][pName], MAX_PLAYER_NAME, result);
			cache_get_field_content(0, "Password", result); format(PlayerInfo[playerid][pPassword], 32, result);
			cache_get_field_content(0, "Email", result); format(PlayerInfo[playerid][pEmail], 32, result);

			printf("%s (user: %d) s-a logat. [Gender: %d, Name: %s, Password: %s, Email: %s]", GetName(playerid), PlayerInfo[playerid][pSQLID], PlayerInfo[playerid][pGender], PlayerInfo[playerid][pPassword], PlayerInfo[playerid][pEmail]);
	  }
   }
   return 1;
}

function insertAccount(playerid) {
   PlayerInfo[playerid][pSQLID] = cache_insert_id();
   printf("%s s-a inregistrat cu SQLID-ul #%d.", GetName(playerid), PlayerInfo[playerid][pSQLID]);
   return 1;
}

function checkAccount(playerid) {
   switch(cache_num_rows()) {
	  case 0: ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Scrie o parola pentru a te putea inregistra (minim 6 caractere maxim 32):", "Select", "Cancel");
	  case 1: ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Scrie o parola pentru a te putea loga:", "Select", "Cancel");
   }
}

stock GetName(playerid) {
   new playerName[MAX_PLAYER_NAME];
   GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
   return playerName;
}

Iar erorile cu tot cu warning uri sunt: 

C:\Users\Fabian\Desktop\SAMP SV\gamemodes\ringshield.pwn(14) : error 001: expected token: ";", but found "enum"
C:\Users\Fabian\Desktop\SAMP SV\gamemodes\ringshield.pwn(69) : warning 217: loose indentation
C:\Users\Fabian\Desktop\SAMP SV\gamemodes\ringshield.pwn(72) : warning 217: loose indentation
C:\Users\Fabian\Desktop\SAMP SV\gamemodes\ringshield.pwn(74) : error 001: expected token: "-string end-", but found "-identifier-"
C:\Users\Fabian\Desktop\SAMP SV\gamemodes\ringshield.pwn(74) : error 017: undefined symbol "i"
C:\Users\Fabian\Desktop\SAMP SV\gamemodes\ringshield.pwn(74) : warning 215: expression has no effect
C:\Users\Fabian\Desktop\SAMP SV\gamemodes\ringshield.pwn(74) : warning 215: expression has no effect
C:\Users\Fabian\Desktop\SAMP SV\gamemodes\ringshield.pwn(74) : error 001: expected token: ";", but found ")"
C:\Users\Fabian\Desktop\SAMP SV\gamemodes\ringshield.pwn(74) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


5 Errors.

Va multumesc!

4 answers to this question

Recommended Posts

  • 0
Posted (edited)

Poftim, ti-am rezolvat eu erorile, nu am compilat, daca mai primesti ceva, imi dai reply sa-ti rezolv. Aveai erori pentru ca nu ai declarat un string, lipseau niste ghilimele la undefined symbol "i", si la acel enum ai uitat sa inchizi cu ";".

Edit: Aseaza-ti tu codul in coder, ca sa nu mai primesti warningul acela loose identation

 

#include <a_samp>
#include <a_mysql>

new SQL = -1, gQuery[256], gString[256];

#define function%0(%1)   forward %0(%1);   public %0(%1)
#define SCM              SendClientMessage

#define COLOR_DARKRED    0xd80003FF

new
   incercariParola[MAX_PLAYERS]

enum pInfo {
   pSQLID,
   pName[MAX_PLAYER_NAME],
   pPassword[32],
   pEmail[32],
   pGender
};

new PlayerInfo[MAX_PLAYERS][pInfo];

enum {
   //Register
   DIALOG_REGISTER,
   DIALOG_EMAIL,
   DIALOG_GENDER,

   //Login
   DIALOG_LOGIN
}


main() { print("Gamemode-ul este in curs de procesare.."); }

public OnGameModeInit()
{
	SQL = mysql_connect("5.9.8.124", "u1715759_BXc9PBwXII", "s1715759_ringshield", "nN0wEys=sGic37abSLtj=Qj5");

	// Don't use these lines if it's a filterscript
	SetGameModeText("RING RPG");
	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	return 1;
}

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) {
   incercariParola[playerid] = 0;

   gQuery[0] = EOS;
   mysql_format(SQL, gQuery, sizeof(gQuery), "SELECT * FROM `users` WHERE `Name`='%s' LIMIT 1", GetName(playerid));
   mysql_tquery(SQL, gQuery, "checkAccount", "i", playerid);
   return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) 
{
   switch(dialogid)  
   {
		case DIALOG_REGISTER:  
		{
			if(!response) return Kick(playerid);

			if(strlen(inputtext) < 6 || strlen(inputtext) > 32)
			   return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Scrie o parola pentru a te putea inregistra (minim 6 caractere maxim 32):", "Select", "Cancel");

			new gQuery[0] = EOS;
			mysql_format(SQL, gQuery, sizeof(gQuery), "INSERT INTO `users` (`Name`, `Password`) VALUES ('%s', '%s')", GetName(playerid), inputtext);
			mysql_tquery(SQL, gQuery, "insertAccount", "i", playerid);

			gString[0] = EOS;
			format(gString, sizeof(gString), "Parola ta contine %d caractere", strlen(inputtext));
			SCM(playerid, -1, gString);


			format(PlayerInfo[playerid][pPassword], 32, inputtext);

			ShowPlayerDialog(playerid, DIALOG_EMAIL, DIALOG_STYLE_INPUT, "Email", "Seteaza-ti adresa de email:", "Select", "Cancel");
	   }
	   case DIALOG_EMAIL: 
	   {
         if(!response)
			return Kick(playerid);

			if(strlen(inputtext) < 6 || strlen(inputtext) > 32)
			   return ShowPlayerDialog(playerid, DIALOG_EMAIL, DIALOG_STYLE_INPUT, "Email", "Seteaza-ti adresa de email:", "Select", "Cancel");

   		gQuery[0] = EOS;
		 	mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE `users` SET `Email`='%s' WHERE `ID`='%d'", inputtext, PlayerInfo[playerid][pSQLID]);
		 	mysql_tquery(SQL, gQuery, "", "");

		 	gString[0] = EOS;
		 	format(gString, sizeof(gString), "Email setat: %s", inputtext);
		 	SCM(playerid, -1, gString);


		 	format(PlayerInfo[playerid][pEmail], 32, inputtext);

		 	ShowPlayerDialog(playerid, DIALOG_GENDER, DIALOG_STYLE_MSGBOX, "Gender", "Seteaza-ti sexul:", "Masculin", "Feminin");
	   }
	   case DIALOG_GENDER: 
	   {
	 		switch(response) 
		 	{
				case 0: 
				{
					PlayerInfo[playerid][pGender] = 1;
					SCM(playerid, -1, "Sex setat: Feminin");
				}
				case 1: 
				{
					PlayerInfo[playerid][pGender] = 0;
					SCM(playerid, -1, "Sex setat: Masculin");
				}
			}

	      gQuery[0] = EOS;
		 	mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE `users` SET `Gender`='%d' WHERE `ID`='%d'", PlayerInfo[playerid][pGender], PlayerInfo[playerid][pSQLID]);
		 	mysql_tquery(SQL, gQuery, "", "");

		 	SpawnPlayer(playerid);
	   }
	   case DIALOG_LOGIN: 
	   {
			if(!response) return Kick(playerid);

		   mysql_format(SQL, gQuery, sizeof(gQuery), "SELECT * FROM `users` WHERE `Name`='%s' AND `Password`='%s' LIMIT 1", GetName(playerid), inputtext);
         mysql_tquery(SQL, gQuery, "onLogin", "i", playerid);
	   }
   }
   return 1;
}

function onLogin(playerid) {
   switch(cache_num_rows()) {
	  case 0: {
		 incercariParola[playerid] ++;

		 gString[0] = EOS;
		 format(gString, sizeof(gString), "Parola incorecta! (%d/3 incercari ramase)", incercariParola[playerid]);
		 SCM(playerid, COLOR_DARKRED, gString);

		 if(incercariParola[playerid] == 3) Kick(playerid);
		 else ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Scrie o parola pentru a te putea loga:", "Select", "Cancel");
	  }
	  case 1: {
		 new
			result[64];

			PlayerInfo[playerid][pSQLID]= cache_get_field_content_int(0, "ID");
			PlayerInfo[playerid][pGender]= cache_get_field_content_int(0, "Gender");

			cache_get_field_content(0, "Name", result); format(PlayerInfo[playerid][pName], MAX_PLAYER_NAME, result);
			cache_get_field_content(0, "Password", result); format(PlayerInfo[playerid][pPassword], 32, result);
			cache_get_field_content(0, "Email", result); format(PlayerInfo[playerid][pEmail], 32, result);

			printf("%s (user: %d) s-a logat. [Gender: %d, Name: %s, Password: %s, Email: %s]", GetName(playerid), PlayerInfo[playerid][pSQLID], PlayerInfo[playerid][pGender], PlayerInfo[playerid][pPassword], PlayerInfo[playerid][pEmail]);
	  }
   }
   return 1;
}

function insertAccount(playerid) {
   PlayerInfo[playerid][pSQLID] = cache_insert_id();
   printf("%s s-a inregistrat cu SQLID-ul #%d.", GetName(playerid), PlayerInfo[playerid][pSQLID]);
   return 1;
}

function checkAccount(playerid) {
   switch(cache_num_rows()) {
	  case 0: ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Scrie o parola pentru a te putea inregistra (minim 6 caractere maxim 32):", "Select", "Cancel");
	  case 1: ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Scrie o parola pentru a te putea loga:", "Select", "Cancel");
   }
}

stock GetName(playerid) {
   new playerName[MAX_PLAYER_NAME];
   GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
   return playerName;
}

 

Edited by Costi Oprea
  • 0
Posted
3 hours ago, Costi Oprea said:

Poftim, ti-am rezolvat eu erorile, nu am compilat, daca mai primesti ceva, imi dai reply sa-ti rezolv. Aveai erori pentru ca nu ai declarat un string, lipseau niste ghilimele la undefined symbol "i", si la acel enum ai uitat sa inchizi cu ";".

Edit: Aseaza-ti tu codul in coder, ca sa nu mai primesti warningul acela loose identation

 

#include <a_samp>
#include <a_mysql>

new SQL = -1, gQuery[256], gString[256];

#define function%0(%1)   forward %0(%1);   public %0(%1)
#define SCM              SendClientMessage

#define COLOR_DARKRED    0xd80003FF

new
   incercariParola[MAX_PLAYERS]

enum pInfo {
   pSQLID,
   pName[MAX_PLAYER_NAME],
   pPassword[32],
   pEmail[32],
   pGender
};

new PlayerInfo[MAX_PLAYERS][pInfo];

enum {
   //Register
   DIALOG_REGISTER,
   DIALOG_EMAIL,
   DIALOG_GENDER,

   //Login
   DIALOG_LOGIN
}


main() { print("Gamemode-ul este in curs de procesare.."); }

public OnGameModeInit()
{
	SQL = mysql_connect("5.9.8.124", "u1715759_BXc9PBwXII", "s1715759_ringshield", "nN0wEys=sGic37abSLtj=Qj5");

	// Don't use these lines if it's a filterscript
	SetGameModeText("RING RPG");
	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	return 1;
}

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) {
   incercariParola[playerid] = 0;

   gQuery[0] = EOS;
   mysql_format(SQL, gQuery, sizeof(gQuery), "SELECT * FROM `users` WHERE `Name`='%s' LIMIT 1", GetName(playerid));
   mysql_tquery(SQL, gQuery, "checkAccount", "i", playerid);
   return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) 
{
   switch(dialogid)  
   {
		case DIALOG_REGISTER:  
		{
			if(!response) return Kick(playerid);

			if(strlen(inputtext) < 6 || strlen(inputtext) > 32)
			   return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Scrie o parola pentru a te putea inregistra (minim 6 caractere maxim 32):", "Select", "Cancel");

			new gQuery[0] = EOS;
			mysql_format(SQL, gQuery, sizeof(gQuery), "INSERT INTO `users` (`Name`, `Password`) VALUES ('%s', '%s')", GetName(playerid), inputtext);
			mysql_tquery(SQL, gQuery, "insertAccount", "i", playerid);

			gString[0] = EOS;
			format(gString, sizeof(gString), "Parola ta contine %d caractere", strlen(inputtext));
			SCM(playerid, -1, gString);


			format(PlayerInfo[playerid][pPassword], 32, inputtext);

			ShowPlayerDialog(playerid, DIALOG_EMAIL, DIALOG_STYLE_INPUT, "Email", "Seteaza-ti adresa de email:", "Select", "Cancel");
	   }
	   case DIALOG_EMAIL: 
	   {
         if(!response)
			return Kick(playerid);

			if(strlen(inputtext) < 6 || strlen(inputtext) > 32)
			   return ShowPlayerDialog(playerid, DIALOG_EMAIL, DIALOG_STYLE_INPUT, "Email", "Seteaza-ti adresa de email:", "Select", "Cancel");

   		gQuery[0] = EOS;
		 	mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE `users` SET `Email`='%s' WHERE `ID`='%d'", inputtext, PlayerInfo[playerid][pSQLID]);
		 	mysql_tquery(SQL, gQuery, "", "");

		 	gString[0] = EOS;
		 	format(gString, sizeof(gString), "Email setat: %s", inputtext);
		 	SCM(playerid, -1, gString);


		 	format(PlayerInfo[playerid][pEmail], 32, inputtext);

		 	ShowPlayerDialog(playerid, DIALOG_GENDER, DIALOG_STYLE_MSGBOX, "Gender", "Seteaza-ti sexul:", "Masculin", "Feminin");
	   }
	   case DIALOG_GENDER: 
	   {
	 		switch(response) 
		 	{
				case 0: 
				{
					PlayerInfo[playerid][pGender] = 1;
					SCM(playerid, -1, "Sex setat: Feminin");
				}
				case 1: 
				{
					PlayerInfo[playerid][pGender] = 0;
					SCM(playerid, -1, "Sex setat: Masculin");
				}
			}

	      gQuery[0] = EOS;
		 	mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE `users` SET `Gender`='%d' WHERE `ID`='%d'", PlayerInfo[playerid][pGender], PlayerInfo[playerid][pSQLID]);
		 	mysql_tquery(SQL, gQuery, "", "");

		 	SpawnPlayer(playerid);
	   }
	   case DIALOG_LOGIN: 
	   {
			if(!response) return Kick(playerid);

		   mysql_format(SQL, gQuery, sizeof(gQuery), "SELECT * FROM `users` WHERE `Name`='%s' AND `Password`='%s' LIMIT 1", GetName(playerid), inputtext);
         mysql_tquery(SQL, gQuery, "onLogin", "i", playerid);
	   }
   }
   return 1;
}

function onLogin(playerid) {
   switch(cache_num_rows()) {
	  case 0: {
		 incercariParola[playerid] ++;

		 gString[0] = EOS;
		 format(gString, sizeof(gString), "Parola incorecta! (%d/3 incercari ramase)", incercariParola[playerid]);
		 SCM(playerid, COLOR_DARKRED, gString);

		 if(incercariParola[playerid] == 3) Kick(playerid);
		 else ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Scrie o parola pentru a te putea loga:", "Select", "Cancel");
	  }
	  case 1: {
		 new
			result[64];

			PlayerInfo[playerid][pSQLID]= cache_get_field_content_int(0, "ID");
			PlayerInfo[playerid][pGender]= cache_get_field_content_int(0, "Gender");

			cache_get_field_content(0, "Name", result); format(PlayerInfo[playerid][pName], MAX_PLAYER_NAME, result);
			cache_get_field_content(0, "Password", result); format(PlayerInfo[playerid][pPassword], 32, result);
			cache_get_field_content(0, "Email", result); format(PlayerInfo[playerid][pEmail], 32, result);

			printf("%s (user: %d) s-a logat. [Gender: %d, Name: %s, Password: %s, Email: %s]", GetName(playerid), PlayerInfo[playerid][pSQLID], PlayerInfo[playerid][pGender], PlayerInfo[playerid][pPassword], PlayerInfo[playerid][pEmail]);
	  }
   }
   return 1;
}

function insertAccount(playerid) {
   PlayerInfo[playerid][pSQLID] = cache_insert_id();
   printf("%s s-a inregistrat cu SQLID-ul #%d.", GetName(playerid), PlayerInfo[playerid][pSQLID]);
   return 1;
}

function checkAccount(playerid) {
   switch(cache_num_rows()) {
	  case 0: ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Scrie o parola pentru a te putea inregistra (minim 6 caractere maxim 32):", "Select", "Cancel");
	  case 1: ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Scrie o parola pentru a te putea loga:", "Select", "Cancel");
   }
}

stock GetName(playerid) {
   new playerName[MAX_PLAYER_NAME];
   GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
   return playerName;
}

 

ai pus ; la un enum care e inutil deoarece nu e necesar, dar nu ai vazut ca la definirea incercariParola a uitat de ;

  • 0
Posted
13 hours ago, Micu_Gamer said:

Salut! astazi am incercat sa mi fac un gamemode de la zero si logic am inceput cu un system de register si login si intampin aceste probleme dar prima data acesta este tot codul meu current: 

#include <a_samp>
#include <a_mysql>

new SQL = -1, gQuery[256], gString[256];

#define function%0(%1)   forward %0(%1);   public %0(%1)
#define SCM              SendClientMessage

#define COLOR_DARKRED    0xd80003FF

new
   incercariParola[MAX_PLAYERS]

enum pInfo {
   pSQLID,
   pName[MAX_PLAYER_NAME],
   pPassword[32],
   pEmail[32],
   pGender
}
new PlayerInfo[MAX_PLAYERS][pInfo];

enum {
   //Register
   DIALOG_REGISTER,
   DIALOG_EMAIL,
   DIALOG_GENDER,

   //Login
   DIALOG_LOGIN
}


main() { print("Gamemode-ul este in curs de procesare.."); }

public OnGameModeInit()
{
	SQL = mysql_connect("5.9.8.124", "u1715759_BXc9PBwXII", "s1715759_ringshield", "nN0wEys=sGic37abSLtj=Qj5");

	// Don't use these lines if it's a filterscript
	SetGameModeText("RING RPG");
	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	return 1;
}

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) {
   incercariParola[playerid] = 0;

   gQuery[0] = EOS;
   mysql_format(SQL, gQuery, sizeof(gQuery), "SELECT * FROM `users` WHERE `Name`='%s' LIMIT 1", GetName(playerid));
   mysql_tquery(SQL, gQuery, "checkAccount", "i", playerid);
   return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
   switch(dialogid) {
	  case DIALOG_REGISTER: {
		 if(!response)
			return Kick(playerid);

			if(strlen(inputtext) < 6 || strlen(inputtext) > 32)
			   return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Scrie o parola pentru a te putea inregistra (minim 6 caractere maxim 32):", "Select", "Cancel");

		 gQuery[0] = EOS;
		 mysql_format(SQL, gQuery, sizeof(gQuery), "INSERT INTO `users` (`Name`, `Password`) VALUES ('%s', '%s')", GetName(playerid), inputtext);
		 mysql_tquery(SQL, gQuery, "insertAccount, "i", playerid);

		 gString[0] = EOS;
		 format(gString, sizeof(gString), "Parola ta contine %d caractere", strlen(inputtext));
		 SCM(playerid, -1, gString);


		 format(PlayerInfo[playerid][pPassword], 32, inputtext);

		 ShowPlayerDialog(playerid, DIALOG_EMAIL, DIALOG_STYLE_INPUT, "Email", "Seteaza-ti adresa de email:", "Select", "Cancel");
	  }
	  case DIALOG_EMAIL: {
         if(!response)
			return Kick(playerid);

			if(strlen(inputtext) < 6 || strlen(inputtext) > 32)
			   return ShowPlayerDialog(playerid, DIALOG_EMAIL, DIALOG_STYLE_INPUT, "Email", "Seteaza-ti adresa de email:", "Select", "Cancel");

   		 gQuery[0] = EOS;
		 mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE `users` SET `Email`='%s' WHERE `ID`='%d'", inputtext, PlayerInfo[playerid][pSQLID]);
		 mysql_tquery(SQL, gQuery, "", "");

		 gString[0] = EOS;
		 format(gString, sizeof(gString), "Email setat: %s", inputtext);
		 SCM(playerid, -1, gString);


		 format(PlayerInfo[playerid][pEmail], 32, inputtext);

		 ShowPlayerDialog(playerid, DIALOG_GENDER, DIALOG_STYLE_MSGBOX, "Gender", "Seteaza-ti sexul:", "Masculin", "Feminin");
	  }
	  case DIALOG_GENDER: {
		 switch(response) {
			case 0: {
			   PlayerInfo[playerid][pGender] = 1;
			   SCM(playerid, -1, "Sex setat: Feminin");
			}
			case 1: {
			   PlayerInfo[playerid][pGender] = 0;
			   SCM(playerid, -1, "Sex setat: Masculin");
			}
		 }
         gQuery[0] = EOS;
		 mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE `users` SET `Gender`='%d' WHERE `ID`='%d'", PlayerInfo[playerid][pGender], PlayerInfo[playerid][pSQLID]);
		 mysql_tquery(SQL, gQuery, "", "");

		 SpawnPlayer(playerid);
	  }
	  case DIALOG_LOGIN: {
		 if(!response)
			return Kick(playerid);

			   mysql_format(SQL, gQuery, sizeof(gQuery), "SELECT * FROM `users` WHERE `Name`='%s' AND `Password`='%s' LIMIT 1", GetName(playerid), inputtext);
               mysql_tquery(SQL, gQuery, "onLogin", "i", playerid);
	  }
   }
   return 1;
}

function onLogin(playerid) {
   switch(cache_num_rows()) {
	  case 0: {
		 incercariParola[playerid] ++;

		 gString[0] = EOS;
		 format(gString, sizeof(gString), "Parola incorecta! (%d/3 incercari ramase)", incercariParola[playerid]);
		 SCM(playerid, COLOR_DARKRED, gString);

		 if(incercariParola[playerid] == 3) Kick(playerid);
		 else ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Scrie o parola pentru a te putea loga:", "Select", "Cancel");
	  }
	  case 1: {
		 new
			result[64];

			PlayerInfo[playerid][pSQLID]= cache_get_field_content_int(0, "ID");
			PlayerInfo[playerid][pGender]= cache_get_field_content_int(0, "Gender");

			cache_get_field_content(0, "Name", result); format(PlayerInfo[playerid][pName], MAX_PLAYER_NAME, result);
			cache_get_field_content(0, "Password", result); format(PlayerInfo[playerid][pPassword], 32, result);
			cache_get_field_content(0, "Email", result); format(PlayerInfo[playerid][pEmail], 32, result);

			printf("%s (user: %d) s-a logat. [Gender: %d, Name: %s, Password: %s, Email: %s]", GetName(playerid), PlayerInfo[playerid][pSQLID], PlayerInfo[playerid][pGender], PlayerInfo[playerid][pPassword], PlayerInfo[playerid][pEmail]);
	  }
   }
   return 1;
}

function insertAccount(playerid) {
   PlayerInfo[playerid][pSQLID] = cache_insert_id();
   printf("%s s-a inregistrat cu SQLID-ul #%d.", GetName(playerid), PlayerInfo[playerid][pSQLID]);
   return 1;
}

function checkAccount(playerid) {
   switch(cache_num_rows()) {
	  case 0: ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Scrie o parola pentru a te putea inregistra (minim 6 caractere maxim 32):", "Select", "Cancel");
	  case 1: ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Scrie o parola pentru a te putea loga:", "Select", "Cancel");
   }
}

stock GetName(playerid) {
   new playerName[MAX_PLAYER_NAME];
   GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
   return playerName;
}

Iar erorile cu tot cu warning uri sunt: 

C:\Users\Fabian\Desktop\SAMP SV\gamemodes\ringshield.pwn(14) : error 001: expected token: ";", but found "enum"
C:\Users\Fabian\Desktop\SAMP SV\gamemodes\ringshield.pwn(69) : warning 217: loose indentation
C:\Users\Fabian\Desktop\SAMP SV\gamemodes\ringshield.pwn(72) : warning 217: loose indentation
C:\Users\Fabian\Desktop\SAMP SV\gamemodes\ringshield.pwn(74) : error 001: expected token: "-string end-", but found "-identifier-"
C:\Users\Fabian\Desktop\SAMP SV\gamemodes\ringshield.pwn(74) : error 017: undefined symbol "i"
C:\Users\Fabian\Desktop\SAMP SV\gamemodes\ringshield.pwn(74) : warning 215: expression has no effect
C:\Users\Fabian\Desktop\SAMP SV\gamemodes\ringshield.pwn(74) : warning 215: expression has no effect
C:\Users\Fabian\Desktop\SAMP SV\gamemodes\ringshield.pwn(74) : error 001: expected token: ";", but found ")"
C:\Users\Fabian\Desktop\SAMP SV\gamemodes\ringshield.pwn(74) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


5 Errors.

Va multumesc!

deci, scrii cod de la 0, dar nu stii sa rezolvi niste erori, sa nu mai zic ca nici macar escape nu folosesti peste input-urile unui player, si pe langa asta inserezi parola plain in db 😂, a, si vezi ca ti ai cam dat datele mysql la public

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.