SA-MP Forums Archive
Mysql Loading Help ! [+rep] - 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 Loading Help ! [+rep] (/showthread.php?tid=567318)



Mysql Loading Help ! [+rep] - MoemenWalid - 12.03.2015

Okay , i have tried too many things but there is a proplem with the loading the data saves in the mysql but it doesnt load here is the codes am using

PHP код:
stock LoadATMS()
{
    
printf("[LoadAtms] Loading data from database...");
    
mysql_function_query(MainPipeline"SELECT * FROM `atms`"true"OnLoadAtms""");

and

PHP код:
forward OnLoadATMS();
public 
OnLoadATMS()
{
    new 
irowsfieldstmp[128];
    
cache_get_data(rowsfieldsMainPipeline);
    while(
rows)
    {
        
cache_get_field_content(i"VW"tmpMainPipeline); ATM[i][atmVW] = strval(tmp);
        
cache_get_field_content(i"Int"tmpMainPipeline); ATM[i][atmInt] = strval(tmp);
        
cache_get_field_content(i"Modelz"tmpMainPipeline); ATM[i][atmModelz] = strval(tmp);
        
cache_get_field_content(i"PosX"tmpMainPipeline); ATM[i][atmPosX] = floatstr(tmp);
        
cache_get_field_content(i"PosY"tmpMainPipeline); ATM[i][atmPosY] = floatstr(tmp);
        
cache_get_field_content(i"PosZ"tmpMainPipeline); ATM[i][atmPosZ] = floatstr(tmp);
        
cache_get_field_content(i"Angle"tmpMainPipeline); ATM[i][atmAngle] = floatstr(tmp);
        
RenderATM(i);
        
i++;
    }
    if(
0printf("[LoadATMS] %d atms rehashed/loaded."i);
    else 
printf("[LoadATMS] Failed to load any atms.");

If somone can please fix me both by changing them to Yini or atleast help me to fix this bug it doesnt load.

Here the save codes.
PHP код:
stock SaveATM(id)
{
    new 
string[512];
    
format(stringsizeof(string), "UPDATE `atms` SET \
        `VW`=%d, \
        `Int`=%d, \
        `Modelz`=%d, \
        `PosX`=%f, \
        `PosY`=%f, \
        `PosZ`=%f, \
        `Angle`=%f WHERE `id`=%d"
,
        
ATM[id][atmVW],
        
ATM[id][atmInt],
        
ATM[id][atmModelz],
        
ATM[id][atmPosX],
        
ATM[id][atmPosY],
        
ATM[id][atmPosZ],
        
ATM[id][atmAngle],
        
id+1
    
); // Array starts from zero, MySQL starts at 1 (this is why we are adding one).
    
mysql_function_query(MainPipelinestringfalse"OnQueryFinish""i"SENDDATA_THREAD);




Re: Mysql Loading Help ! [+rep] - FOTIS6 - 12.03.2015

Programming languages are case sensitive, meaning that if you are calling OnLoadAtms but you have forwarded OnLoadATMS the script will simply not find the callback and will skip executing it while OnLoadATMS will not even be called. To fix that replace this:

Код:
mysql_function_query(MainPipeline, "SELECT * FROM `atms`", true, "OnLoadAtms", "");
with this:

Код:
mysql_function_query(MainPipeline, "SELECT * FROM `atms`", true, "OnLoadATMS", "");
The rest of the code seems fine to me, although there is no need to store everything in strings and then use strval and floatstr since there are functions available like cache_get_field_content_int and cache_get_field_content_float.


Re: Mysql Loading Help ! [+rep] - TakeiT - 12.03.2015

To add on to FOTIS, your tables are case sensitive as well. So make sure the table in the database is called atms and not ATMS or something


Re: Mysql Loading Help ! [+rep] - MoemenWalid - 13.03.2015

Quote:
Originally Posted by FOTIS6
Посмотреть сообщение
Programming languages are case sensitive, meaning that if you are calling OnLoadAtms but you have forwarded OnLoadATMS the script will simply not find the callback and will skip executing it while OnLoadATMS will not even be called. To fix that replace this:

Код:
mysql_function_query(MainPipeline, "SELECT * FROM `atms`", true, "OnLoadAtms", "");
with this:

Код:
mysql_function_query(MainPipeline, "SELECT * FROM `atms`", true, "OnLoadATMS", "");
The rest of the code seems fine to me, although there is no need to store everything in strings and then use strval and floatstr since there are functions available like cache_get_field_content_int and cache_get_field_content_float.
WOAH !! THANKS BRO. [+repped you both]