SA-MP Forums Archive
Faction vehicles. [MySQL] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Faction vehicles. [MySQL] (/showthread.php?tid=467395)



Faction vehicles. [MySQL] - Fez - 02.10.2013

When I dynamicly add faction vehicles to a certain faction IG everything is fine. However once I restart the server some of the faction vehicles suddenly appear in different factions even though everything appears to be fine in the database.

Here is my MySQL database and my script for it...

http://puu.sh/4G3zR.png

Код:
    mysql_query("SELECT * FROM `Vehicles`");
    mysql_store_result();
    new i = 1;
    if(mysql_num_rows() > 0)
    {
        while(mysql_fetch_row(Str))
        {
            sscanf(Str, "p<|>iiffffiii", vID, dModel, VX, VY, VZ, VA, col1, col2, faction);
            CreateVehicle(dModel, VX, VY, VZ, VA, col1, col2, -1);
            VehicleFaction[i] = faction;
            new str[9];
			new rand[7];
			rand[0] = random(sizeof(letters));
			rand[1] = random(sizeof(letters));
			rand[2] = random(sizeof(nums));
			rand[3] = random(sizeof(nums));
			rand[4] = random(sizeof(letters));
			rand[5] = random(sizeof(letters));
			rand[6] = random(sizeof(letters));
			format(str, sizeof(str), "%s%s%d%d %s%s%s", letters[rand[0]], letters[rand[1]], nums[rand[2]], nums[rand[3]], letters[rand[4]], letters[rand[5]], letters[rand[6]]);
			//SetVehicleNumberPlate(i, str);
			SetVehicleToRespawn(i);
            i++;
			vTotal++;
		}
    }
    mysql_free_result();
    printf("%i vehicles loaded from the MySQL Database.", vTotal);
	return 1;
}



Re: Faction vehicles. [MySQL] - Richie© - 03.10.2013

You are assigning VehicleFaction var to the wrong vehicleid. Any vehicle created before this will conflict with that code.
pawn Код:
new vehicle = CreateVehicle(...
VehicleFaction [vehicle] = faction;



Re: Faction vehicles. [MySQL] - Fez - 03.10.2013

This didn't seem to work although I think I've worked a way around this.. Thanks anyway!