Static Vehicle System error. - 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: Static Vehicle System error. (
/showthread.php?tid=515290)
Static Vehicle System error. -
VictorCreed - 25.05.2014
I have a little problem with my in script vehicle system. In my roleplay game, I have nearly 520 faction cars. Their ID's are starting from 3 and ends at 512. So when a player buys a car, there isn't a problem for first two vehicle for their ID. But after 3rd vehicle, codes mixing and player writes /v buy, game creates a vehicle for player at SF Docks, at the same time code makes that player owner of the NG Patrol Car because that car's ID is already 3. So when player writes /stats, he sees he have a NG Patrol car. And that car which created at SF Docks, waits for that player and /v park it. Then everything turns normal. Also when a player sells his car, code mixes again and all cars mixing up.
I also tried to add a loop on the code which cheks the vehicle ID and if it's below 520, use "continue;" but it changed nothing.
Here's the loop
Код:
#define CreateVehicle S_CreateVehicle
stock S_CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay)
{
new v;
for(v = 0; v < MAX_VEHICLES; v++)
{
if(v < 520) continue;
break;
}
CreateVehicle(modelid, x, y, z, angle, color1, color2, respawn_delay);
return v;
}
Re : Static Vehicle System error. -
S4t3K - 25.05.2014
Try this solution
PHP код:
#define CreateVehicle S_CreateVehicle
stock S_CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay)
{
new v;
for(v = 3; v < MAX_VEHICLES; v++)
{
if(v <= 520) continue;
CreateVehicle(modelid, x, y, z, angle, color1, color2, respawn_delay);
return v;
}
return 0;
}
This will create vehicles with a minimal ID of 521.