17.01.2017, 10:51
Hello, I made a command to open/close vehicle trunks. It works for vehicles that were spawned when the server first started up but any other vehicles spawned afterwards through for example /vspawner won't respond to the command. I tried using MAX_VEHICLES but that made no difference.
If anyone has any ideas on why this doesn't work, it would be appreciated.
pawn Код:
CMD:trunk(playerid, params[]) //New vehicles won't work
{
new engine,lights,alarm,doors,bonnet,boot,objective,Float:x,Float:y,Float:z;
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "You can't do this while inside a vehicle.");
for(new i = 0; i < GetVehiclePoolSize(); i++)
{
GetVehiclePos(i, x, y, z);
if(IsPlayerInRangeOfPoint(playerid, 4, x, y, z))
{
GetVehicleParamsEx(i, engine, lights, alarm, doors, bonnet, boot, objective);
if(boot == VEHICLE_PARAMS_ON)
{
SetVehicleParamsEx(i, engine, lights, alarm, doors, bonnet, VEHICLE_PARAMS_OFF, objective);
return 1;
}
else
{
SetVehicleParamsEx(i, engine, lights, alarm, doors, bonnet, VEHICLE_PARAMS_ON, objective);
return 1;
}
}
}
return 1;
}