Need scripting help with vehicle spawn command
#1

Looking for scripting help. I'm trying to script vehicle spawner by car type (LAW ENFOREMENT, ADMIN, CIVILIAN, DRIVER. I have already modified one gamemode of Cops And Robbers but i don't know how to add this to my vehicle spawner. So look here:

I have already defined car types in my gamemode:

#define VEHICLE_TYPE_LAW_ENFOREMENT 1 // if you enter this vehicle type as civilian, you get 8 wanted lvl stars
#define VEHICLE_TYPE_CIVILIAN 2 // Anyone can enter this type of vehicle
#define VEHICLE_TYPE_DRIVER 3 // This type of vehicle can be used for /driver [fare] (you can be on duty as taxi)
#define VEHICLE_TYPE_ADMIN 4 // Only Admins can use this type of vehicle. If player enter,he gets EJECTED

I Have used this for static vehicles:
// Car Spawns
/*
VEHICLE_TYPE_LAW_ENFOREMENT 1
VEHICLE_TYPE_CIVILIAN 2
VEHICLE_TYPE_DRIVER 3
VEHICLE_TYPE_ADMIN 4

CreateStaticVehicle(VEHICLE_TYPE_LAW_ENFOREMENT,mo delid,Float:X,Float:Y,Float:Z,Float:A,ColorOne,Col orTwo);
*/

But I want to make it also for spawned vehicles by an admin with command /v [model]. How can I add vehicle type to this command? I have already tried to do something but iam always getting atleast 5 errors.. By this command, you can only spawn CIVILIAN type of vehicle.

PHP код:
dcmd_v(playeridparams[])
{
    if(
IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] > 0)
    {
        new 
idx,modelid;
        new 
tmp[256],string[256];
        
tmp strtok(paramsidx);
        if(!
strlen(tmp))
        {
            
SendClientMessage(playeridCOLOR_ERROR"USAGE: /v (Modelid/Name)");
            return 
1;
        }
        
        
        if(
isNumeric(tmp))
        {
        
modelid strval(tmp);
        
        }else{
        
modelid GetVehicleModelIDFromNametmp );
        if( 
modelid == -)
        {
        
SendClientMessage(playeridCOLOR_ERROR"[ERROR] Invalid MODELID/NAME");
        return 
1;
        }
        }
        if(
modelid 400 || modelid 611)
        {
        
SendClientMessage(playeridCOLOR_ERROR"Enter A Vehicle Modelid Between 400 And 611");
        return 
1;
        }
        new 
Float:XFloat:YFloat:ZFloat:A;//,Interior,World;
        
GetPlayerPos(playeridXYZ);
        
GetPlayerFacingAngle(playeridA);
        
//Interior = GetPlayerInterior(playerid);
        //World = GetPlayerVirtualWorld(playerid);
        
GetXYInFrontOfPlayer(playeridXY5.0);
        
CreateVehicle(modelidX,Y,2.0,90.0,-1,-1,1000);
        
format(stringsizeof(string), "%s Spawned A (%s), Modelid: (%d)"PlayerInfo[playerid][pName], aVehicleNames[modelid 400], modelid);
}else{
    
SendClientMessage(playeridCOLOR_ERROR"Unknown Command! Type /cmds For Available Commands.");
    }
    return 
1;

Thank you for you help. I really need this in my gamemode
Reply
#2

rather than giving it type how about making a variable hold it?
PHP код:
#define MAX_ADMINVEHICLES 2
new AdminVehicle[MAX_ADMINVEHICLES]; 
then on your code upon creating
PHP код:
AdminVehicle[vehicleid] = CreateVehicle(params//<- that vehicleid should be a free id and you can make an admin only spawn two cars by adding some constraints 
You can also add constraints that a player tries to seat on the driver seat of the admin vehicle will be thrown off from the seat and will only be allowed to seat on the passenger seat. That's already easy.. so hope you get the idea and it helps.

Oh yeah ones the vehicle gets destroyed make sure to destroy it also or it will respawn on the spot you have created it...
Reply
#3

using AdminVehicle[vehicleid] will cause problems as the vehicle ID shouldn't be what you are using to track this. Especially in that reference.
Reply
#4

Nice idea, i will search how to destroy vehicle after spawn. But, that's not what i wanted. I wanted something like this in my php code: /v (model id /name) (ctype /car type) //civilian, law enforement, driver, admin
Reply
#5

What I would do is set a faction array, with [MAX_VEHICLES] and use that to track which faction each vehicle belongs to.

Then you just check the players faction/allegiance with the vehicles faction tag, and then you've got your information.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)