DestroyVehicle
#1

Hello there. Today I discovered something whilst browsing my server for bugs.

In my server I have a command for destroying cars (as in completely removing them from the server until a server restart) which is derived from LAdminv4 (the admin system which my system is heavily influenced by)

When I go to use the command, which is "/dc" (dcmd) usually it deletes the car from the server. However I have now discovered that it doesn't delete the car, and any other function using DestroyVehicle is now bugged. Idk if this has been brough up before, or whether it is something to do with my script .. does anyone have any info that could help me solve this?
Reply
#2

Bump. Anyone gonna shed some light on this issue? It's really annoying.
Reply
#3

Working fine on my server.
Reply
#4

me to.
Reply
#5

Quote:
Originally Posted by JaTochNietDan
Working fine on my server.
Reply
#6

Then wtf?! Why isn't it deleting the cars ...
Reply
#7

Your script is wrong then.
Reply
#8

Quote:
Originally Posted by dugi
Your script is wrong then.
I don't see how, I mean it worked fine in 0.2x O.o ...

Ok let me take you through this:

Firstly the command is used
pawn Код:
dcmd_destroycar(playerid,params[]) {
    #pragma unused params
    if(PlayerInfo[playerid][Level] >= 5)
    {
      EraseVehicle(GetPlayerVehicleID(playerid));
      return 1;
    }
    else return 0;
}
Which calls the EraseVehicle function you see in the command which looks like this:

pawn Код:
EraseVehicle(vehicleid)
{
  for(new players=0;players<=MAX_PLAYERS;players++)
  {
    new Float:X,Float:Y,Float:Z;
    if (IsPlayerInVehicle(players,vehicleid))
    {
      GetPlayerPos(players,X,Y,Z);
      SetPlayerPos(players,X,Y,Z+2);
      SetVehicleToRespawn(vehicleid);
    }
    SetVehicleParamsForPlayerEx(vehicleid,players,0,1);
  }
  SetTimerEx("VehRes",3000,0,"d",vehicleid);
  return 1;
}
Which sets the timer on "VehRes" function which looks like this:

pawn Код:
forward VehRes(vehicleid);
public VehRes(vehicleid)
{
  DestroyVehicle(vehicleid);
}
.. this is used in other places in the GM too.

As you can see the SetVehicleParamsForPlayerEx by kc is in there, do you think this could be causing a problem?

Help is appreciated.

Reply
#9

The EraseVehicle function you call is very poorly coded so I am not surprised you are having problems. You do not need the for loop (which should be limited to less then MAX_PLAYERS anyway) to get/set player positions for those in a vehicle you are destroying. You also don't need to use SetVehicleToRespawn and SetVehicleParamsForPlayerEx, and calling DestroyVehicle via the timer is not needed. Call DestroyVehicle directly and you shouldn't have a problem.
Reply
#10

Quote:
Originally Posted by Betamaster
The EraseVehicle function you call is very poorly coded so I am not surprised you are having problems. You do not need the for loop (which should be limited to less then MAX_PLAYERS anyway) to get/set player positions for those in a vehicle you are destroying. You also don't need to use SetVehicleToRespawn and SetVehicleParamsForPlayerEx, and calling DestroyVehicle via the timer is not needed. Call DestroyVehicle directly and you shouldn't have a problem.
This wasn't coded by me ... it is from LAdminV4. Also you don't understand, this is just part of a larger code, however this is the part I am taking about in my 1st post. It has worked fine on 0.2x and has only appeared recently.

The SetVehicleParamsForPlayerEx (formerly SetVehicleParamsForPlayer) is there for this exact reason, when DestroyVehicle fails it locks the vehicle to anyone because cars in this system or generally admin created. If you look at LAdminV4 you'll see exactly what I mean.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)