06.07.2011, 16:17
Hello everyone,
I'm making simple car system. And I face a problem. Take a look at part of my script:
And I made cmd like this:
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?
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 ++;
}
}
}
pawn Код:
if (strcmp("/respawnvehicles", cmdtext, true, 10) == 0)
{
SaveAllVehicles();
DestroyAllVehicles();
LoadAllVehicles();
return 1;
}
Any ideas how to fix it?