Load vehicles from INI files
#1

Hello there everybody,
so this is the problem,
I have a full functioning Vehicle Ownership system, but the thing is, when I close the server's connection and then restart it back, the owned vehicles won't spawn, so is there some way I can do to make all private/owned vehicles spawn on their last position?

This is the saving code I use:
PHP код:

stock SaveVehicle
(vehicleid){
    
VehicleInfo[vehicleid][vModel] = GetVehicleModel(vehicleid);
    new 
INI:File INI_Open(PVPath(vehicleid));
    
INI_SetTag(File"VehicleColor");
    
INI_WriteInt(File"vColor1"VehicleInfo[vehicleid][vColor1]);
    
INI_WriteInt(File"vColor2"VehicleInfo[vehicleid][vColor2]);
    
INI_SetTag(File"VehicleCordinates");
    
INI_WriteFloat(File"vPosX"VehicleInfo[vehicleid][vPosX]);
    
INI_WriteFloat(File"vPosY"VehicleInfo[vehicleid][vPosY]);
    
INI_WriteFloat(File"vPosZ"VehicleInfo[vehicleid][vPosZ]);
    
INI_WriteFloat(File"vAng"VehicleInfo[vehicleid][vAng]);
    
INI_SetTag(File"VehicleInfo");
    
INI_WriteInt(File"vModel"VehicleInfo[vehicleid][vModel]);
    
INI_WriteString(File"vOwner"VehicleInfo[vehicleid][vOwner]);
    
INI_WriteInt(File"vOwned"VehicleInfo[vehicleid][vOwned]);
    
INI_Close(File);
    return 
1;

Reply
#2

Load the vehicles under OnGameModeInit. There are plenty of tutorials available to you, feel free to use them.
Reply
#3

Quote:
Originally Posted by Threshold
Посмотреть сообщение
Load the vehicles under OnGameModeInit. There are plenty of tutorials available to you, feel free to use them.
I already solved this, but thanks for your answer anyway, here how I did it,

PHP код:
printf("||******************************PRIVATE VEHICLES*******************************||");
    for(new 
i=0i<2000i++){
           if(
fexist(PVPath(i))){
               new 
str[MAX_PLAYER_NAME+60];
            
INI_ParseFile(PVPath(i), "LoadVehicle", .bExtra true, .extra i);
            
CreateVehicle(VehicleInfo[i][vModel], VehicleInfo[i][vPosX], VehicleInfo[i][vPosY], VehicleInfo[i][vPosZ], VehicleInfo[i][vAng], VehicleInfo[i][vColor1], VehicleInfo[i][vColor2], 300000);
            
format(strsizeof(str), "{FFFF00}%s{FFFFFF}'s Vehicle"VehicleInfo[i][vOwner]);
            
Attach3DTextLabelToVehicle(Create3DTextLabel(strYELLOW0.00.00.02000), i0.00.01.5);
            
SetVehicleNumberPlate(iVehicleInfo[i][vOwner]);
            
printf("[PRIVATE VEHICLE]: %s's private vehicle has loaded, ID: %d"VehicleInfo[i][vOwner], i);
        }
    } 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)