spawn car with VehicleID
#1

i need help with this. i want to save certain VehicleID(GetPlayerVehicleID() like 100 -200 for Admins. so when admins spawn a car with /veh they should get a car with id 100-200

pawn Код:
dcmd_veh(playerid,params[])
{
    if(AccInfo[playerid][Level] >= 1)
    {
        new Index;
        new tmp[256];  tmp  = strtok(params,Index);
        new tmp2[256]; tmp2 = strtok(params,Index);
        new tmp3[256]; tmp3 = strtok(params,Index);
       
        if(!strlen(tmp)) return
        SendClientMessage(playerid, red, "Usage: /veh [ModelID/Name]");
        new car;
        new carid;
        new string[128];
        new colour1, colour2;
        if(!IsNumeric(tmp))
        car = GetVehicleModelIDFromName(tmp);
        else car = strval(tmp);
        carid = GetPlayerVehicleID();
       
       
        if(car < 411 || car > 600) return  SendClientMessage(playerid, red, "Invalid Vehicle Model ID!");
        if(!strlen(tmp2)) colour1 = 0; else colour1 = strval(tmp2);
        if(!strlen(tmp3)) colour2 = 0; else colour2 = strval(tmp3);

        if(AccInfo[playerid][pCar] != -1 && !IsPlayerAdmin(playerid))
        EraseVeh(AccInfo[playerid][pCar]);
        new LVehicleID;
        new Float:X,Float:Y,Float:Z;
        new Float:Angle,int1;
        GetPlayerPos(playerid, X,Y,Z);
        GetPlayerFacingAngle(playerid,Angle);
        int1 = GetPlayerInterior(playerid);
        LVehicleID = CreateVehicle(car, X,Y-4,Z, Angle, colour1, colour2, -1);
        LinkVehicleToInterior(LVehicleID,int1);
        AccInfo[playerid][pCar] = LVehicleID;
        SendCommandToAdmins(playerid,"Car");
        format(string, sizeof(string), "%s Spawned a %s (Model:%d) Colours (%d, %d)", pName(playerid), VehicleNames[car-400], car, colour1, colour2);
        SaveIn("CarSpawns",string);
        format(string, sizeof(string), "Spawned a %s (%d)  Colors: %d,%d", VehicleNames[car-400], car, colour1, colour2);
        return SendClientMessage(playerid,LIGHTBLUE, string);
    }
    else return ErrorMessages(playerid, 6);
}
Reply
#2

You can't choose what ID a vehicle gets, it gets the lowest available ID (starting at 1).
Reply
#3

or can i get 1-100 for admins. something like that.?
Reply
#4

Lol, well you can spawn 100 vehicles when your server loads.
And everytime a admin spawns a car you remove on of those vehicle and replace them when the vehicle for the admin.
Ofcourse this can cause bugs and even lag.
If you are going to do this you should spawn all those 100 vehicles at one point .

So it's kind of alot work for a small result I guess.
Reply
#5

Okay make an array like this

pawn Код:
new AdminCars[100]; // 100 is the amoun tof mars (starting from 0 - 99
Now under OnGameModeInit()

pawn Код:
AdminCars[0] = AddStaicVehicle(..);
AdminCars[1] = AddStaticVehicle(..); // defines a vehicle id to an array number
Now you can make the command

I'm going to do this in zmcd as thats most common if you'd like a differnt command type tell me

pawn Код:
CMD:veh(playerid)
{
      new Float:Pos[3];
     if(PlayerInfo[playerid][pAdmin] >= level) // is admin level higher or eual to.
     new car = Random(sizeof(AdminCars)); // getting  random car
     GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]); // getting the admins pos to know where to put the car
     SetVehiclePos(car, Pos[0], Pos[1], Pos[2]); // placing the vehicle where the player is
     PutPlayerInVehicle(playerid, car, 0); // Putting him in the car
     return 1; // ending the command
}
NOTE: CHANGE the Admin Vehicle array to the mount of cars you have OR the command wont work if a car doesnt exist!


UNTESTED!

EDIT: Thanks a bunch for adding your command AFTER I slaved over this, great help!
Reply
#6

its like in Crazybobs. they spawn admin cars and normal cars.
Reply
#7

So wait let me get this clear, you want to spawn NEW cars now reserve some?
Reply
#8

yea Spawn new cars. when i spawn cars with /veh i should spawn admins only cars.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)