Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help

Billybob Street
Registered User
Join date: 18 Aug 2004
Posts: 26
08-10-2005 20:41
When i shoot my gun with this script that i been working on it says cannot find object abd no bullet comes out also the change bullet commands dont work any one see any thing wrong with it?


string sound;
string bullet;
integer gAttachPart = ATTACH_RHAND;

string INSTR_HELD_1 = "Enter Mouselook (press 'M') to shoot me.";
string INSTR_HELD_2 = "Right-click and choose 'Detach' to take me off.";

string INSTR_NOT_HELD_1 = "To wear and use me, right click and choose";
string INSTR_NOT_HELD_2 = "Acquire -> Attach -> Right Hand.";

string INSTR_NOT_OWNER_1 = "To use this gun, take it (right-click and choose 'Take'.)";
string INSTR_NOT_OWNER_2 = "Then, drag it from your inventory onto yourself.";


integer gDesiredPerm;

integer gHavePermissions;

// Bullet travel speed
float gBulletSpeed = 45.0;

float gLastFireTime = 0;

float gTapReloadTime = 0.01;

float gHoldReloadTime = 2;

float gOutOfAmmoReloadTime = 0.1;

integer gAmmoClipSize = 45;

integer gAmmo;

vector gEyeOffset = <0.0, 0.0, 0.84>;


say(string msg)
{
llSay(0, msg);
}
debug(string msg)
{
// llSay(0, msg);
}
func_debug(string msg)
{

}

default
{
on_rez(integer start_param)
{
func_debug("on_rez";);

vector size = llGetAgentSize(llGetOwner());
gEyeOffset.z = gEyeOffset.z * (size.z / 2.0);

llWhisper(0,"Press 'M' to enter mouslook and the mouse button to fire";);


}

state_entry()
{
func_debug("default state_entry";);
gHavePermissions = FALSE;

gDesiredPerm = (PERMISSION_TAKE_CONTROLS
| PERMISSION_TRIGGER_ANIMATION);

gAmmo = gAmmoClipSize;
llResetTime();
}

touch_start(integer tnum)
{
func_debug("touch_start";);

if ( llDetectedKey(0) == llGetOwner() )
{
if ( gHavePermissions )
{

} else
{

}
} else
{
// Not the owner

}
}
listen(integer channel,string name, key id, string message)
{


if(message == "SG on";)
{
sound = "grenade1";
}

if (message == "SG off";)
{
sound = "MG";
}
if (message == "SA on";)
{
llTriggerSound("SA", 0.7);
sound = "SA";
gTapReloadTime = 1.00;
gHoldReloadTime = 1.00;
}
if (message == "FA on";)
{
llTriggerSound("MG", 0.7);
sound = "MG";
gTapReloadTime = 0.01;
gHoldReloadTime = 0.01;
}
if (message == "push on";)
{
bullet == "PBullet";

}
if (message == "push off";)
{
bullet == "Bullet";
}
}
attach(key av_key)
{
func_debug("attach";);

if (av_key != NULL_KEY)
{

if ( av_key != llGetOwner() )
{
llWhisper(0, INSTR_NOT_OWNER_1);
llWhisper(0, INSTR_NOT_OWNER_2);
return;
}


llRequestPermissions(av_key, gDesiredPerm);


} else
{
func_debug(" detach";);

if ( gHavePermissions )
{

llStopAnimation("hold_R_rifle";);
llReleaseControls();
llSetRot(<0.0, 0.0, 0.0, 1.0>;);
gHavePermissions = FALSE;
}
}
}


run_time_permissions(integer perm)
{
func_debug("run_time_permissions";);

if ( (perm & gDesiredPerm) == gDesiredPerm )
{
func_debug(" got perms";);

gHavePermissions = TRUE;
llTakeControls(CONTROL_ML_LBUTTON, TRUE, FALSE);
llStartAnimation("hold_R_rifle";);
} else
{
func_debug(" didn't get perms";);

// we didn't get them, kill ourselves
llDie();
}
}


// the player has used the controls, process them
control(key owner, integer level, integer edge)
{
func_debug("control";);


float time = llGetTime();


if ( ( ((edge & level) & CONTROL_ML_LBUTTON)
&& (time > gTapReloadTime) )
|| ( (time > gHoldReloadTime)
&& (level & CONTROL_ML_LBUTTON) ) )
{

if ( (gAmmo >= 1) || (time > gOutOfAmmoReloadTime) )
{
// bang!
llTriggerSound("MG", 1.0);
llResetTime();

vector my_pos = llGetPos() + gEyeOffset;
rotation my_rot = llGetRot();
vector my_fwd = llRot2Fwd(my_rot);

llRezObject(bullet,
my_pos,
my_fwd * gBulletSpeed,
my_rot,
1);

llRezObject("shell", llGetPos(), llGetVel(),llGetRot(),1);


--gAmmo;
if ( gAmmo > 0 )
{

}
else if ( gAmmo == 0 )
{

llTriggerSound("pistol_reload.wav", 1.0);
}
else // gAmmo < 0
{

gAmmo = gAmmoClipSize - 1;
}
} else
{
debug("Can't shoot, reloading...";);
}
}

} // control

} // default state
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
08-10-2005 20:54
Just a quick guess, is there an actual bullet in the contents of your gun? If not, then your bullet was probably set to NO-COPY. With that setting, the bullet would fire once and be gone from the gun's contents afterwards.
Billybob Street
Registered User
Join date: 18 Aug 2004
Posts: 26
08-10-2005 21:02
the bullet dont even come out at all and yes its a real bullet
Cid Jacobs
Theoretical Meteorologist
Join date: 18 Jul 2004
Posts: 4,304
08-10-2005 21:08
From: Billybob Street
the bullet dont even come out at all and yes its a real bullet

