Need scripting help with vehicle spawn command -
DarknesS1988 - 19.09.2017
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(playerid, params[])
{
if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] > 0)
{
new idx,modelid;
new tmp[256],string[256];
tmp = strtok(params, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /v (Modelid/Name)");
return 1;
}
if(isNumeric(tmp))
{
modelid = strval(tmp);
}else{
modelid = GetVehicleModelIDFromName( tmp );
if( modelid == -1 )
{
SendClientMessage(playerid, COLOR_ERROR, "[ERROR] Invalid MODELID/NAME");
return 1;
}
}
if(modelid < 400 || modelid > 611)
{
SendClientMessage(playerid, COLOR_ERROR, "Enter A Vehicle Modelid Between 400 And 611");
return 1;
}
new Float:X, Float:Y, Float:Z, Float:A;//,Interior,World;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, A);
//Interior = GetPlayerInterior(playerid);
//World = GetPlayerVirtualWorld(playerid);
GetXYInFrontOfPlayer(playerid, X, Y, 5.0);
CreateVehicle(modelid, X,Y,Z + 2.0,A + 90.0,-1,-1,1000);
format(string, sizeof(string), "%s Spawned A (%s), Modelid: (%d)", PlayerInfo[playerid][pName], aVehicleNames[modelid - 400], modelid);
}else{
SendClientMessage(playerid, COLOR_ERROR, "Unknown Command! Type /cmds For Available Commands.");
}
return 1;
}
Thank you for you help. I really need this in my gamemode
Re: Need scripting help with vehicle spawn command -
JesterlJoker - 19.09.2017
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...
Re: Need scripting help with vehicle spawn command -
Sew_Sumi - 19.09.2017
using AdminVehicle[vehicleid] will cause problems as the vehicle ID shouldn't be what you are using to track this. Especially in that reference.
Re: Need scripting help with vehicle spawn command -
DarknesS1988 - 19.09.2017
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
Re: Need scripting help with vehicle spawn command -
Sew_Sumi - 19.09.2017
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.