Jump to content
  • 0

Baza de date[REZOLVAT]


Alexandru Alex

Question

CMD:setpin(playerid, params[]) {
	if(playerVariables[playerid][pPin] != 0) return SCM(playerid, COLOR_LIGHTGREEN3, "Ai deja un pin setat!\nFoloseste comanda [/pin] pentru a te loga!");
	ShowPlayerDialogEx(playerid, DIALOG_SETPIN, DIALOG_STYLE_INPUT, "Set Pin", "Seteza-ti pinul!\nPinul trebuie sa contina 4 numere!", "Ok", "Exit");
	return 1;
}
CMD:pin(playerid, params[]) {
	if(playerVariables[playerid][pPinLogged] == 1) return SCM(playerid, COLOR_LIGHTGREEN3, "Deja te-ai logat cu pin-ul tau!");
	if(playerVariables[playerid][pPin] == 0) return SCM(playerid, COLOR_LIGHTGREEN3, "Nu ai un pin setat!\nFoloseste comanda [/setpin] pentru ati seta unul!");
	ShowPlayerDialogEx(playerid, DIALOG_PIN, DIALOG_STYLE_INPUT, " Login Pin", "Conecteaza-te cu pinul setat de tine!", "Ok", "Exit");
	return 1;
}
CMD:changepin(playerid, params[]) {
	if(playerVariables[playerid][pPin] == 0) return SCM(playerid, COLOR_LIGHTGREEN3, "Nu ai un pin setat!\nFoloseste comanda [/setpin] pentru ati seta unul!");
	if(playerVariables[playerid][pPinLogged] == 0) return SCM(playerid, COLOR_LIGHTGREEN3, "Pentru ati schimba pinul trebuie sa fi logat cu el!");
	ShowPlayerDialogEx(playerid, DIALOG_CHANGEPIN, DIALOG_STYLE_INPUT, " Change Pin", "Conecteaza-te cu pinul setat de tine!", "Ok", "Exit");
	return 1;
}
        switch(dialogid) {
		case DIALOG_SETPIN: {
			if(!response) return 1;
			if(!IsNumeric(inputtext)) return SCM(playerid, COLOR_LIGHTGREEN3, "Pinul trebuie sa contina doar numere!");
			if(strlen(inputtext) > 4) return SCM(playerid, COLOR_LIGHTGREEN3, "Pinul trebuie sa fie format din 4 numere!");
			if(strlen(inputtext) < 4) return SCM(playerid, COLOR_LIGHTGREEN3, "Pinul trebuie sa fie format din 4 numere!");
			new pin = strval(inputtext);
			playerVariables[playerid][pPin] = pin;
			playerVariables[playerid][pPinLogged] = 1;
			format(string, sizeof(string), "Pinul tau este %d!", pin);
			SCM(playerid, COLOR_ORANGE, string);
			new query[180];
			format(query, sizeof(query), "UPDATE `users` SET `Pin'='%s' WHERE `ID`='%d'", pin, playerVariables[playerid][pSQLID]);
			mysql_query(SQL, query);
		}
		case DIALOG_PIN: {
			if(!response) return 1;
			new pin = strval(inputtext);
			if(playerVariables[playerid][pPin] != pin) return SCM(playerid, COLOR_RED, "Pin-ul introdus este Invalid!");
			playerVariables[playerid][pPinLogged] = 1;
			SCM(playerid, COLOR_YELLOW, "Te-ai logat cu succes cu pin-ul setat de tine!");
		}
		case DIALOG_CHANGEPIN: {
			if(!response) return 1;
			new pin = strval(inputtext);
			if(playerVariables[playerid][pPin] != pin) return SCM(playerid, COLOR_RED, "Pin-ul introdus este Invalid!");
			ShowPlayerDialogEx(playerid, DIALOG_CHANGEPIN+1, DIALOG_STYLE_INPUT, "New Pin", "Seteaza-ti noul tau pin!", "Ok", "Exit");		
		}
		case DIALOG_CHANGEPIN+1: {
			if(!response) return 1;
			new pin = strval(inputtext);
			playerVariables[playerid][pPin] = pin;
			format(string, sizeof(string), "Noul tau pin este %d!", pin);
			SCM(playerid, COLOR_ORANGE, string);
			new query[180];
			format(query, sizeof(query), "UPDATE `users` SET `Pin`='%s' WHERE `ID`='%d'", pin, playerVariables[playerid][pSQLID]);
			mysql_query(SQL, query);
		}	
	}