Did you make sure the name of the bullet is "shell", capitalization is important.
_____________________
Billybob Street
Registered User
Join date: 18 Aug 2004
Posts: 26
08-10-2005 21:16
the shell thing is for the shell ejection when the gun shoots even when i get ride of that thing the same message comes up saying cannot find object
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
08-10-2005 21:35
Excuse me, but I didn't understand this section.
CODE
 if (message == "push on")
{
bullet == "PBullet";

}
if (message == "push off")
{
bullet == "Bullet";
}
:confused:
_____________________
:) Seagel Neville :)
Minsk Oud
Registered User
Join date: 12 Jul 2005
Posts: 85
08-10-2005 21:44
From: Seagel Neville
Excuse me, but I didn't understand this section.
CODE
 if (message == "push on")
{
bullet == "PBullet";

}
if (message == "push off")
{
bullet == "Bullet";
}
:confused:


That controls whether the bullet that will be rez'd will be the inventory object named PBullet (and presumably contains a push-on-impact script) or whether it will be the inventory object named Bullet. I tend to agree with the earlier comment that it is probably just inventory naming, though I have not read through the script in great detail.
_____________________
Ignorance is fleeting, but stupidity is forever. Ego, similar.
Billybob Street
Registered User
Join date: 18 Aug 2004
Posts: 26
08-10-2005 22:25
yes PBullet is a push bullet
Catherine Omega
Geometry Ninja
Join date: 10 Jan 2003
Posts: 2,053
08-10-2005 22:52
From: Minsk Oud
That controls whether the bullet that will be rez'd will be the inventory object named PBullet (and presumably contains a push-on-impact script) or whether it will be the inventory object named Bullet. I tend to agree with the earlier comment that it is probably just inventory naming, though I have not read through the script in great detail.
"==" is used to evaluate two values. "=" is used to assign a variable. Those should be "bullet = Pbullet" and "bullet = "Bullet", respectively.
_____________________
Need scripting help? Visit the LSL Wiki!
Omega Point - Catherine Omega's Blog
Billybob Street
Registered User
Join date: 18 Aug 2004
Posts: 26
08-11-2005 12:54
From: Catherine Omega
"==" is used to evaluate two values. "=" is used to assign a variable. Those should be "bullet = Pbullet" and "bullet = "Bullet", respectively.


i just tried that it still didnt work i have no clue what to do from here still says cannot find object and the bullets still dont change when you say the commands
Kiva Franklin
Registered User
Join date: 22 Jul 2005
Posts: 6
08-11-2005 13:32
It doesn't appear that this script has a listen handler at all in it. How are you handling that? While you have the listen() in there, there's no llListen.
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
08-11-2005 17:26
If it's at the point that it can't find the object named ______, then the problem is that whatever object you're calling with llRezObject() doesn't exist. It's that simple.

It appears that your script never gets to the point of assigning either "PBullet", or "Bullet" to the bullet string variable. Your listen may not be functioning properly. As a test, you can do two things;

First, add a debug line right before the lLRezObject(bullet....) line. The code should be a simple, llOwnerSay(bullet); - I suspect you'll find the script says _____ (nothing)

Second, when you declare the bullet string at the top of your code, declare an actual string instead of nothing. string bullet = "Bullet"; - that way, if your listen fails, the "Bullet" object will still be assigned to the bullet string variable.

Also, double check the case of your object contents names... "Bullet" versus "bullet," and "PBullet" versus "pbullet." They have to match exactly between script and contents.