05.05.2012, 20:36
hi,
this is all my code that creates vehicles with a command in game.
The vehicles should be destroyed after they die (after they explode or get destroyed) but the problem is they are not destroyed the vehicles just respawn where they have been created with the command.
Also all vehicles that had been created with the command should be destroyed after a certain time using a loop, also there is a bug i think.
I post my current code and i hope some of you guys can tell me where my bugs are![Smiley](images/smilies/smile.png)
thx in advance![Smiley](images/smilies/smile.png)
this is all my code that creates vehicles with a command in game.
The vehicles should be destroyed after they die (after they explode or get destroyed) but the problem is they are not destroyed the vehicles just respawn where they have been created with the command.
Also all vehicles that had been created with the command should be destroyed after a certain time using a loop, also there is a bug i think.
I post my current code and i hope some of you guys can tell me where my bugs are
![Smiley](images/smilies/smile.png)
thx in advance
![Smiley](images/smilies/smile.png)
pawn Код:
new RespawnedVehicle[MAX_PLAYERS];
//OnPlayerCommand
if (strcmp("/carrespawn", cmdtext, true) == 0)//the command
{
new playerState = GetPlayerState(playerid);
if(playerState == PLAYER_STATE_DRIVER)return SendClientMessage(playerid, 0xFF0000FF, "You are already in a vehicle!");
DestroyVehicle(RespawnedVehicle[playerid]);
RWRespawnedVehicle[playerid]=-1;
new Float:Xc, Float:Yc, Float:Zc;
GetPlayerPos(playerid, Xc, Yc, Zc);
RespawnedVehicle[playerid] = CreateVehicle(422, Xc+3, Yc+3, Zc+3, 0.0,-1,-1, 600);
PutPlayerInVehicle(playerid,RespawnedVehicle[playerid],0);
return 1;
}
//OnVehicleDeath
for(new rws = 0; rws < sizeof(RespawnedVehicle); rws++)
{
if(RespawnedVehicle[rws]==vehicleid)DestroyVehicle(RespawnedVehicle[rws]);
RespawnedVehicle[rws]=-1;
}
//the loop i use in a time to destroy all created vehicles after a certain time
for(new rws; rws < sizeof(RespawnedVehicle); rws++)
{
DestroyVehicle(RespawnedVehicle[rws]);
RespawnedVehicle[rws]=-1;
}