I need help to check if player exist MYSQL
#1

Someone could help me to fix it? See if player exist in MYSQL DB?

Why every time is going to:
Код:
	else {
    	QuemReferenciou(playerid);
    	SendClientMessage(playerid, COLOR_LIGHTRED, "THIS PLAYER IS NOT FOUND!");
	}
Even if this player exist...

What i'm doing worng?

CODE:

Код:
	else if(dialogid == 28) {
        new nlocalreffer[30];
        if(!response) {
        	SendClientMessage(playerid, -1, "YOU SELECT NO... SO NO ONE REFFER YOU!");
        	nlocalreffer = "Empty";
        	reffer[playerid] = nlocalreffer;
        	firstlogin[playerid] = false;
        	ChangeClass(playerid);
        }
        else if(response) {
	        if(!strlen(inputtext)) {
	        	SendClientMessage(playerid, -1, "YOU DONT WRITE A NAME... SO NO ONE REFFER YOU!");
	        	nlocalreffer = "Empty";
	        	reffer[playerid] = nlocalreffer;
	        	firstlogin[playerid] = false;
	        	ChangeClass(playerid);
	        }
	        else {
	            format(nlocalreffer, sizeof nlocalreffer, inputtext);
	            if(!strcmp(nlocalreffer, PlayerName(playerid), true)) {
	                SendClientMessage(playerid, COLOR_LIGHTRED, "YOU CAN NOT PUT YOUR OWN NAME!");
	                QuemReferenciou(playerid);
	                return 1;
	            }
	            else { // sucesso
				    new Nameid[30], refferquery[160];
		            format(nlocalreffer, sizeof nlocalreffer, inputtext);
					mysql_format(ConnectMYSQL, refferquery, sizeof refferquery, "SELECT `Username` FROM accounts WHERE Username = '%s' LIMIT 1", Nameid);
					mysql_tquery(ConnectMYSQL, refferquery, "CheckRefferExist", "iss", playerid, Nameid, nlocalreffer);
	            }
	        }
	    }
	}
Код:
forward CheckRefferExist(playerid, nrinput[30]); public CheckRefferExist(playerid, nrinput[30]) {
	if(cache_get_row_count(ConnectMYSQL) == 1) {
    	reffer[playerid] = nrinput;
    	new string[80];
		format(string, sizeof(string), "Your reffer: %s!", reffer[playerid] );
		SendClientMessage(playerid, COLOR_LIGHTRED, string);
		firstlogin[playerid] = false;
		ChangeClass(playerid);
	}
	else {
    	QuemReferenciou(playerid);
    	SendClientMessage(playerid, COLOR_LIGHTRED, "THIS PLAYER IS NOT FOUND!");
	}
	return 1;
}
Код:
forward QuemReferenciou(playerid); public QuemReferenciou(playerid) {
	ShowPlayerDialog(playerid,28, DIALOG_STYLE_INPUT, "Reffer", "A player from the server called you here to play?\nNo? Leave this question blank box\nYes? Insert him name inside box!\n\n\nCall people to play here and earn rewards when your guest get some experience points\n====================================\n10 exp = 5.000$\n30 exp = 15.000$\n60 exp = 30.000$\n100 exp = 1 VIP days\n150 exp = 3 VIP days\n300 exp = 7 VIP days\n====================================", "Yes", "No");
}
Reply
#2

(MAYBE) you need this
PHP код:
cache_get_field_content(0"Username"reffer[playerid], ConnectMYSQL124); 
No? what are you meaning by reffer?
Reply
#3

Quote:
Originally Posted by Shinja
Посмотреть сообщение
(MAYBE) you need this
PHP код:
cache_get_field_content(0"Username"reffer[playerid], ConnectMYSQL124); 
No? what are you meaning by reffer?
I gave you a REP, but idk what u mean

Reffer is who call you to play lthe server... Like is on Intense Life server...

Код:
forward QuemReferenciou(playerid); public QuemReferenciou(playerid) {
	ShowPlayerDialog(playerid,28, DIALOG_STYLE_INPUT, "Reffer", "A player from the server called you here to play?\nNo? Leave this question blank box\nYes? Insert him name inside box!\n\n\nCall people to play here and earn rewards when your guest get some experience points\n====================================\n10 exp = 5.000$\n30 exp = 15.000$\n60 exp = 30.000$\n100 exp = 1 VIP days\n150 exp = 3 VIP days\n300 exp = 7 VIP days\n====================================", "Yes", "No");
}
I'm trapped on this check is player invite exist or not, could you help me to fix?
Reply
#4

topic edited
Reply
#5

