Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Need help with making a script

Sinister Sloane
Registered User
Join date: 20 Aug 2006
Posts: 29
08-25-2006 12:30
I altered the example gun script because I'm a lazy arse. Anyway it was working fine origionally then I did this:
// Pistol // Ready Jack // 5.22.04 // 1.4

// Make sure these are right
integer channel = 0;
string deathmode = "defion";
string firemode = "firion";
string watermode = "waion";
string airmode = "aion";
integer mode = 0;
string gBulletName = "Death Orb";
string gShotSound = "Shot";
float gBulletSpeed = 7.5;
integer gBulletDamage = 100; // Passed to the bullet script via the rez param

// use a hold anim, you'll go
// into the aim anim automatically when entering mouselook
string gAnim = "hold_R_handgun";
integer gGrip = ATTACH_LLARM;
string gGripMessage = "this weapon only fits on your left wrist";
vector gAimOffsetConstant = <0.0, 0.0, 0.84>; // borrowed from the Revolver script
integer gEnableBullet;
integer gEnableSound;
integer gArmed;
vector gAimOffset;

say(string message)
{
llOwnerSay(message);
}

getPerms()
{
integer perms = llGetPermissions()
| PERMISSION_TAKE_CONTROLS
| PERMISSION_TRIGGER_ANIMATION
| PERMISSION_ATTACH;
llRequestPermissions(llGetOwner(), perms);
}

verifyInventory()
{
if (llGetInventoryKey(gBulletName) != NULL_KEY) {
gEnableBullet = TRUE;
} else {
gEnableBullet = FALSE;
say("bullet not found: " + gBulletName);
}
if (llGetInventoryKey(gShotSound) != NULL_KEY) {
gEnableSound = TRUE;
} else {
gEnableSound = FALSE;
// say("sound not found: " + gShotSound);
}
}

arm() {
integer perm = PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION;
if ((llGetPermissions() & perm) != perm ) {
getPerms();
} else {
llTakeControls(CONTROL_ML_LBUTTON, TRUE, FALSE);
llStartAnimation(gAnim);
gArmed = TRUE;
}
}

disarm() {
if(llGetAgentSize(llGetPermissionsKey()) != ZERO_VECTOR)
llStopAnimation(gAnim);
llReleaseControls();
gArmed = FALSE;
}


default
{
listen(integer channel,string Blah,key x,string message)
{
if(message == deathmode)
{
gBulletName = "Death Orb";
mode = 0;
}
if(message == firemode)
{
gBulletName = "Fire Orb";
mode = 1;
}
if(message == watermode)
{
gBulletName = "Water Orb";
mode = 2;
}
if(message == airmode)
{
gBulletName = "Air Orb";
mode = 3;
}
}
state_entry()
{
verifyInventory();
llListen(channel,"",llGetOwner(),"";);
llSetStatus(STATUS_PHANTOM,TRUE);
}

touch_start(integer count)
{
if (llDetectedKey(0) != llGetOwner()) {
return;
} else if (!llGetAttached()) {
getPerms();
} else if (gArmed) {
disarm();
} else {
arm();
}
}

run_time_permissions(integer perms)
{
if (perms & (PERMISSION_TAKE_CONTROLS
| PERMISSION_TRIGGER_ANIMATION
| PERMISSION_ATTACH)) {
if (!llGetAttached()) {
llAttachToAvatar(gGrip);
} else if (llGetAttached() != gGrip) {
say(gGripMessage);
llDetachFromAvatar();
} else {
verifyInventory();
arm();
}
} else {
say("insufficient permissions";);
if (llGetAttached()) llDetachFromAvatar();
}
}

attach(key avatar)
{
if (avatar != NULL_KEY) {
// attaching
vector size = llGetAgentSize(avatar);
gAimOffset = gAimOffsetConstant;
gAimOffset.z *= size.z / 2.0;
getPerms();
} else {
// detaching
if (gArmed) disarm();
}
}
on_rez(integer start_param)
{
llResetScript();
}

control(key avatar, integer levels, integer edges)
{
// mouse press
if ((levels & CONTROL_ML_LBUTTON) && (edges & CONTROL_ML_LBUTTON)) {
}

// mouse release
if (!(levels & CONTROL_ML_LBUTTON) && (edges & CONTROL_ML_LBUTTON)) {
if (gEnableSound) llTriggerSound(gShotSound, 1.0);
rotation rot = llGetRot();
vector aim = llRot2Fwd(rot);
vector pos = llGetPos() + gAimOffset + (aim * 1.0);
llRezObject(gBulletName, pos, aim * gBulletSpeed, rot, gBulletDamage);
}


// mouse down
if ((levels & CONTROL_ML_LBUTTON) && !(edges & CONTROL_ML_LBUTTON)) {
}
}
}


The bullets are identical except with different colour partical emitters. When I press the mouse button it does the firing animation but it doesn't shoot any of the bullets.
aceofspades Tully
Registered User
Join date: 25 Mar 2006
Posts: 7
08-25-2006 15:32
are you getting cannot find bullet message
Sinister Sloane
Registered User
Join date: 20 Aug 2006
Posts: 29
08-26-2006 06:06
From: aceofspades Tully
are you getting cannot find bullet message

No, I have all the bullets in the contents.
Anyway I thought of a different method which will probably cut the script in half and work.