Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Weapons LoLSBS_Gun_Script  

LoLSBS_Gun_Script

LoLSBS Gun Script.lsl

Category: Weapons
By : Anonymous
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for LoLSBS_Gun_Script
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. LoLSBS_Gun_Script_1.lsl
1
2 //This is a free script designed to be used with the Lance of Longinus Shield Breaker System.
3
4 //SETUP:
5 string firesound = ""; //Type the name of the sound you would like to use when firing between the "".
6 integer customanimation = FALSE; //Change to true to use a custom animation.
7 string customname = ""; //Type the name of the animation between the "".
8 integer handgun = TRUE; //If you are not using a custom animation, set to TRUE to use a default handgun animation. Set to FALSE to use a default rifle animation.
9 float firingpause = 1.0; //The pause in seconds between firing bullets.
10 integer fullauto = TRUE; //Set true to if you want the gun to fire as long as the button is held down, or set to false if you want the user to click for each shot.
11 integer multibullet = FALSE; //Set to TRUE to enable multi bullet. This allows the user to put in multiple bullets, and change them by clicking on the gun. The user must name the bullets Bullet1, Bullet2, Bullet3 and so on for all of the bullets.
12 //END SETUP
13
14
15
16 integer attached = FALSE;
17 integer permissions = FALSE;
18 float pausetimer = 0.0;
19 vector eye = <0.0, 0.0, 0.84>;
20 integer bullet = 1;
21
22
23
24 fire()
25 {
26 rotation rot = llGetRot();
27 vector fwd = llRot2Fwd(rot);
28 vector pos = llGetPos() + eye;
29 fwd *= 5;
30 llTriggerSound(firesound, 1.0);
31 if(multibullet)
32 {
33 llRezObject("Bullet" + (string)bullet, pos, fwd, rot, 0);
34 }
35 else
36 {
37 llRezObject("Bullet", pos, fwd, rot, 0);
38 }
39 pausetimer = llGetTime() + firingpause;
40 }
41
42
43 default
44 {
46 {
48 llPreloadSound(firesound);
50 eye.z = eye.z * (size.z / 2.0);
51 if(multibullet)
52 {
53 if(llGetInventoryType("Bullet1") == -1)
54 {
55 llSay(0, "ERROR! Bullet1 not found! Turning off Multi bullet support!");
56 multibullet = FALSE;
57 }
58 }
59
60 }
61
62 on_rez(integer param)
63 {
65 }
66
67 run_time_permissions(integer permissions)
68 {
69 if(permissions > 0)
70 {
71
72 if(!attached)
73 {
75 }
77 if(customanimation)
78 {
79 llStartAnimation(customname);
80 }
81 else if(handgun)
82 {
83 llStartAnimation("hold_R_handgun");
84 }
85 else
86 {
87 llStartAnimation("hold_R_rifle");
88 }
89
90 attached = TRUE;
91 permissions = TRUE;
92 }
93 }
94
95 attach(key attachedAgent)
96 {
97
98 if(attachedAgent != NULL_KEY)
99 {
100 attached = TRUE;
101
102 if(!permissions)
103 {
105 }
106
107 }
108 else
109 {
110
111 attached = FALSE;
112 if(customanimation)
113 {
114 llStopAnimation(customname);
115 }
116 else if(handgun)
117 {
118 llStopAnimation("hold_R_handgun");
119 }
120 else
121 {
122 llStopAnimation("hold_R_rifle");
123 }
125
126
127 }
128 }
129
130 control(key name, integer levels, integer edges)
131 {
133 {
134 if(fullauto)
135 {
136 {
137 if(llGetTime() > pausetimer)
138 {
139 fire();
140 }
141 }
142 }
144 {
145 {
146 if(llGetTime() > pausetimer)
147 {
148 fire();
149 }
150 }
151 }
152 }
153 }
154
155 touch_start(integer num_detected)
156 {
157 if(multibullet)
158 {
159 if(llGetInventoryType("Bullet" + (string)(bullet +1)) != -1)
160 {
161 bullet = bullet + 1;
162 }
163 else
164 {
165 bullet = 1;
166 }
167 llSay(0, "Now using bullet number " + (string)bullet);
168 }
169 }
170 }
171 // END //

Back to the Best Free Tools in Second Life and OpenSim.