Jump to content
UpperM

cannot createVehicle ItemGPS

Recommended Posts

Hi,

 

I have made a script where a player can rob gps from an another player. I want to place the GPS on the ground but the"createVehicle" dont work.
 
I get an error  "Cannot create non-ai vehicle itemGPS"
 
_pos = player modelToWorld[0,0.4,0]; 
_pos = [(_pos select 0),(_pos select 1),0]; 
_obj = "itemGPS" createVehicle _pos; 
_obj setPos _pos;

I tried with Chemlight an it's work.

 

 

 

 

Share this post


Link to post
Share on other sites

You need to create a "WeaponHolderSimulated", and then add the gps with addItemCargo.

_pos = player modelToWorld[0,0.4,0]; 
_pos = [(_pos select 0),(_pos select 1),0]; 
_holder = "WeaponHolderSimulated" createVehicle _pos;
_holder setPos _pos;
_holder addItemCargo ["itemGPS", 1];

If you use this in a multiplayer environment I suggest using addItemCargoGlobal. So it will be spawned for allplayers.

  • Like 1

Share this post


Link to post
Share on other sites

if i remember correct then u cant place stuff like weapos magazines and items on ground without something called like ground weapon holder.

Share this post


Link to post
Share on other sites

Thank guys it's work perfectly !

Share this post


Link to post
Share on other sites

You can create a vehicle of class "Item_ItemGPS", not "ItemGPS".

As sarogahtyp said, "you cant place stuff like weapos magazines and items on ground without something called like ground weapon holder".

Then, what happens when you create vehicle of class "Item_ItemGPS"? "Item_ItemGPS" is a vehicle class derived from "WeaponHolder" vehicle class (through "Item_Base_F"), so "Item_ItemGPS" is "WeaponHolder". It has corresponding model and set of transported items in "TransportItems" subentry. It is a shortcut to creating weapon holder, containing item "ItemGPS". So yes, weapon holders are still involved.

There are plenty of vehicle classes that mimick items laying on surfaces. Names of vehicle classes usually (but not obliged to be) of form "Item_className", where className is corresponding cfgWeapons subentry. Not every weapon and item presented here, check list of available classes in cfgVehicles.

 

Difference with the code posted by JasperRab is same as between "WeaponHolder" vs "WeaponHolderSimulated", plus you don't have to specially deal with MP (createVehicle is eG).

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×