SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 25/08/2017, 01:03 PM   #11
skuller12
Big Clucker
 
Join Date: Feb 2015
Location: Galati, Romania
Posts: 101
Reputation: 0
Default Re: cache_get_row_int error

Code:
In CMD:login

mysql_format(kapcsolat, Query, sizeof(Query), "SELECT * FROM players WHERE name = '%e' AND password = '%e'", nev, Whirlpool(jelszo));
mysql_tquery(kapcsolat, Query, "Login","ds",playerid,Whirlpool(jelszo));

fpublic Login(playerid, jelszo[])
{
	new rows, fields;
	cache_get_data(rows, fields, kapcsolat);
	if(!rows) return SendClientMessage(playerid, -1, "* Wrong password.");
	else
	{
	    SendClientMessage(playerid,-1, "You have successfully logged in!");
	    Belepve[playerid] = true;
	    Score[playerid] = cache_get_field_content_int(0, "score", kapcsolat);
		SpawnPlayer(playerid);
	}
}
skuller12 is offline   Reply With Quote
Old 25/08/2017, 01:17 PM   #12
SecretMax
Little Clucker
 
Join Date: May 2017
Location: Hungary
Posts: 26
Reputation: 0
Default Re: cache_get_row_int error

Thank you very much, what was the mistake?
SecretMax is offline   Reply With Quote
Old 25/08/2017, 01:23 PM   #13
skuller12
Big Clucker
 
Join Date: Feb 2015
Location: Galati, Romania
Posts: 101
Reputation: 0
Default Re: cache_get_row_int error

There are plenty ...
skuller12 is offline   Reply With Quote
Old 25/08/2017, 01:26 PM   #14
SecretMax
Little Clucker
 
Join Date: May 2017
Location: Hungary
Posts: 26
Reputation: 0
Default Re: cache_get_row_int error

Would you please write it down? I would like to learn to do so any other time.
SecretMax is offline   Reply With Quote
Old 25/08/2017, 01:36 PM   #15
skuller12
Big Clucker
 
Join Date: Feb 2015
Location: Galati, Romania
Posts: 101
Reputation: 0
Default Re: cache_get_row_int error

The code to extract if a player exists in db is:

Ex:
Code:
mysql_format(handle, gString, 256, "SELECT * FROM `users` WHERE `Name` = '%e' AND `Password` = '%e'", GetName(playerid), password);
mysql_tquery(handle, gString, "WhenPlayerLogin", "d", playerid);

function WhenPlayerLogin(playerid)
{
new rows, fields;
cache_get_data(rows, fields, handle); // rows -> verify for player if he have account
if(!rows) return SendClientMessage(playerid, -1, "* You don't have account or wrong password."); // verify if player have account(name) and password exist
else
{
// Your code here...
}
return 1;
}
Not use for select from db:

Code:
format(gString, 256, "SELECT * FROM `users` WHERE `Name` =  '%s' AND `Password` = '%s'", GetName(playerid), password);
The code correct is:

Code:
mysql_format(handle, gString, 256, "SELECT * FROM `users` WHERE `Name` =  '%e' AND `Password` = '%e'", GetName(playerid), password);
There is examples http://wiki.sa-mp.com/wiki/Format for formating string

Edit: For single player extract:

Code:
mysql_format(handle, gString, 256, "SELECT * FROM `users` WHERE `Name` = '%e' AND `Password` = '%e'", GetName(playerid), password);
mysql_tquery(handle, gString, "WhenPlayerLogin", "d", playerid);

function WhenPlayerLogin(playerid)
{
new rows, fields, score, name[24];
cache_get_data(rows, fields, handle); // rows -> verify for player if he have account
if(!rows) return SendClientMessage(playerid, -1, "* You don't have account or wrong password."); // verify if player have account(name) and password exist
else
{
cache_get_field_content(0, "name", name, handle, 24);
score = cache_get_field_content_int(0, "score", handle);
}
return 1;
}
For arrays extractI use while)

Code:
mysql_tquery(handle, "SELECT * FROM `ban` WHERE `ID` > '0'", "BanCheck", "");

function BanCheck
{
new rows, fields, i = 0, time, id;
cache_get_data(rows, fields, handle);
if(!rows) return 1; // Not action
while(i < rows)
{
id = cache_get_field_content_int(i, "ID", handle);
time = cache_get_field_content_int(i, "time", handle);
if(gettime() >= time)
{
mysql_format(handle, gString, 256, "DELETE * FROM `bans` WHERE `ID` = '%d'", id);
mysql_tquery(handle, gString, "", "");
}
i++;
}
}
skuller12 is offline   Reply With Quote
Old 25/08/2017, 01:39 PM   #16
SecretMax
Little Clucker
 
Join Date: May 2017
Location: Hungary
Posts: 26
Reputation: 0
Default Re: cache_get_row_int error

Okay, thank you!
SecretMax is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cache_get_row_int error Japanda Scripting Help 2 15/12/2015 04:36 PM
[Help]Problem with cache_get_row_int [ REP ++ ] buburuzu19 Scripting Help 2 14/01/2015 10:09 PM
MySQL Help [Cache_get_row_int firemanjv Scripting Help 4 17/01/2014 09:52 AM
cache_get_row_int and cache_get_row_float AphexCCFC Scripting Help 1 17/09/2013 03:38 PM
cache_get_row_int(...) - An error occured during the datatype conversion. zombieking Scripting Help 2 28/05/2013 10:21 AM


All times are GMT. The time now is 12:55 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.