Car respawning problem - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Car respawning problem (
/showthread.php?tid=266911)
Car respawning problem -
Dirkon - 06.07.2011
Hello everyone,
I'm making simple car system. And I face a problem. Take a look at part of my script:
pawn Код:
stock LoadAllVehicles()
{
new fname[36];
new index = 1;
format(fname, sizeof(fname), "/vehicles/%d.ini", index);
while(fexist(fname))
{
LoadVehicle(fname);
index ++;
format(fname, sizeof(fname), "/vehicles/%d.ini", index);
}
}
stock DestroyAllVehicles()
{
for(new i = 0; i < MAX_VEHICLES; i++)
{
DestroyVehicle(i);
}
stock SaveAllVehicles()
{
new saveindex = 1;
new fname[36];
for(new i = 1; i < MAX_VEHICLES; i ++)
{
if(validcar[i])
{
format(fname, sizeof(fname), "/vehicles/%d.ini", saveindex);
SaveVehicle(i, fname);
saveindex ++;
}
}
}
And I made cmd like this:
pawn Код:
if (strcmp("/respawnvehicles", cmdtext, true, 10) == 0)
{
SaveAllVehicles();
DestroyAllVehicles();
LoadAllVehicles();
return 1;
}
So the problem is that, when I write the cmd In-Game all cars gets doubled (Before respawn there was 1 car and after respawn there is 2 cars at the same position).
Any ideas how to fix it?