You dont even ask if the player exsits.
I dont know your mysql plugin version so well, send me the code where you check if the username exists when a player is connecting to your server and i will fix the referrer problem for you.
Reply
#6

Quote:
Originally Posted by ubunttu
Посмотреть сообщение
mysql_format(ConnectMYSQL, refferquery, sizeof refferquery, "SELECT `Username` FROM accounts WHERE Username = '%s' LIMIT 1", Nameid);
mysql_tquery(ConnectMYSQL, refferquery, "CheckRefferExist", "iss", playerid, Nameid, nlocalreffer);
What is this Nameid?
Change it to inputtext or nlocalreffer

And in your CheckRefferExist there are 2 params while you gave 3 in tquery

PHP код:
mysql_format(ConnectMYSQLrefferquerysizeof(refferquery), "SELECT `Username` FROM accounts WHERE Username = '%s' LIMIT 1"inputtext);
                    
mysql_tquery(ConnectMYSQLrefferquery"CheckRefferExist""iss"playeridinputtext); 
And i think your variable nlocalreffer is useless since the name is saved in inputtext
Reply
#7

Quote:
Originally Posted by Shinja
Посмотреть сообщение
What is this Nameid?
Change it to inputtext or nlocalreffer

And in your CheckRefferExist there are 2 params while you gave 3 in tquery

PHP код:
mysql_format(ConnectMYSQLrefferquerysizeof(refferquery), "SELECT `Username` FROM accounts WHERE Username = '%s' LIMIT 1"inputtext);
                    
mysql_tquery(ConnectMYSQLrefferquery"CheckRefferExist""iss"playeridinputtext); 
And i think your variable nlocalreffer is useless since the name is saved in inputtext
Look the main code, i was edited

Quote:
Originally Posted by GangstaSunny
Посмотреть сообщение
You dont even ask if the player exsits.
I dont know your mysql plugin version so well, send me the code where you check if the username exists when a player is connecting to your server and i will fix the referrer problem for you.
Код:
public OnPlayerConnect(playerid) {
    new query[512];
    new Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
    mysql_format(ConnectMYSQL, query, sizeof(query), "SELECT * FROM `accounts` WHERE `Username` = '%s'", Nome(playerid) ); //SELECT * FROM accounts WHERE Name = %s TROQUE PELA QUAL ESTA NO SEU BANCO DE DADOS
    mysql_function_query(ConnectMYSQL, query, true, "OnConnection","i",playerid);
Код:
forward OnConnection(playerid); public OnConnection(playerid) {
	new rows, fields;
	cache_get_data(rows, fields);
	if(rows) {
		ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Your account has been found - Log-in", "Your account has been found in our database.\nPlease insert your password to continue.", "Log-in", "Quit");
	}
	else {
		ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Your account hasn't been found - Register", "Your account couldn't be found in our database.\nPlease insert a new password to complete the registration.", "Register", "Quit");
	}
	return 1;
}
Reply
#8

uppppp
Reply
#9

PHP код:
else if(dialogid == 28)
{
    new 
nlocalreffer[30];
    if(!
response)
    {
        
SendClientMessage(playerid, -1"YOU SELECT NO... SO NO ONE REFFER YOU!");
        
nlocalreffer "Empty";
        
reffer[playerid] = nlocalreffer;
        
firstlogin[playerid] = false;
        
ChangeClass(playerid);
    }
    else if(
response)
    {
        if(!
strlen(inputtext))
        {
            
SendClientMessage(playerid, -1"YOU DONT WRITE A NAME... SO NO ONE REFFER YOU!");
            
nlocalreffer "Empty";
            
reffer[playerid] = nlocalreffer;
            
firstlogin[playerid] = false;
            
ChangeClass(playerid);
        }
        else
        {
            
format(nlocalreffersizeof nlocalrefferinputtext);
            if(!
strcmp(nlocalrefferPlayerName(playerid), true))
            {
                
SendClientMessage(playeridCOLOR_LIGHTRED"YOU CAN NOT PUT YOUR OWN NAME!");
                
QuemReferenciou(playerid);
                return 
1;
            }
            else
            { 
// sucesso
            
                
new query[160], refferername[MAX_PLAYER_NAME+1];
                
format(refferername,sizeof(refferername),"%s",inputtext);
                
mysql_format(ConnectMYSQLquerysizeof(query), "SELECT Username FROM `accounts` WHERE `Username` = '%s'"refferername ); //SELECT * FROM accounts WHERE Name = %s TROQUE PELA QUAL ESTA NO SEU BANCO DE DADOS
                
mysql_function_query(ConnectMYSQLquerytrue"CheckRefferExist","is",playerid,refferername);
            }
        }
    }

Reply
#10

edited, look other page
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)