[Help] Vehicle System.
#1

Hi guys,
I'm building a vehicle system right now, I'm almost done with it.
I have collided with a problem, when someone sells his car, or new cars adding to the mod, the carid changing and the INI will not change himself.
So I tried to add a parameter that will save on the vehicle file, let's says the vehicle id is 3 so in the vehicle file(3.ini), will be wroten ID = 3.
I tried to do
PHP код:
if(VehicleInfo[vehicleid][vID] != vehicleidprintf("Error"); 
But that's printing me the Error when it's not true.
To verify that I removed one vehicle from the gm, and the vehicle id that was 3 become 2, and his file still was 3, with ID = 3.

It's really important for me, thanks for who helping/trying to.
Good day.
Reply
#2

PHP код:
enum CarSystem
{
    
cDescription[MAX_PLAYER_NAME],
    
cOwner[MAX_PLAYER_NAME],
    
Float:cX,
    
Float:cY,
    
Float:cZ,
    
Float:cTempX,
    
Float:cTempY,
    
Float:cTempZ,
    
Float:cAngle,
    
Float:cTempAngle,
    
cOwned,
    
cPrice,
    
cLocked,
    
cModel,
    
cCol1,
    
cCol2,
    
ownedvehicle,
    
ccLocked,
};
new 
Cars[28][CarSystem]; // 28 CARS !
forward LoadCars();
forward SaveCars();
public 
OnGameModeInit()
{
LoadCars;
carsavetimer SetTimer("SaveCars",60000,1);
return 
1;
}
public 
OnPlayerText(playeridtext[])
{
public 
LoadCars()
{
    new 
arrCoords[17][64];
    new 
strFromFile2[256];
    new 
Filefile fopen("Cars/cars2.cfg",io_read);
    if (
file)
    {
        new 
idx;
        while (
idx sizeof(Cars))
        {
            
fread(filestrFromFile2);
            
split(strFromFile2arrCoords'|');
            
strmid(Cars[idx][cDescription], arrCoords[0], 0strlen(arrCoords[0]), 255);
            
strmid(Cars[idx][cOwner], arrCoords[1], 0strlen(arrCoords[1]), 255);
            
Cars[idx][cModel] = strval(arrCoords[2]);
            
Cars[idx][cX] = floatstr(arrCoords[3]);
            
Cars[idx][cY] = floatstr(arrCoords[4]);
            
Cars[idx][cZ] = floatstr(arrCoords[5]);
            
Cars[idx][cAngle] = floatstr(arrCoords[6]);
            
Cars[idx][cOwned] = strval(arrCoords[7]);
            
Cars[idx][cPrice] = strval(arrCoords[8]);
            
Cars[idx][cLocked] = strval(arrCoords[9]);
            
Cars[idx][cCol1] = strval(arrCoords[10]);
            
Cars[idx][cCol2] = strval(arrCoords[11]);
            
Cars[idx][cTempX] = floatstr(arrCoords[12]);
            
Cars[idx][cTempY] = floatstr(arrCoords[13]);
            
Cars[idx][cTempZ] = floatstr(arrCoords[14]);
            
Cars[idx][cTempAngle] = floatstr(arrCoords[15]);
            
Cars[idx][cTempX] = Cars[idx][cX];
            
Cars[idx][cTempY] = Cars[idx][cY];
            
Cars[idx][cTempZ] = Cars[idx][cZ];
            
Cars[idx][cTempAngle] = Cars[idx][cAngle];
            
Cars[idx][ccLocked] = strval(arrCoords[16]);
            
Cars[idx][ownedvehicle] = CreateVehicle(Cars[idx][cModel],Cars[idx][cX],Cars[idx][cY],Cars[idx][cZ],Cars[idx][cAngle],Cars[idx][cCol1],Cars[idx][cCol2],10000);
            
VehicleFuel[idx] = GasMax;
            
idx++;
        }
        
fclose(file);
    }

    return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
new 
car PlayerInfo[playerid][pCarKey];
    if(
Cars[car][cLocked] == 1)
    {
        
Cars[car][ccLocked] = 1;
        
Cars[car][cLocked] = 0;
    }
SaveCars;
return 
1;

the system is more easy and it can changing ids, also in .CFG is
Код:
Windsor|None|555|1517.418701|-694.222473|94.434265|90.076080|0|100|0|0|0|1517.418701|-694.222473|94.434265|90.076080|0

Name of Vehicle | veh's owner | vehicle's id |x|y|z|angle|0|price|color1|color2|x1|y1|z1|angle1|0|
the x1,y1,z1,angler1 is for in case if somebody bought vehicle
I hope my system will help you
Reply
#3

It's not understantable...
Mine vehicle system works with alots of features, and I want to truck that if vehicleid doesn't match with his file it will delete it and recompile the file again.
Reply
#4

Quote:
Originally Posted by BlackSA
Посмотреть сообщение
It's not understantable...
Mine vehicle system works with alots of features, and I want to truck that if vehicleid doesn't match with his file it will delete it and recompile the file again.
lol, I almost gave all vehicle system, and you saying it's not understanding post more details about your system then I could help or other one can
Reply
#5

I have a vehicle system with able for each player upto 10 vehicles.
Every vehicles have an Owner, Insurances, Lock, ParkPlace(need to buy), Dents, Fines and more..

I just want to get the vehicle id in the file, and if it's not works with the vehicleid it will print "Error".

BTW, Your vehicle system using a simple programming, and it's not included much features.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)