doesn't save vehicles mysql
#1

PHP Code:
stock loadvehs(vehicleid)
{
    new
        
Query500 ],
        
Float:mPos[3];
    
format(Query,sizeof(Query), "SELECT `ID` FROM `masinos` WHERE `ID` = '%i'"GetVehicleID(vehicleid));
    
mysql_query(Query);
    
    if(
mysql_num_rows() > 0)
    {
                
format(Query,sizeof(Query), "INSERT INTO `masinos` (masinosid) VALUES ('%s')"GetVehicleName(vehicleid));
                
mysql_query(Query);
    }
    else
    {
        new 
result[200];
        
format(Query,sizeof(Query), "SELECT * FROM `masinos` WHERE `ID` = '%s'"GetVehicleID(vehicleid));
        
mysql_query(Query);
        
mysql_store_result();
        
mysql_retrieve_row();
        
mysql_fetch_field_row(result"mxPos");
        
mPos] = floatstr(result);
        
mysql_fetch_field_row(result"myPos");
        
mPos] = floatstr(result);
        
mysql_fetch_field_row(result"mzPos");
        
mPos] = floatstr(result);
        
SetVehiclePos(vehicleidmPos[0], mPos[1], mPos[2]);
        
mysql_fetch_field_row(result"degalai");
        
masina.degalai[vehicleid] = strval(result);
        
mysql_fetch_field_row(result"rida");
        
masina.rida[vehicleid] = floatstr(result);
    }
    return 
1;
}
stock savevehs(vehicleid)
{
    new 
Query500 ], Float:mPos];
    
GetVehiclePos(vehicleidmPos[0], mPos[1], mPos[2]);
    
format(Query,sizeof(Query), "UPDATE `masinos` SET \
    \
        mxPos = %f,            \
        myPos = %f,            \
        mzPos = %f,            \
        degalai = %.1f,        \
        rida = %.1f,        \
    WHERE `ID` = '%s'"
,
    
mPos],
    
mPos],
    
mPos],
    
masina.degalai[vehicleid],
    
masina.rida[vehicleid],
    
GetVehicleID(vehicleid));
    
mysql_query(Query);
    return 
1;

there are my save functions
PHP Code:
public OnVehicleStreamIn(vehicleidforplayerid)
{
    
loadvehs(vehicleid);
    return 
1;
}
public 
OnVehicleStreamOut(vehicleidforplayerid)
{
    
savevehs(vehicleid);
    return 
1;

I put them here, mysql debug doesn't give an error or anything, i don't get it

--EDIT--
I made getvehicleid to
PHP Code:
stock GetVehicleID(vehicleid)
{
    new    
Query500 ];
    
format(Query,sizeof(Query), "SELECT `masinosid` FROM `masinos` WHERE `masinosid` = '%s'"GetVehicleName(vehicleid));
    return 
1;

now it gives
CMySQLHandler::Query(INSERT INTO `masinos` (masinosid) VALUES ('Sentinel')) - An error has occured. (Error ID: 2014, Commands out of sync; you can't run this command now)
this error
Reply
#2

Check your savevehs(); function.
You save
PHP Code:
GetVehicleID(vehicleid); 
as a string, use
PHP Code:
%
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)