SA-MP Forums Archive
Some help needed... - 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: Some help needed... (/showthread.php?tid=164551)



Some help needed... - Conroy - 31.07.2010

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


Re: Some help needed... - straco - 31.07.2010

Try use SetVehicleToRespawn(vehid);


Re: Some help needed... - Conroy - 31.07.2010

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.


Re: Some help needed... - straco - 31.07.2010

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


Re: Some help needed... - Conroy - 31.07.2010

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

-Conroy


Re: Some help needed... - Vince - 31.07.2010

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


Re: Some help needed... - Conroy - 31.07.2010

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


Re: Some help needed... - straco - 31.07.2010

use CreateVehicle no static

but Vince find where you have wrong syntax


Re: Some help needed... - Conroy - 31.07.2010

I created a custom vehicle spawner.

CreateStaticVehicle creates files which is what I want.


Re: Some help needed... - Daren_Jacobson - 31.07.2010

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.