dim3 Forum

Full Version: Error with weapon
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, i need help with this script. I have just created a weapon but the ammo doesnt work with it. when i try to take the ammo it says "68:Named Weapon does not exist in Object".

// ***********************************************************
//
// OBJECT: Ammo Item
//
// This is a generic script that uses parameters passed from the
// spot that created it to become a certain type of ammo pickup item.
//
// param 0 = Model texture frame to use
// param 1 = Weapon to add ammo to
// param 2 = # of ammo to add
// param 3 = # of clips to add
// param 4 = # of alt ammo to add
// param 5 = # of alt clips to add
//
// ***********************************************************

//
// ammo item construction
//

function ammoItemConstruct(obj)
{
obj.setting.suspend=true;
obj.setting.pickUp=true;

// model

obj.model.on=true;
obj.model.name='MODERN AK';
obj.model.lit=DIM3_MODEL_LIT_HILITE;
obj.model.bounce=true;
obj.model.spin.y=1;

// settings

obj.size.x=600;
obj.size.z=600;
obj.size.y=600;
}

//
// ammo item spawn
//

function ammoItemSpawn(obj)
{
var frame;

frame=parseInt(obj.setting.getParameter(0));
obj.model.fill.change(0,frame);
}

//
// ammo item pickup callback
//

function ammoItemPickup(obj)
{
var weaponName,
ammoCount,clipCount,
altAmmoCount,altClipCount;

// add ammo

weaponName=obj.setting.getParameter(1);

ammoCount=parseInt(obj.setting.getParameter(2));
if (ammoCount!=0) {
obj.pickup.addAmmo(obj.pickup.objectId,weaponName,ammoCount);
}

clipCount=parseInt(obj.setting.getParameter(3));
if (clipCount!=0) {
obj.pickup.addClip(obj.pickup.objectId,weaponName,clipCount);
}

altAmmoCount=parseInt(obj.setting.getParameter(4));
if (altAmmoCount!=0) {
obj.pickup.addAltAmmo(obj.pickup.objectId,weaponName,altAmmoCount);
}

altClipCount=parseInt(obj.setting.getParameter(5));
if (altClipCount!=0) {
obj.pickup.addAltClip(obj.pickup.objectId,weaponName,altClipCount);
}

// turn off pickups and hide

sound.play('Got Ammo',obj.position.x,obj.position.z,obj.position.y,1);

obj.setting.contact=false;
obj.setting.hidden=true;

// set a wait timer to reappear

obj.event.chain(50,'ammoItemReappear');
}

//
// ammo item reappear
//

function ammoItemReappear(obj,tick)
{
sound.play('Got Ammo',obj.position.x,obj.position.z,obj.position.y,1.5);

obj.setting.hidden=false;
obj.setting.contact=true;
}

//
// ammo item events
//

function event(obj,mainEvent,subEvent,id,tick)
{
switch (mainEvent) {

case DIM3_EVENT_CONSTRUCT:
ammoItemConstruct(obj);
return;

case DIM3_EVENT_SPAWN:
ammoItemSpawn(obj);
return;

case DIM3_EVENT_PICKUP:
ammoItemPickup(obj);
return;

}
}


The RED text is line 68.
Look at the comment section at the top of the script.
Code:
// param 0 = Model texture frame to use
// param 1 = Weapon to add ammo to
// param 2 = # of ammo to add
// param 3 = # of clips to add
// param 4 = # of alt ammo to add
// param 5 = # of alt clips to add
You will have to set those parameters in the editor by double clicking the spot. Then it should work.
Bink Wrote:Look at the comment section at the top of the script.
Code:
// param 0 = Model texture frame to use
// param 1 = Weapon to add ammo to
// param 2 = # of ammo to add
// param 3 = # of clips to add
// param 4 = # of alt ammo to add
// param 5 = # of alt clips to add
You will have to set those parameters in the editor by double clicking the spot. Then it should work.

Thank you so much, you have been great help for my last questions to. I shoud have a well-earned cookie!
[Image: chocolate_chip_cookie.jpg]
Reference URL's