Car respawning problem
#1

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)