Vehicle charging error[Mysql]
#1

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;

Reply
#2

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?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)