mysql, carro 1 nгo carrega
#1

o veiculo com ID 1 na database nгo carrega.

pawn Код:
function:LoadVehicles()
{
    //CreateVehicle(422, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 1, 60);
    mysql_function_query(MYSQLConnection, "SELECT * FROM vehicleinfo LIMIT 2000", true, "r@LoadVehicles", "d", 11);
    return 1;
}

function:r@LoadVehicles()
{
    new values[32], rows, fields;
    cache_get_data(rows, fields);  
    new i = 1;  
    for( ; i < rows; i++)    
    {              
        cache_get_field_content(i, "ID", values, MYSQLConnection);
        vehicleinfo[i][vSQLID] = strval(values);                                    
        cache_get_field_content(i, "Model", values, MYSQLConnection);
        vehicleinfo[i][vModel] = strval(values);                      
        cache_get_field_content(i, "Color1", values, MYSQLConnection);
        vehicleinfo[i][vColors1] = strval(values);        
        cache_get_field_content(i, "Color2", values, MYSQLConnection);
        vehicleinfo[i][vColors2] = strval(values);                
        cache_get_field_content(i, "Mod1", values, MYSQLConnection);
        vehicleinfo[i][vMod][0] = strval(values);                          
        cache_get_field_content(i, "Mod2", values, MYSQLConnection);
        vehicleinfo[i][vMod][1] = strval(values);        
        cache_get_field_content(i, "Mod3", values, MYSQLConnection);
        vehicleinfo[i][vMod][2] = strval(values);                          
        cache_get_field_content(i, "Mod4", values, MYSQLConnection);
        vehicleinfo[i][vMod][3] = strval(values);        
        cache_get_field_content(i, "Mod5", values, MYSQLConnection);
        vehicleinfo[i][vMod][4] = strval(values);        
        cache_get_field_content(i, "Mod6", values, MYSQLConnection);
        vehicleinfo[i][vMod][5] = strval(values);        
        cache_get_field_content(i, "Mod7", values, MYSQLConnection);
        vehicleinfo[i][vMod][6] = strval(values);            
        cache_get_field_content(i, "Mod8", values, MYSQLConnection);
        vehicleinfo[i][vMod][7] = strval(values);          
        cache_get_field_content(i, "Mod9", values, MYSQLConnection);
        vehicleinfo[i][vMod][8] = strval(values);            
        cache_get_field_content(i, "Mod10", values, MYSQLConnection);
        vehicleinfo[i][vMod][9] = strval(values);                  
        cache_get_field_content(i, "Mod11", values, MYSQLConnection);
        vehicleinfo[i][vMod][10] = strval(values);        
        cache_get_field_content(i, "Mod12", values, MYSQLConnection);
        vehicleinfo[i][vMod][11] = strval(values);        
        cache_get_field_content(i, "Mod13", values, MYSQLConnection);
        vehicleinfo[i][vMod][12] = strval(values);        
        cache_get_field_content(i, "Health", values, MYSQLConnection);
        vehicleinfo[i][vHealth] = floatstr(values);          
        cache_get_field_content(i, "Owner", vehicleinfo[i][vOwner], MYSQLConnection);      
        cache_get_field_content(i, "Type", values, MYSQLConnection);
        vehicleinfo[i][vType] = strval(values);                            
        cache_get_field_content(i, "RentPrice", values, MYSQLConnection);
        vehicleinfo[i][vRentPrice] = strval(values);      
        cache_get_field_content(i, "Price", values, MYSQLConnection);
        vehicleinfo[i][vPrice] = strval(values);      
        cache_get_field_content(i, "Fuel", values, MYSQLConnection);
        vehicleinfo[i][vFuel] = strval(values);                  
        cache_get_field_content(i, "Job", values, MYSQLConnection);
        vehicleinfo[i][vJob] = strval(values);        
        cache_get_field_content(i, "Buyable", values, MYSQLConnection);
        vehicleinfo[i][vBuyable] = strval(values);
        cache_get_field_content(i, "Locked", values, MYSQLConnection);
        vehicleinfo[i][vLocked] = strval(values);
        cache_get_field_content(i, "Rentable", values, MYSQLConnection);
        vehicleinfo[i][vRentable] = strval(values);  
        cache_get_field_content(i, "ParkX", values, MYSQLConnection);
        vehicleinfo[i][vParkPos1] = floatstr(values);      
        cache_get_field_content(i, "ParkY", values, MYSQLConnection);
        vehicleinfo[i][vParkPos2] = floatstr(values);      
        cache_get_field_content(i, "ParkZ", values, MYSQLConnection);
        vehicleinfo[i][vParkPos3] = floatstr(values);                        
        cache_get_field_content(i, "ParkAngle", values, MYSQLConnection);
        vehicleinfo[i][vParkPos4] = floatstr(values);        
        cache_get_field_content(i, "fCarID", values, MYSQLConnection);
        vehicleinfo[i][vFCarID] = strval(values);                            
        cache_get_field_content(i, "Alarm", values, MYSQLConnection);
        vehicleinfo[i][vAlarm] = strval(values);        
        cache_get_field_content(i, "Locks", values, MYSQLConnection);
        vehicleinfo[i][vLock] = strval(values);                                    
        cache_get_field_content(i, "Immobiliser", values, MYSQLConnection);
        vehicleinfo[i][vImmobiliser] = strval(values);      
        cache_get_field_content(i, "Bought", values, MYSQLConnection);
        vehicleinfo[i][vBought] = strval(values);                
        cache_get_field_content(i, "World", values, MYSQLConnection);
        vehicleinfo[i][vWorld] = strval(values);    
        cache_get_field_content(i, "Weapon1", values, MYSQLConnection);
        vehicleinfo[i][vWeapons1] = strval(values);          
        cache_get_field_content(i, "Weapon2", values, MYSQLConnection);
        vehicleinfo[i][vWeapons2] = strval(values);            
        cache_get_field_content(i, "Weapon3", values, MYSQLConnection);
        vehicleinfo[i][vWeapons3] = strval(values);          
        cache_get_field_content(i, "Ammo1", values, MYSQLConnection);
        vehicleinfo[i][vAmmo1] = strval(values);      
        cache_get_field_content(i, "Ammo2", values, MYSQLConnection);
        vehicleinfo[i][vAmmo2] = strval(values);        
        cache_get_field_content(i, "Ammo3", values, MYSQLConnection);
        vehicleinfo[i][vAmmo3] = strval(values);            
        cache_get_field_content(i, "XMRadio", values, MYSQLConnection);
        vehicleinfo[i][vXMRadio] = strval(values);            
        cache_get_field_content(i, "Insurance", values, MYSQLConnection);        
        vehicleinfo[i][vInsurance] = strval(values);          
        new vehicleadd = AddStaticVehicleEx(vehicleinfo[i][vModel], vehicleinfo[i][vParkPos1],vehicleinfo[i][vParkPos2],vehicleinfo[i][vParkPos3],vehicleinfo[i][vParkPos4],vehicleinfo[i][vColors1],vehicleinfo[i][vColors2], -1);  
        SetVehicleZAngle(vehicleadd, vehicleinfo[i][vParkPos4]);        
        AddVehicleComponent(vehicleadd, vehicleinfo[i][vMod][0]);
        AddVehicleComponent(vehicleadd, vehicleinfo[i][vMod][1]);
        AddVehicleComponent(vehicleadd, vehicleinfo[i][vMod][2]);
        AddVehicleComponent(vehicleadd, vehicleinfo[i][vMod][3]);
        AddVehicleComponent(vehicleadd, vehicleinfo[i][vMod][4]);
        AddVehicleComponent(vehicleadd, vehicleinfo[i][vMod][5]);
        AddVehicleComponent(vehicleadd, vehicleinfo[i][vMod][6]);
        AddVehicleComponent(vehicleadd, vehicleinfo[i][vMod][7]);
        AddVehicleComponent(vehicleadd, vehicleinfo[i][vMod][8]);
        AddVehicleComponent(vehicleadd, vehicleinfo[i][vMod][9]);
        AddVehicleComponent(vehicleadd, vehicleinfo[i][vMod][10]);
        AddVehicleComponent(vehicleadd, vehicleinfo[i][vMod][11]);
        AddVehicleComponent(vehicleadd, vehicleinfo[i][vMod][12]);        
        SetVehicleHealth(vehicleadd, vehicleinfo[i][vHealth]);            

        for(new b = 0; b < MAX_PLAYERS; b ++)
        {
            if(vehicleinfo[i][vLocked] == 1) SetVehicleParamsForPlayer(vehicleadd,b,0,1);
            if(vehicleinfo[i][vFCarID] != -1 && playerinfo[b][pFaction] != vehicleinfo[i][vFCarID]) SetVehicleParamsForPlayer(vehicleadd,b,0,1);
            if(vehicleinfo[i][vJob] != -1 && playerinfo[b][pJob] != vehicleinfo[i][vJob]) SetVehicleParamsForPlayer(vehicleadd,b,0,1);            
        }        
        SetVehicleToRespawn(vehicleadd);            
        if(!strcmp(vehicleinfo[i][vOwner], "Faction", true))
        {
            SetVehicleVirtualWorld(vehicleadd, 0);              
        }
        else
        {
            SetVehicleVirtualWorld(vehicleadd, i+1);            
        }
    }    
    printf("Loaded %d Vehicles.", rows);
    return 1;
}
Reply


Messages In This Thread
mysql, carro 1 nгo carrega - by willttoonn - 05.10.2013, 22:44
Re: mysql, carro 1 nгo carrega - by zPain - 05.10.2013, 23:33
Re: mysql, carro 1 nгo carrega - by willttoonn - 05.10.2013, 23:34
Re: mysql, carro 1 nгo carrega - by zPain - 05.10.2013, 23:36
Re: mysql, carro 1 nгo carrega - by willttoonn - 05.10.2013, 23:55

Forum Jump:


Users browsing this thread: 1 Guest(s)