View Single Post
Old 03/02/2020, 10:51 AM   #8
OsmanMalagic
Little Clucker
 
Join Date: Jul 2016
Location: EX-YU
Posts: 40
Reputation: 51
Default Re: MySQL load vehicles issue

Quote:
Originally Posted by Filip21 View Post
PHP Code:
mysql_format(mysqlquerysizeof(query), "SELECT * FROM `vehicles`");
mysql_tquery(mysqlquery"LoadVehicles""");

forward LoadVehicles();
public 
LoadVehicles()
{
    new 
rowsfieldscountdata[24];
    
cache_get_data(rowsfields);
    
    for(new 
1sizeof(CarInfo); j++)
    {
        
cache_get_field_content(j-1"ID"data); CarInfo[j][cID] = strval(data);
        
cache_get_field_content(j-1"CarID"data); CarInfo[j][cCarID] = strval(data);
        
cache_get_field_content(j-1"Owned"data); CarInfo[j][cOwned] = strval(data);
        
cache_get_field_content(j-1"Owner"data); strmid(CarInfo[j][cOwner], data0strlen(data), 64);
        
cache_get_field_content(j-1"Model"data); CarInfo[j][cModel] = strval(data);
        
cache_get_field_content(j-1"Location_X"data); CarInfo[j][cLocationx] = floatstr(data);
        
cache_get_field_content(j-1"Location_Y"data); CarInfo[j][cLocationy] = floatstr(data);
        
cache_get_field_content(j-1"Location_Z"data); CarInfo[j][cLocationz] = floatstr(data);
        
cache_get_field_content(j-1"Angle"data); CarInfo[j][cAngle] = floatstr(data);
        
cache_get_field_content(j-1"Color_1"data); CarInfo[j][cColorOne] = strval(data);
        
cache_get_field_content(j-1"Color_2"data); CarInfo[j][cColorTwo] = strval(data);
        
cache_get_field_content(j-1"VirtualWorld"data); CarInfo[j][cVirWorld] = strval(data);

        if(
CarInfo[j][cOwned] == || CarInfo[j][cModel] == 0)
        {
            
CarInfo[j][cCarID] = NBC_AddStaticVehicleEx(510, -804.53843791.850639.4313+jCarInfo[j][cAngle], CarInfo[j][cColorOne], CarInfo[j][cColorTwo], 600000);
        }
        else
        {
            
CarInfo[j][cCarID] = NBC_AddStaticVehicleEx(CarInfo[j][cModel], CarInfo[j][cLocationx], CarInfo[j][cLocationy], CarInfo[j][cLocationz]+1.0CarInfo[j][cAngle], CarInfo[j][cColorOne], CarInfo[j][cColorTwo], 600000);
        }
        
count++; 
    } 
    return 
1;

Again same..
Vehicle ID is 503 not ID 1.


Quote:
Originally Posted by Kwarde View Post
It appears you are referring to 'vehicleid' (The server's vehicle id, created with AddStaticVehicle/CreateVehicle). If you want this to be 1-1000 ingame (like in the MySQL server), make sure to load these vehicles before any other vehicles.

CarInfo[*][cID] should countain the ID from the MySQL database. The CarID is probably the ID that must be used in-game? You should not save such data to the database. Especially since you're re-assigning it afterwards anyway.
Hm, I loading private vehicles first, then all others, that is not a problem.
I store Vehicle Number into my database and then using that Vehicle Number i want to load that car.
Seeing old system on Y_INI all loading values must go trough CarInfo loop then under that values car spawns.
When i do that, server created same vehicle more than 600 times.
OsmanMalagic is offline   Reply With Quote