CAR command help
#1

Guys this is my vehicle command I want that if player spawns a new car old one despawn can I do so?

pawn Код:
YCMD:veh(playerid, params[])
{
    if(gPlayerLoggedIn[playerid] == 0) return 1;

    if(PlayerInfo[playerid][Admin] >= 4) {
    new model[128], color1, color2;
    if(sscanf( params, "s[128]dd", model, color1, color2)) return SendClientMessage(playerid, COLOR_WHITE, "[USAGE]: /veh [Vehicle name] [Color1] [Color2]");
   
    new Float:X, Float:Y, Float:Z, Float:A;
   
    GetPlayerPos(playerid, X, Y, Z);
    GetPlayerFacingAngle(playerid, A);
   
    new car = ReturnVehicleModelID(model);
   
    if(!car) return SendClientMessage(playerid, COLOR_WHITE, "Unable to find that Vehicle name.");
   
    new carid = CreateVehicle(car, X,Y,Z,A, color1, color2, 0);
   
    PutPlayerInVehicle(playerid,carid,0);
    LinkVehicleToInterior(carid,GetPlayerInterior(playerid));
   
    for(new i = 0; i < sizeof(CreatedCars); i++)
    {
        if(CreatedCars[i] == INVALID_VEHICLE_ID)
        {
            CreatedCars[i] = carid;
            break;
        }
    }
   
    SendClientMessage(playerid, COLOR_WHITE, "You have spawned a vehicle.");
   
    }
    return 1;
}
Reply
#2

Yes,save the vehicle that the player has spawned and destroy it when he uses the command again.
Reply
#3

Rather i suggest,

1.Create A variable like Unused[carid] or something like that
2.Create a timer of your choice , the time will be in how much time the vehicle becomes "unused"
3.In the timer function , set the unused variable to 1.
4.Go to OnPlayerExitVehicle and call the timer here.
5.Make command that will respawn all the vehicles that are unused

So like that vehicles without a driver will become unused after some time ( time defined by the timer )
Reply
#4

But that will make the car respawn, even if he enters the same car again... any solution to that ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)