Vehicle ID Issue (REP+)
#1

I've persevered from my previous issue but now there's a new one. One with ID's. Because I'm working with three different ID's here, it's sort of difficult to pinpoint which one I should be using where. I'm working with the ROW when I load from MySQL, the DB ID of the vehicle, and the VID in game.

This is my load function: Rows are starting at zero bear in mind.

PHP код:
forward InitiateVehicles();
public 
InitiateVehicles()
{
    new 
rowsfieldsvehicles;
    
    
cache_get_data(rowsfields);
    for(new 
rowrow MAX_DYN_VEHICLESrow++)
    {
        
Vehicle[row][VehicleDatabaseID] = cache_get_field_content_int(row"id"SQL);       
        
Vehicle[row][Model] = cache_get_field_content_int(row"Model"SQL);
        
Vehicle[row][VehiclePos][0] = cache_get_field_content_float(row"X"SQL);
        
Vehicle[row][VehiclePos][1] = cache_get_field_content_float(row"Y"SQL);
        
Vehicle[row][VehiclePos][2] = cache_get_field_content_float(row"Z"SQL);
        
Vehicle[row][VehiclePos][3] = cache_get_field_content_float(row"A"SQL);
        
Vehicle[row][VehicleVW] = cache_get_field_content_int(row"VW"SQL);
        
Vehicle[row][VehicleInt] = cache_get_field_content_int(row"Int"SQL);
        
Vehicle[row][VehicleColour][0] = cache_get_field_content_int(row"Colour1"SQL);
        
Vehicle[row][VehicleColour][1] = cache_get_field_content_int(row"Colour2"SQL);
        
Vehicle[row][VehicleGroup] = cache_get_field_content_int(row"Group"SQL);
        
Vehicle[row][Siren] = cache_get_field_content_int(row"Siren"SQL);
        if(
Vehicle[row][VehiclePos][0] != 0.00000 && Vehicle[row][VehiclePos][1] != 0.00000 && Vehicle[row][VehiclePos][2] != 0.00000)
        {
            
Vehicle[row][VehID] = CreateVehicle(Vehicle[row][Model], Vehicle[row][VehiclePos][0], Vehicle[row][VehiclePos][1], Vehicle[row][VehiclePos][2], Vehicle[row][VehiclePos][3], Vehicle[row][VehicleColour][0], Vehicle[row][VehicleColour][1], -1Vehicle[row][Siren]);
            
SetVehicleVirtualWorld(Vehicle[row][VehID], Vehicle[row][VehicleVW]);
            
LinkVehicleToInterior(Vehicle[row][VehID], Vehicle[row][VehicleInt]);
        }
        
printf("%d | %d | %d"rowVehicle[row][VehicleDatabaseID], Vehicle[row][VehID]);
        
vehicles++;
    }
    switch(
vehicles)
    {
        case 
0printf("[SCRIPT-LOAD/ERR] The script initiated 0 vehicles."vehicles);
        default: 
printf("[SCRIPT-LOAD] The script has initiated %d vehicles"vehicles);
    }

This successfully creates vehicles and the print that I put in looks like this for the two cars I have created: (I've laid it out in a table)

pawn Код:
ROW|DID|VID
[18:53:18] 0 | 1 | 1
Perfect, it does what it's suppose to do. But when I do /editvehicle 1 spawn (which is designed to move vehicle ID 1's spawn and save it's new location) it moves vehicle ID 2, and saves it's coordinates to DBID 2 in the database. The possible issues I'm having are probably with wrongly used ID's somewhere in the /editvehicle command.

Here you go: (I'll only show the 'spawn' option just to spare you a headache.)

PHP код:
CMD:editvehicle(playeridparams[])
{
    new 
idusage[16], amount;
    if(
sscanf(params"ds[16]D(0)"idusageamount)) 
    {
        if(
Player[playerid][AdminLevel] >= 5)
        {
            
SendClientMessage(playeridWHITE"USAGE: /editvehicle [id] [usage] [(optional) amount]");
            return 
SendClientMessage(playeridGREY"Usages: spawn, colour(1-2), group, delete");
        }
    }
    else if(
Player[playerid][AdminLevel] >= 5)
    {
        if(
id || id MAX_VEHICLES) return SendClientMessage(playeridWHITE"That is not a valid vehicle ID!");
        if(
Vehicle[id][VehicleDatabaseID] < 1) return SendClientMessage(playeridWHITE"That is not a valid dynamic vehicle ID!");
        Array[
0] = 0;
        if(
strcmp(usage"spawn"true) == 0)
        {
            new 
Float:Pos[4];
            
GetPlayerPos(playeridPos[0], Pos[1], Pos[2]);
            
GetPlayerFacingAngle(playeridPos[3]);
            
Vehicle[id][VehiclePos][0] = Pos[0];
            
Vehicle[id][VehiclePos][1] = Pos[1];
            
Vehicle[id][VehiclePos][2] = Pos[2];
            
Vehicle[id][VehiclePos][3] = Pos[3];
            
Vehicle[id][VehicleVW] = GetPlayerVirtualWorld(playerid);
            
Vehicle[id][VehicleInt] = GetPlayerInterior(playerid);
            
format(Array, sizeof(Array), "You have moved the spawn of vehicle %d"id);
            
SendClientMessage(playeridWHITE, Array);
            
format(Array, sizeof(Array), "[/EDITVEHICLE] %s has moved the spawn of vehicle %d to X: %f, Y: %f, Z: %f"GetName(playerid), idPos[0], Pos[1], Pos[2]);
        }
        else
        {
            
SendClientMessage(playeridWHITE"USAGE: /editvehicle [id] [usage] [(optional) amount]");
            return 
SendClientMessage(playeridGREY"Usages: spawn, colour(1-2), group, delete");
        }
        
Log(4, Array);
        
RespawnVehicle(id);
        
SaveVehicle(id);
    }
    else 
SendClientMessage(playeridWHITE"You are not authorized to preform this command.");
    return 
1;

Any reason why the ID's are getting mismatched and confused?
Reply


Messages In This Thread
Vehicle ID Issue (REP+) - by BornHuman - 24.05.2016, 23:04
Re: Vehicle ID Issue (REP+) - by Jefff - 24.05.2016, 23:36
Re: Vehicle ID Issue (REP+) - by BornHuman - 24.05.2016, 23:44
Re: Vehicle ID Issue (REP+) - by Jefff - 24.05.2016, 23:53
Re: Vehicle ID Issue (REP+) - by BornHuman - 24.05.2016, 23:56
Re: Vehicle ID Issue (REP+) - by Jefff - 24.05.2016, 23:59
Re: Vehicle ID Issue (REP+) - by BornHuman - 25.05.2016, 00:10
Re: Vehicle ID Issue (REP+) - by Jefff - 25.05.2016, 00:16
Re: Vehicle ID Issue (REP+) - by BornHuman - 25.05.2016, 00:20
Re: Vehicle ID Issue (REP+) - by Jefff - 25.05.2016, 00:24

Forum Jump:


Users browsing this thread: 1 Guest(s)