SA-MP Forums Archive
Vehicle charging error[Mysql] - 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: Vehicle charging error[Mysql] (/showthread.php?tid=423304)



Vehicle charging error[Mysql] - Enrico_Matthes - 17.03.2013

Hi
I have. the problem when a user buys a car and then relogt me smears from the server but if I go in the car and put in mysql tablle store to 0 it will work again.

PHP код:
stock getPlayerAutos(playerid)
{
    new 
pAutos[128];
    new 
minpAuto;
    new 
maxpAuto;
    
format(query,sizeof(query),"SELECT id FROM autos WHERE besitzer='%s' AND laden='1' ORDER by id ASC",SpielerName(playerid));
    
mysql_query(query);
    
mysql_store_result();
    if(
mysql_num_rows()>0)
    {
        
mysql_fetch_field("id",data);
        
minpAuto=strval(data);
    }
    else
    {
        
minpAuto=0;
    }
    
mysql_free_result();
    
format(query,sizeof(query),"SELECT id FROM autos WHERE besitzer='%s' AND laden='1' ORDER by id DESC",SpielerName(playerid));
    
mysql_query(query);
    
mysql_store_result();
    if(
mysql_num_rows()>0)
    {
        
mysql_fetch_field("id",data);
        
maxpAuto=strval(data);
    }
    else
    {
        
maxpAuto=0;
    }
    
mysql_free_result();
    for(new 
i=minpAutoi<=maxpAutoi++)
    {
        
format(query,sizeof(query),"SELECT id FROM autos WHERE laden='1' AND id='%i' AND besitzer='%s'",i,SpielerName(playerid));
        
mysql_query(query);
        
mysql_store_result();
        if(
mysql_num_rows()==1)
        {
            if(
i!=maxpAuto)
            {
                
format(pAutos,sizeof(pAutos),"%s%i,",pAutos,i);
            }
            else
            {
                
format(pAutos,sizeof(pAutos),"%s%i",pAutos,i);
            }
        }
        
mysql_free_result();
    }
    return 
pAutos;
}
//Problem gefunden by Enrico
stock loadPlayerAutos(playerid)
{
    
format(query,sizeof(query),"SELECT * FROM autos WHERE besitzer='%s' AND laden='1'",SpielerName(playerid));
    
mysql_query(query,1234,playerid,mysql_car);
    return 
1;




Re: Vehicle charging error[Mysql] - Misiur - 17.03.2013

Dude, you should really optimise your code, and use threaded queries. You can do it using single query, not firing one after another. What are you trying to achieve with your code?