Some help needed...
#1

Alright, I'm making a RespawnAllVehicles function and the command basically stops once it gets to a certain line.

pawn Код:
public RespawnAllVehicles()
{
    new VehicleCannotBeRespawned[MAX_VEHICLES], VehiclePath[128];
    for(new i; i <= MAX_PLAYERS; i++) {
        if(IsPlayerInAnyVehicle(i)) {
            VehicleCannotBeRespawned[GetPlayerVehicleID(i)] = 1;
        }
    }
    for(new vehid; vehid <= MAX_VEHICLES; vehid++) {
        print("Loop");
        format(VehiclePath, sizeof(VehiclePath), "\\Vehicles\\%d.ini", vehid);
        print("Format");
        if(dini_Exists(VehiclePath)) {
            print("Exists");
            if(VehicleCannotBeRespawned[vehid] == 0) {
                print("Check");
                SetVehiclePos(vehid,
                dini_Float(VehiclePath, "SpawnX"),
                dini_Float(VehiclePath, "SpawnY"),
                dini_Float(VehiclePath, "SpawnZ")), print("Move");
                SetVehicleZAngle(vehid, dini_Float(VehiclePath, "SpawnA"));
                print("Angle");
            }
        }
    }
    SendClientMessageToAll(COLOR_YELLOW, "[SERVER] - All unused vehicles have been respawned.");
    AllVehiclesAreRespawning = 0;
    return 1;
}
As you can see, I'm using prints to see which line to server gets to before the command stopped. I saw Loop, Format, Exists, Check but Move wasn't there. Therefore it's the SetVehiclePos command which is causing the server to stop. Any ideas how to fix this?

pawn Код:
SetVehiclePos(vehid, dini_Float(VehiclePath, "SpawnX"), dini_Float(VehiclePath, "SpawnY"), dini_Float(VehiclePath, "SpawnZ"));
Any help would be appreciated,

-Conroy
Reply
#2

Try use SetVehicleToRespawn(vehid);
Reply
#3

I know that would work, but I am using it this way because the vehicles spawn position can be changed with a command, and if I SetVehicleToRespawn it will bypass the new spawn position.

The command changes the variables in the file, hence when I'm using it this way.
Reply
#4

If this work you can in changing position of vehicle destroy it and create new at new position and it will respawning cars at right place


And if you only change position vehicle can be damaged
Reply
#5

Ah, never thought about destroying and creating it again. I'll try it and let you know how I get on.

-Conroy
Reply
#6

You missed something;
After the 'SpawnZ' there's a comma, that should be a semicolon.
Reply
#7

Alright, well, it works, although I have another problem.

pawn Код:
DestroyVehicle(oldvehid);
dini_Remove(VehiclePath);
new vehid = CreateStaticVehicle(vehModel, X, Y, Z, A, vehColor1, vehColor2);
As you can see here, I destroy the vehicle then delete the file, and the straight after I add the same vehicle.

The problem I'm getting is that the new vehicle has an id of 33536 (or something along these lines). I have no idea why, and I think it's because I am destroying it then creating it again straight after. Any help would be appreciated.

-Conroy
Reply
#8

use CreateVehicle no static

but Vince find where you have wrong syntax
Reply
#9

I created a custom vehicle spawner.

CreateStaticVehicle creates files which is what I want.
Reply
#10

Quote:
Originally Posted by Vince
Посмотреть сообщение
You missed something;
After the 'SpawnZ' there's a comma, that should be a semicolon.
no, a comma is just fine, learn the language before you post.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)