MySQL problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL problem (
/showthread.php?tid=642471)
MySQL problem -
XHunterZ - 01.10.2017
so i tried to select an integer from a column called town from a table called playerData, if it is 0, it spawns you at SF, if its 1 it spawns you at LV, if its -1, it asks you for a location to spawn.
So i created a variable called townspawn to select from the table the value, but it always select the value as 1, even it is 0 at the column, so what is the problem in the code?
Код:
new townQuery[200];
new townspawn = format(townQuery, sizeof(townQuery), "SELECT `town` FROM `playerdata` WHERE `playerName` = '%s'", playerNamee);
if(townspawn == -1)
{
ShowPlayerDialog(playerid, DIALOG_TOWN, DIALOG_STYLE_LIST, "Choose Spawn Town", "San Fierro \nLas Venturas", "Choose", "");
TogglePlayerSpectating(playerid, true);
return 1;
}
else if(townspawn == 0)
{
playerData[playerid][playerTown] = SF;
}
else if(townspawn == 1)
{
playerData[playerid][playerTown] = LV;
}
Re: MySQL problem -
SyS - 01.10.2017
You are just formatting a string.The query need to be executed and then fetch result.
Re: MySQL problem -
XHunterZ - 01.10.2017
Quote:
Originally Posted by SyS
You are just formatting a string.The query need to be executed and then fetch result.
|
and how to do that?
Re: MySQL problem -
biker122 - 01.10.2017
Which version of MySQL are you using?
Re: MySQL problem -
XHunterZ - 01.10.2017
StrickenKid's MySQL Plugin - v2.1.1 (
https://sampforum.blast.hk/showthread.php?tid=122983)
Re: MySQL problem -
biker122 - 01.10.2017
pawn Код:
new townQuery[200];
format(townQuery, sizeof(townQuery), "SELECT `town` FROM `playerdata` WHERE `playerName` = '%s'", playerNamee);
mysql_query(townQuery), mysql_store_result();
if(mysql_num_rows() != 0)
{
mysql_fetch_row_format(townQuery);
sscanf(townQuery, "i", townspawn);
mysql_free_result();
}
switch(townspawn)
{
case -1:
{
ShowPlayerDialog(playerid, DIALOG_TOWN, DIALOG_STYLE_LIST, "Choose Spawn Town", "San Fierro \nLas Venturas", "Choose", "");
TogglePlayerSpectating(playerid, true);
}
case 0:
{
playerData[playerid][playerTown] = SF;
}
case 1:
{
playerData[playerid][playerTown] = LV;
}
}
Re: MySQL problem -
Zeth - 01.10.2017
Quote:
Originally Posted by XHunterZ
|
Why are you using a depreciated and older MySQL plugin which was last updated in 2011? Use a better and simplified verison of
Blueg's MySQL
Re: MySQL problem -
XHunterZ - 01.10.2017
Quote:
Originally Posted by biker122
pawn Код:
new townQuery[200]; format(townQuery, sizeof(townQuery), "SELECT `town` FROM `playerdata` WHERE `playerName` = '%s'", playerNamee); mysql_query(townQuery), mysql_store_result(); if(mysql_num_rows() != 0) { mysql_fetch_row_format(townQuery); sscanf(townQuery, "i", townspawn); mysql_free_result(); } switch(townspawn) { case -1: { ShowPlayerDialog(playerid, DIALOG_TOWN, DIALOG_STYLE_LIST, "Choose Spawn Town", "San Fierro \nLas Venturas", "Choose", ""); TogglePlayerSpectating(playerid, true); } case 0: { playerData[playerid][playerTown] = SF; } case 1: { playerData[playerid][playerTown] = LV; } }
|
thank you so much ill try it +rep
Re: MySQL problem -
XHunterZ - 01.10.2017
Quote:
Originally Posted by Debjit
Why are you using a depreciated and older MySQL plugin which was last updated in 2011? Use a better and simplified verison of Blueg's MySQL
|
but the gamemode is huge and ill have to change all the functions of MySQL in the gamemode.
Re: MySQL problem -
XHunterZ - 01.10.2017
error 017: undefined symbol "mysql_fetch_row_format"
should i replace it with mysql_fetch_row_data?