Jump to content

Need Help with my grenade Launcher


Hadet Sonnenkern
 Share

You are about to reply to a thread that has been inactive for 4601 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I'm new to LSL but i have done this:

"integer have_permissions = FALSE;                                   fire(){    rotation rot = llGetRot();    vector vel = llRot2Fwd(rot);               vector pos = llGetPos();                   pos = pos + vel;                   pos.z += 0.75;                     vel = vel * 30;    llTriggerSound("Report", 1.0);     llRezObject("Frag", pos, vel, rot, 0);}default{    state_entry()    {        key owner = llGetOwner();        llPreloadSound("Report");        llListen(8,"",owner,"r");        if (!have_permissions)         {            llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION| PERMISSION_TAKE_CONTROLS);           }    }    listen(integer channel, string name, key id, string message)    {        llResetScript();    }    on_rez(integer param)    {        llResetScript();       }    run_time_permissions(integer permissions)    {    if (permissions == PERMISSION_TRIGGER_ANIMATION| PERMISSION_TAKE_CONTROLS)        {            llTakeControls(CONTROL_ML_LBUTTON, TRUE, FALSE);            llStartAnimation("hold_R_rifle");            have_permissions = TRUE;        }    }    attach(key attachedAgent)    {               if (attachedAgent != NULL_KEY)        {                        llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION| PERMISSION_TAKE_CONTROLS);           }        else        {            if (have_permissions)            {                llStopAnimation("hold_R_rifle");                llStopAnimation("aim_R_rifle");                llStopAnimation("hold_R_handgun");                llStopAnimation("aim_R_handgun");                llReleaseControls();                llSetRot(<0,0,0,1>);                have_permissions = FALSE;            }        }    }    control(key name, integer levels, integer edges)     {        if (  ((edges & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON)  &&((levels & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON) )        {            fire();        }    }    touch_end(integer num)    {        if (have_permissions)         {            ;        }        else         {               llWhisper(0, "wear me");        }    }}nteger num)    {        if (have_permissions)         {            ;        }        else         {               llWhisper(0, "wear me");        }    }}

 

And i'd like to make it have a set clip size and reload time of 20 seconds can anyone help?

 

Link to comment
Share on other sites

Word of advice there.... for another scripter to help you, they'll probably need to see neatly organized code.

Just like a story written without any punctuation, paragraphing, or indentation is very hard to read... so is this.

For example, you can edit your post to appear more like this:

 

integer have_permissions = FALSE;

     fire(){

          rotation rot = llGetRot();

          vector vel = llRot2Fwd(rot);

          vector pos = llGetPos();

          pos = pos + vel;

 

Once you lay it all out tidy like that you might actually immediately see what is wrong yourself!

As it appears in your post, it is far too jumbled for anyone to sort out most likely.

 

Link to comment
Share on other sites

little clipboard button, just right or the spoiler tag button (smiley with hands over it's eyes). gives you...

integer have_permissions = FALSE;fire(){	rotation rot = llGetRot();	vector vel = llRot2Fwd(rot);	vector pos = llGetPos();	pos = pos + vel;	pos.z += 0.75;	vel = vel * 30;	llTriggerSound("Report", 1.0);	llRezObject("Frag", pos, vel, rot, 0);}default{	state_entry(){		key owner = llGetOwner();		llPreloadSound("Report");		llListen(8,"",owner,"r");		if (!have_permissions){			llRequestPermissions( llGetOwner(),PERMISSION_TRIGGER_ANIMATION| PERMISSION_TAKE_CONTROLS);		}	}		listen( integer channel, string name, key id, string message ){		llResetScript();	}		on_rez( integer param ){		llResetScript();	}		run_time_permissions(integer permissions){		if (permissions == PERMISSION_TRIGGER_ANIMATION| PERMISSION_TAKE_CONTROLS){			llTakeControls(CONTROL_ML_LBUTTON, TRUE, FALSE);			llStartAnimation("hold_R_rifle");			have_permissions = TRUE;		}	}		attach(key attachedAgent){		if (attachedAgent != NULL_KEY){			llRequestPermissions( llGetOwner(), PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS );		}else{			if (have_permissions){				llStopAnimation("hold_R_rifle");				llStopAnimation("aim_R_rifle");				llStopAnimation("hold_R_handgun");				llStopAnimation("aim_R_handgun");				llReleaseControls();				llSetRot();				have_permissions = FALSE;			}		}	}		control( key name, integer levels, integer edges ){		if (((edges & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON)  && ((levels & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON)){			fire();		}	}		touch_end( integer num ){		if (have_permissions){			;		}else{			llWhisper( 0, "wear me" );		}	}}//-- minus some garbage that was at the end caused by double pasting...

 to add a clip size simply add a global variable with the number, check the number before firing, and subtract 1 when you do.

when the number is zero you can use either llSleep, or llSetTimerEvent [with or without a state change] and then reset the counter (either after the sleep, or in the timer event, just make sure you also stop the timer if you use that method)

ETA: and yes I did reformat from Allmans to 1TBS, if I have to do the formatting, that's what I'm going to use

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4601 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...