Cand scriu /setpin imi aleg pin-ul dar nu mi se pune in baza de date..

Ce as putea face?

 

Edited by Alexandru Alex
Link to comment
Share on other sites

13 answers to this question

Recommended Posts

  • 0

E scris gresit in query-ul de la DIALOG_SETPIN.
Inlocuieste: 

`Pin'='%s'

cu 

`Pin` = %i

Si la DIALOG_CHANGEPIN+1 inlocuieste la fel!

Edited by Akan
  • Haha 1

Discord:
! Akan !#6675

Link to comment
Share on other sites

  • 0
49 minutes ago, Banditul said:

Poti sa ne spui ce tip de data este definit pentru pin in baza de date?

Deasemenea verifica mysql log si vezi daca sunt erori

[22:29:19 05/01/20] [ERROR] CMySQLQuery::Execute - (error #1054) Unknown column '5' in 'where clause' (Query: "UPDATE `users` SET `Pin` = `8` WHERE `id` = `5`")
[18:31:09 05/02/20] [ERROR] CMySQLQuery::Execute - (error #1054) Unknown column '4' in 'where clause' (Query: "UPDATE `users` SET `Pin` = `{` WHERE `id` = `4`")
[22:55:30 05/02/20] [ERROR] CMySQLQuery::Execute - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ID`='4'' at line 1 (Query: "UPDATE `users` SET `Pin'='8' WHERE `ID`='4'")
[22:58:32 05/02/20] [ERROR] CMySQLQuery::Execute - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ID`='4'' at line 1 (Query: "UPDATE `users` SET `Pin'='8' WHERE `ID`='4'")
[00:16:53 05/03/20] [ERROR] CMySQLQuery::Execute - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ID`='4'' at line 1 (Query: "UPDATE `users` SET `Pin'='2104' WHERE `ID`='4'")
[00:19:22 05/03/20] [ERROR] CMySQLQuery::Execute - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ID`='2104'' at line 1 (Query: "UPDATE `users` SET `Pin'='e' WHERE `ID`='2104'")
[00:37:39 05/03/20] [ERROR] CMySQLQuery::Execute - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ID`='4'' at line 1 (Query: "UPDATE `users` SET `Pin'='8' WHERE `ID`='4'")
[00:43:05 05/03/20] [ERROR] CMySQLQuery::Execute - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ID`='4'' at line 1 (Query: "UPDATE `users` SET `Pin'='8' WHERE `ID`='4'")
[00:46:07 05/03/20] [ERROR] CMySQLQuery::Execute - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ID`='4'' at line 1 (Query: "UPDATE `users` SET `Pin'='8' WHERE `ID`='4'")
[00:48:15 05/03/20] [ERROR] CMySQLQuery::Execute - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ID`='4'' at line 1 (Query: "UPDATE `users` SET `Pin'='8' WHERE `ID`='4'")
[00:49:56 05/03/20] [ERROR] CMySQLQuery::Execute - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ID`='4'' at line 1 (Query: "UPDATE `users` SET `Pin'='8' WHERE `ID`='4'")
[00:51:44 05/03/20] [ERROR] CMySQLQuery::Execute - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ID`='4'' at line 1 (Query: "UPDATE `users` SET `Pin'='8' WHERE `ID`='4'")
[00:59:55 05/03/20] [ERROR] CMySQLQuery::Execute - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ID`='4'' at line 1 (Query: "UPDATE `users` SET `Pin'='2104' WHERE `ID`='4'")
[01:17:37 05/03/20] [WARNING] cache_get_row_count - no active cache
[01:18:02 05/03/20] [ERROR] CMySQLQuery::Execute - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ID`='6'' at line 1 (Query: "UPDATE `users` SET `Pin'='2104' WHERE `ID`='6'")
[01:32:25 05/03/20] [WARNING] cache_get_row_count - no active cache
[12:23:13 05/03/20] [WARNING] cache_get_row_count - no active cache
[12:23:28 05/03/20] [ERROR] CMySQLQuery::Execute - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ID`='8'' at line 1 (Query: "UPDATE `users` SET `Pin'='2104' WHERE `ID`='8'")
[13:36:37 05/03/20] [ERROR] CMySQLQuery::Execute - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ID`='8'' at line 1 (Query: "UPDATE `users` SET `Pin'='2104' WHERE `ID`='8'")
[13:43:20 05/03/20] [ERROR] CMySQLQuery::Execute - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ID`='8'' at line 1 (Query: "UPDATE `users` SET `Pin'='2104' WHERE `ID`='8'")
[13:49:10 05/03/20] [WARNING] cache_get_row_count - no active cache
[13:49:25 05/03/20] [ERROR] CMySQLQuery::Execute - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ID`='9'' at line 1 (Query: "UPDATE `users` SET `Pin'='1234' WHERE `ID`='9'")
[13:53:03 05/03/20] [ERROR] CMySQLQuery::Execute - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ID`='9'' at line 1 (Query: "UPDATE `users` SET `Pin'='2103' WHERE `ID`='9'")
[13:56:28 05/03/20] [ERROR] CMySQLQuery::Execute - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ID`='9'' at line 1 (Query: "UPDATE `users` SET `Pin'='2103' WHERE `ID`='9'")

 

Mysql_log

 

iar in baza de date am

Pin int(10)     No None
Link to comment
Share on other sites

  • 0
format(query, sizeof(query), "UPDATE users SET Pin = %i WHERE `ID` = %i", pin, playerVariables[playerid][pSQLID]);

Pune direct asa in locul acelui query al tau de la dialog_setpin.

 

Din mysql_log pe care l-ai trimis se vede ca nu ai inlocuit cum ti-am zis...
`Pin' - asta e gresit, ai ` inainte de Pin si ' dupa Pin ... 2 semne de punctuatie diferite... sterge-le pe amandoua, pune cum ti-am scris eu mai sus codul ca nu sunt necesare semnele de punctuatie in cazul de fata!

Edited by Akan
  • Upvote 1

Discord:
! Akan !#6675

Link to comment
Share on other sites

  • 0
20 minutes ago, Akan said:

format(query, sizeof(query), "UPDATE users SET Pin = %i WHERE `ID` = %i", pin, playerVariables[playerid][pSQLID]);

Pune direct asa in locul acelui query al tau de la dialog_setpin.

 

Din mysql_log pe care l-ai trimis se vede ca nu ai inlocuit cum ti-am zis...
`Pin' - asta e gresit, ai ` inainte de Pin si ' dupa Pin ... 2 semne de punctuatie diferite... sterge-le pe amandoua, pune cum ti-am scris eu mai sus codul ca nu sunt necesare semnele de punctuatie in cazul de fata!

sper sa fie cum zictu, acum compilez si verific

 

Link to comment
Share on other sites

  • 0
22 minutes ago, Akan said:

format(query, sizeof(query), "UPDATE users SET Pin = %i WHERE `ID` = %i", pin, playerVariables[playerid][pSQLID]);

Pune direct asa in locul acelui query al tau de la dialog_setpin.

 

Din mysql_log pe care l-ai trimis se vede ca nu ai inlocuit cum ti-am zis...
`Pin' - asta e gresit, ai ` inainte de Pin si ' dupa Pin ... 2 semne de punctuatie diferite... sterge-le pe amandoua, pune cum ti-am scris eu mai sus codul ca nu sunt necesare semnele de punctuatie in cazul de fata!

+1 RESPECT, mersi mult ❤️

Link to comment
Share on other sites

  • 0
Acum 2 minute, Alexandru Alex a spus:

+1 RESPECT, mersi mult ❤️

Cu multa placere! :) Vezi sa inlocuiesti la fel si la  DIALOG_CHANGEPIN+1  ca sa functioneze si cand iti schimbi PIN-ul. :) Bafta!

Discord:
! Akan !#6675

Link to comment
Share on other sites

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.