Admin Spawned vehicles
#1

Here is my /veh command:

pawn Код:
command(veh, playerid, params[])
{
    if(PVar[playerid][alevel] > 1)
    {
        new sCar, str[128];
        new VehicleID;
        new Float:X, Float:Y, Float:Z, Float:Ang;
        new Int, colour1, colour2, defaultcolour;

        if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0x66666666, "You need to be on foot to spawn a vehicle.");
        if(unformat(params, "k<vehicles>D(44)D(defaultcolour)", sCar, colour1, colour2)) return SendClientMessage(playerid, 0x66666666, "Usage: /veh(icle) [Vehicle ID / Name] [Colour 1(Optional)] [Colour 2(Optional)]");
        if(sCar == -1) return SendClientMessage(playerid, 0x66666666, "That vehicle model or ID doesn't exist.");
        if(colour2 == defaultcolour) colour2 = colour1;

        GetPlayerPos(playerid,X, Y, Z);
        GetPlayerFacingAngle(playerid, Ang);
        Int = GetPlayerInterior(playerid);

        VehicleID = CreateVehicle(sCar, X, Y, Z, Ang, colour1, colour2, -1);
        SetVehicleVirtualWorld(VehicleID, GetPlayerVirtualWorld(playerid));

        PutPlayerInVehicle(playerid, VehicleID, 0);
        LinkVehicleToInterior(VehicleID, Int);
        format(str, sizeof(str), "You have spawned a: %s [ID %d]", VehicleNames[sCar - 400], sCar);
        SendClientMessage(playerid, 0x66CCFFFF, str);
    }
    else
    {
        SendClientMessage(playerid, 0x66666666, "You are not authorised to use that command");
        return 1;
    }
    return 1;
}
Basically, I want to add every single Admin spawned car to an Array (Max 100) and would give them a certain license plate like "((Admn))", I want this so that ALL admin cars can be deleted with a command. Im not sure how to do this, can anyone help please?
Reply
#2

Top:
Код:
new admincar[MAX_PLAYERS];
In your command routine above:
Код:
VehicleID = CreateVehicle(sCar, X, Y, Z, Ang, colour1, colour2, -1);
admincar[playerid] = VehicleID;
SetVehicleVirtualWorld(VehicleID, GetPlayerVirtualWorld(playerid));
To destroy all admin cars:
Код:
foreach(Player,i)
{
    if(admincar[i] != INVALID_VEHICLE_ID)
    {
        DestroyVehicle(admincar[i]);
        admincar[i] = INVALID_VEHICLE_ID;
    }
}
Untested as Im at work, but thats the gist of it. Make sure the admins vehicle is destroyed and admincar[playerid] is set to INVALID_VEHICLE_ID when they leave the server.


EDIT and no I didn't do the entire thing for you. I provided a small example of how you would load vehicleids into an array and call them back later. You can use the admincar[playerid] bit when setting license plates, destroying the vehicle, calling (teleporting) the vehicle to the admin, etc etc etc.

Its IMPERATIVE that you set admincar[playerid] = INVALID_VEHICLE_ID after you destroy their vehicle when they leave the server.
Reply
#3

Thanks it worked ^^

Also, lets say I wanted to make a Dialog box which showed a list of the 100 vehicles that were spawned, how would I do that without having a long ass format function similar to:

pawn Код:
format(Msg, sizeof(Msg), "%s (%d)\n%s (%d)\n%s (%d)", Vehiclename, acars[i]);
        DialogList(playerid, AVEHS, "Admin Vehicle List", Msg, "Delete", "Close");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)