st1x51
160 постов
Карма: 8
#1 16 января 2012 в 15:21
Шаг 1<br />Создайте текстовый файл и назовите его flash.qc ,вставьте в этот файл то,что написано ниже, и положите&nbsp; flash.qc&nbsp; в папку со своими исходниками<br /><br />void() W_SetCurrentAmmo;void() flash_update =<br />{<br />&nbsp; &nbsp; &nbsp; &nbsp; // The Player is dead so turn the Flashlight off<br />&nbsp; &nbsp; &nbsp; &nbsp; if (self.owner.deadflag != DEAD_NO)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.effects = 0;<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; // The Player is alive so turn On the Flashlight<br />&nbsp; &nbsp; &nbsp; &nbsp; else&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.effects = EF_DIMLIGHT;&nbsp; <br /><br />&nbsp; &nbsp; &nbsp; &nbsp; // Find out which direction player facing<br />&nbsp; &nbsp; &nbsp; &nbsp; makevectors (self.owner.v_angle);<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; // Check if there is any things infront of the flashlight<br />&nbsp; &nbsp; &nbsp; &nbsp; traceline (self.owner.origin , (self.owner.origin+(v_forward * 500)) , FALSE , self);<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; // Set the Flashlight&#039;s position<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; setorigin (self, trace_endpos+(v_forward * -5));<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; // Repeat it in 0.02 seconds...<br />&nbsp; &nbsp; &nbsp; &nbsp; self.nextthink = time + 0.02;<br />};<br /><br />void() flash_on =<br />{<br />&nbsp; &nbsp; &nbsp; &nbsp; // Make a new entity to hold the Flashlight<br />&nbsp; &nbsp; &nbsp; &nbsp; local entity myflash;<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; // spawn flash<br />&nbsp; &nbsp; &nbsp; &nbsp; myflash = spawn ();<br />&nbsp; &nbsp; &nbsp; &nbsp; myflash.movetype = MOVETYPE_NONE;<br />&nbsp; &nbsp; &nbsp; &nbsp; myflash.solid = SOLID_NOT;<br />&nbsp; &nbsp; &nbsp; &nbsp; // this uses the s_bubble.spr, if you want it to be completly<br />&nbsp; &nbsp; &nbsp; &nbsp; // invisible you need to create a one pixel trancparent spirit<br />&nbsp; &nbsp; &nbsp; &nbsp; // and use it here...<br />&nbsp; &nbsp; &nbsp; &nbsp; setmodel (myflash, &quot;progs/s_bubble.spr&quot;); <br />&nbsp; &nbsp; &nbsp; &nbsp; setsize (myflash, &#039;0 0 0&#039;, &#039;0 0 0&#039;);<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; // Wire Player And Flashlight Together<br />&nbsp; &nbsp; &nbsp; &nbsp; myflash.owner = self;<br />&nbsp; &nbsp; &nbsp; &nbsp; self.flash = myflash;<br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; // give the flash a Name And Make It Glow<br />&nbsp; &nbsp; &nbsp; &nbsp; myflash.classname = &quot;flash&quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; myflash.effects = EF_DIMLIGHT;<br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; // Set Start Position<br />&nbsp; &nbsp; &nbsp; &nbsp; makevectors (self.v_angle);<br />&nbsp; &nbsp; &nbsp; &nbsp; traceline (self.origin , (self.origin+(v_forward * 500)) , FALSE , self);<br />&nbsp; &nbsp; &nbsp; &nbsp; setorigin (myflash, trace_endpos);<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; // Start Flashlight Update<br />&nbsp; &nbsp; &nbsp; &nbsp; myflash.think = flash_update;<br />&nbsp; &nbsp; &nbsp; &nbsp; myflash.nextthink = time + 0.02;<br />};<br /><br /><br />void () flash_toggle =<br />{<br />&nbsp; &nbsp; &nbsp; &nbsp; // If Off, Turn On<br />&nbsp; &nbsp; &nbsp; &nbsp; if (self.flash_flag == FALSE)<br />&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.flash_flag = TRUE;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flash_on();<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; // If On, Turn Off<br />&nbsp; &nbsp; &nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.flash_flag = FALSE;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; W_SetCurrentAmmo ();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.flash.think = SUB_Remove;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.flash.nextthink = time + 0.1;<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />};<br /><br /><br />Шаг 2<br />Откройте defs.qc и добавьте в конец следующие строки:<br /><br />.float flash_flag; // On/off for the flashlight<br />.entity flash;&nbsp; // flash entity<br /><br /><br />Шаг 3<br />Откройте weapons.qc и найдите строку ImpulseCommands (она почти в самом низу),после<br /><br />self.impulse = 0;<br /><br />добавьте:<br /><br />if (self.impulse == 30) <br />&nbsp; &nbsp; &nbsp; &nbsp; flash_toggle();<br /><br /><br />Шаг 4<br />Теперь вы должны прописать flash.qc в файл progs.scr . Напишите flash.qc под defs.qc.<br /><br />Шаг 5<br />Компилируем файлы и кидаем наш progs.dat в папку с нашим модом(игрой), напишите в консоле impulse 30 ии тадаам,фонарик :D<br /><br />P.S: для полного удобства,чтобы не лазить все время в консоль,можно сделать так: bind &quot;f&quot; &quot;impulse 30&quot;<br /><br />Автор кода:ShockMan<br />