Help with vehicle system
#1

fixed...
Reply
#2

Highlight the lines, please.
Reply
#3

in this whole mess of code, where exactly are those problems occurring ?
by the looks of it its a loop or near
Reply
#4

Updated .
Reply
#5

i believe the first one
pawn Код:
stock VehiclePath(vehicleID)
{
    new strPath[64];
    format(strPath, sizeof(strPath), "/vehicle/%d.ini",vehicleID);

    return strPath;
}
2nd
pawn Код:
stock VehicleLoad(vehicleID, file[])
{
    INI_ParseFile(file, "LoadVehicleData", .bExtra = true, .extra = vehicleID);
    new pname(MAX_PLAYER_NAME];format(pname,sizeof pname,"%s",VehicleInfo[vehicleID][vOwner]);
    VehicleCreate(VehicleInfo[vehicleID][vModel],VehicleInfo[vehicleID][vLoc[0]], VehicleInfo[vehicleID][vColor1], VehicleInfo[vehicleID][vColor2], VehicleInfo[vehicleID][vRespawn],
    pname, VehicleInfo[vehicleID][vLocked]);
//NOTE: "vLoc" is an arrey !
}
Last i belive
pawn Код:
public LoadVehicleData(vehicleID, name[], value[])
{
    new strLoc[8]; // Will hold the location key name dynamically.
    INI_Int("model", VehicleInfo[vehicleID][vModel]);
    for(new i = 0; i < 4; i++)
    {
        format(strLoc, sizeof(strLoc), "Loc%d", i), INI_Float(strLoc, VehicleInfo[vehicleID][vLoc[i]]);
        INI_Int("color1", VehicleInfo[vehicleID][vColor1]); // You should've guessed it by now.
        INI_Int("color2", VehicleInfo[vehicleID][vColor2]);
        INI_Int("respawn", VehicleInfo[vehicleID][vRespawn]);
        INI_String("owner", VehicleInfo[vehicleID][vOwner], MAX_PLAYER_NAME);
        VehicleInfo[vehicleID][vLocked] = INI_Int("locked") == 1 ? true : false;
    }
    return 1;
}
//you cant loop the return as it will break the loop as there is no brackets!
there could still be errors/warnings
Reply
#6

Im trying to use the same sort of system.

It appears the problem comes from the size of an array called VehicleCreate which is called in VehicleLoad.
The line of error is the last one.(the one that isn't indented)
pawn Код:
stock VehicleLoad(vehicleID, file[])
{
    INI_ParseFile(file, "LoadVehicleData", .bExtra = true, .extra = vehicleID);
    //new pname(MAX_PLAYER_NAME];
    format(pname,sizeof pname,"%s",VehicleInfo[vehicleID][vOwner]);
VehicleCreate(VehicleInfo[vehicleID][vModel],VehicleInfo[vehicleID][vLoc], VehicleInfo[vehicleID][vColor1], VehicleInfo[vehicleID][vColor2], VehicleInfo[vehicleID][vRespawn],pname, VehicleInfo[vehicleID][vLocked]);
}
And this is the VehicleCreate function;
pawn Код:
stock VehicleCreate(vehicleModel, Float:vehicleLoc[4], vehicleColor1, vehicleColor2, vehicleRespawn, vehicleOwner[], bool:vehicleLocked)
// This is our most important function. This will create the vehicle with the valid information provided on the arguments.
{
    new vehicleid = VehicleGetFreeSlot(); // Get the free slot and store it on the vehicleid variable.
    //Now, we will basically put the information from the arguments to our newly created vehicle's array.
    VehicleInfo[vehicleid][vModel] = vehicleModel; // Assign our vehicle's model id to the model id provided.
    VehicleInfo[vehicleid][vLoc] = vehicleLoc; // Assign our vehicle's position/rotation to the position/rotation provided.
    VehicleInfo[vehicleid][vColor1] = vehicleColor1; // Assign our vehicle's primary color to the primary color provided.
    VehicleInfo[vehicleid][vColor2] = vehicleColor2; // Assign our vehicle's secondary color to the secondary color provided.
    VehicleInfo[vehicleid][vRespawn] = vehicleRespawn; // Assign our vehicle's respawn time to the respawn time provided.
    format(VehicleInfo[vehicleid][vOwner], MAX_PLAYER_NAME, vehicleOwner); // Assign our vehicle's owner name to the owner name provided.
    VehicleInfo[vehicleid][vLocked] = vehicleLocked; // Assign our vehicle's lock data to the lock data provided.
    VehicleInfo[vehicleid][vID] = CreateVehicle(vehicleModel, vehicleLoc[0], vehicleLoc[1], vehicleLoc[2], vehicleLoc[3], vehicleColor1, vehicleColor2,
    vehicleRespawn); // Now we are doing two things. We are creating our vehicle on the sa-mp world based on the data provided as well as assigning the
    // sa-mp vehicle id to our system's vehicle id so that we can alter it later.
    vCreated[vehicleid] = true; // Tell our vehicle management variable that this vehicle creation has been done and it's now on the system.
    VehicleLock(vehicleid, VehicleInfo[vehicleid][vLocked]); // Toggle our vehicle's door based on the parameter.
   
    return vehicleid; // Return the newly created vehicle's system id.
}
Reply
#7

there is an error on this line :
pawn Код:
new pname(MAX_PLAYER_NAME]; format(pname,sizeof pname,"%s",VehicleInfo[vehicleID][vOwner]);
pawn Код:
C:\Users\user\Desktop\Roleplay\Roleplay\gamemodes\rp.pwn(192) : error 001: expected token: ";", but found "("
C:\Users\user\Desktop\Roleplay\Roleplay\gamemodes\rp.pwn(192) : error 001: expected token: ")", but found "]"
C:\Users\user\Desktop\Roleplay\Roleplay\gamemodes\rp.pwn(192) : warning 215: expression has no effect
C:\Users\user\Desktop\Roleplay\Roleplay\gamemodes\rp.pwn(192) : error 035: argument type mismatch (argument 1)
C:\Users\user\Desktop\Roleplay\Roleplay\gamemodes\rp.pwn(192) : fatal error 107: too many error messages on one line
Reply
#8

Lol this looks pretty close to code I wrote almost 9 years ago under my alias tAxI. I abandoned my attempt as this save method is very messy and I went a different direction.

One of your mainproblems is that you are using variables where you don't even need to. Just define the save file position instead of writing a string every time to store it. Wastes space but won't really negatively effect the file functions.
Reply
#9

Common couldn't u spot the mistake ?
pawn Код:
new pname[MAX_PLAYER_NAME]; format(pname,sizeof pname,"%s",VehicleInfo[vehicleID][vOwner]);
It's my fault but I am wrigting these codes from my phone so.. Wht u excpect ;d
Reply
#10

I still have problem with this line :
pawn Код:
format(strLoc, sizeof(strLoc), "Loc%d", i), INI_Float(strLoc, VehicleInfo[vehicleID][vLoc[i]]);
Errors
pawn Код:
C:\Users\user\Desktop\Roleplay\Roleplay\gamemodes\rp.pwn(203) : error 029: invalid expression, assumed zero
C:\Users\user\Desktop\Roleplay\Roleplay\gamemodes\rp.pwn(203) : error 001: expected token: ";", but found "return"
C:\Users\user\Desktop\Roleplay\Roleplay\gamemodes\rp.pwn(203) : error 028: invalid subscript (not an array or too many subscripts): "vLoc"
C:\Users\user\Desktop\Roleplay\Roleplay\gamemodes\rp.pwn(203) : fatal error 107: too many error messages on one line
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)