Skocz do zawartości

  • Zaloguj korzystając z Facebooka Zaloguj korzystając z Twittera Zaloguj przez Steam Zaloguj poprzez Google      Logowanie »   
  • Rejestracja

Witamy w Nieoficjalnym polskim support'cie AMX Mod X

Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.

  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz się do tematów i for, aby otrzymywać automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza społecznościowego
  • Stwórz swój własny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe doświadczenia

Dołączona grafika Dołączona grafika

Guest Message by DevFuse
 

Zdjęcie

Knife API


  • Nie możesz napisać tematu
  • Zaloguj się, aby dodać odpowiedź
Brak odpowiedzi do tego tematu

#1 Adminek AMXX.PL

    Admin :)

  • Bot

Reputacja: 156
Profesjonalista

  • Postów:7177
  • Lokalizacja:AMXX.PL
Offline

Napisano 12.05.2014 17:46

<!-- BEGIN TEMPLATE: postbit_external -->
<div><font face="Century Gothic"><b><font size="7"><font color="#d48484">Knife API v1.0</font></font></b><br /><br />I noticed there's no such thing called Knife API in the alliedmods forums which made me wonder how is that even possible with the recent popularity of billions of custom knives, especially on Jailbreak servers.<br />This mod should turn the pain of adding knives to the server into a breeze. <br /><br /><b>Warning:</b> It is an API. It's a set of tools that <b>YOU </b>should use to add knives <b>BY YOURSELF</b>. If someone decides to make a cool knife using this I'll append it to the main post, but that's about it. <b>I won't make any knife for this mod on request.</b><br /><br />By default, you have hands (knuckles from jailbreak). If you dislike this, comment this line in the code:<br /><!-- BEGIN TEMPLATE: bbcode_php_printable -->
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
<div class="alt2">
<hr />
<code style="white-space:nowrap">
<div dir="ltr" style="text-align:left;">
<!-- php buffer start --><code><span style="color: #000000">
<span style="color: #0000BB"></span><span style="color: #FF8000">#define&nbsp;DEFAULT_HANDS&nbsp;
<br /></span><span style="color: #0000BB"></span>
</span>
</code><!-- php buffer end -->
</div>
</code>
<hr />
</div>
</div>
<!-- END TEMPLATE: bbcode_php_printable --><b><font size="5"><font color="#d48484">Controls</font></font></b><br />You can add up to 32 knives to the game and the player can have all of them at the same time. To switch between your knives as a player, press the <b>R key</b> or the key you have bound <b>+reload</b> on.<br /><br />You can drop any knife THAT IS DROPPABLE (i.e. you set it in register_knife) by pressing <b>G (drop)</b>. Default knife cannot be dropped.<br /><br /><b><font size="5"><font color="#d48484">Cvars</font></font></b><ul><li>knifeapi_dropondeath (1|0, default 1) - <i>Whether or not you should drop all of your DROPPABLE knives on death.</i></li>
<li>knifeapi_lossondeath (1|0, default 1) - <i>Whether or not you should lose ALL of your knives on death. You should keep this 1 even if you have knifeapi_dropondeath set to 1, otherwise the player will still have knives even after dropping them.</i></li>
</ul><br /><b><font size="5"><font color="#d48484">Natives</font></font></b><br /><!-- BEGIN TEMPLATE: bbcode_php_printable -->
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
<div class="alt2">
<hr />
<code style="white-space:nowrap">
<div dir="ltr" style="text-align:left;">
<!-- php buffer start --><code><span style="color: #000000">
<span style="color: #0000BB">native&nbsp;register_knife</span><span style="color: #007700">(&nbsp;const&nbsp;</span><span style="color: #0000BB">v_model</span><span style="color: #007700">[&nbsp;]&nbsp;=&nbsp;</span><span style="color: #DD0000">""</span><span style="color: #007700">,&nbsp;const&nbsp;</span><span style="color: #0000BB">p_model</span><span style="color: #007700">[&nbsp;]&nbsp;=&nbsp;</span><span style="color: #DD0000">""</span><span style="color: #007700">,&nbsp;const&nbsp;</span><span style="color: #0000BB">w_model</span><span style="color: #007700">[&nbsp;]&nbsp;=&nbsp;</span><span style="color: #DD0000">""</span><span style="color: #007700">,&nbsp;const&nbsp;</span><span style="color: #0000BB">deploysound</span><span style="color: #007700">[&nbsp;]&nbsp;=&nbsp;</span><span style="color: #DD0000">""</span><span style="color: #007700">,&nbsp;const&nbsp;</span><span style="color: #0000BB">slashsound</span><span style="color: #007700">[&nbsp;]&nbsp;=&nbsp;</span><span style="color: #DD0000">""</span><span style="color: #007700">,&nbsp;const&nbsp;</span><span style="color: #0000BB">stabsound</span><span style="color: #007700">[&nbsp;]&nbsp;=&nbsp;</span><span style="color: #DD0000">""</span><span style="color: #007700">,&nbsp;const&nbsp;</span><span style="color: #0000BB">whiffsound</span><span style="color: #007700">[&nbsp;]&nbsp;=&nbsp;</span><span style="color: #DD0000">""</span><span style="color: #007700">,&nbsp;const&nbsp;</span><span style="color: #0000BB">wallsound</span><span style="color: #007700">[&nbsp;]&nbsp;=&nbsp;</span><span style="color: #DD0000">""</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">bool</span><span style="color: #007700">:</span><span style="color: #0000BB">bDroppable&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">false</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">Float</span><span style="color: #007700">:&nbsp;</span><span style="color: #0000BB">primarydamage</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">Float</span><span style="color: #007700">:&nbsp;</span><span style="color: #0000BB">secondarydamage</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">Float</span><span style="color: #007700">:&nbsp;</span><span style="color: #0000BB">primarydelay&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">0.0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">Float</span><span style="color: #007700">:&nbsp;</span><span style="color: #0000BB">secondarydelay&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">0.0&nbsp;</span><span style="color: #007700">)
<br /></span><span style="color: #FF8000">/*
<br />...&nbsp;That's&nbsp;a&nbsp;lot&nbsp;of&nbsp;arguments.&nbsp;They&nbsp;all&nbsp;should&nbsp;be&nbsp;self-explanatory,&nbsp;though.&nbsp;If&nbsp;you&nbsp;leave&nbsp;out&nbsp;any&nbsp;of&nbsp;the&nbsp;models&nbsp;empty,&nbsp;they&nbsp;won't&nbsp;be&nbsp;visible&nbsp;in-game&nbsp;(w_model&nbsp;will&nbsp;be&nbsp;replaced&nbsp;by&nbsp;w_backpack.mdl).&nbsp;This&nbsp;is&nbsp;good&nbsp;for&nbsp;the&nbsp;hands&nbsp;for&nbsp;example,&nbsp;p_model&nbsp;is&nbsp;not&nbsp;required&nbsp;so&nbsp;it's&nbsp;just&nbsp;left&nbsp;empty.&nbsp;If&nbsp;you&nbsp;leave&nbsp;any&nbsp;of&nbsp;the&nbsp;sounds&nbsp;empty,&nbsp;standard&nbsp;knife&nbsp;sounds&nbsp;will&nbsp;be&nbsp;used&nbsp;instead.&nbsp;The&nbsp;names&nbsp;may&nbsp;be&nbsp;confusing,&nbsp;but&nbsp;I&nbsp;found&nbsp;them&nbsp;better&nbsp;like&nbsp;this:
<br />Deploy&nbsp;sound&nbsp;-&nbsp;played&nbsp;on&nbsp;weapon&nbsp;deploy
<br />Slash&nbsp;sound&nbsp;-&nbsp;played&nbsp;on&nbsp;slash&nbsp;hit
<br />Stab&nbsp;sound&nbsp;-&nbsp;played&nbsp;on&nbsp;stab&nbsp;hit
<br />Whiff&nbsp;sound&nbsp;-&nbsp;played&nbsp;on&nbsp;slashing&nbsp;through&nbsp;the&nbsp;air
<br />Wall&nbsp;sound&nbsp;-&nbsp;played&nbsp;on&nbsp;hitting&nbsp;the&nbsp;wall
<br />
<br />bDroppable&nbsp;-&nbsp;if&nbsp;set&nbsp;to&nbsp;true,&nbsp;this&nbsp;knife&nbsp;will&nbsp;be&nbsp;droppable&nbsp;with&nbsp;the&nbsp;G&nbsp;button.
<br />Primary&nbsp;and&nbsp;secondary&nbsp;damage&nbsp;is&nbsp;self&nbsp;explanatory.
<br />Primary&nbsp;and&nbsp;secondary&nbsp;delay&nbsp;stand&nbsp;for&nbsp;the&nbsp;delay&nbsp;between&nbsp;attacks.&nbsp;If&nbsp;you&nbsp;leave&nbsp;this&nbsp;at&nbsp;0.0,&nbsp;default&nbsp;knife&nbsp;delays&nbsp;will&nbsp;be&nbsp;used&nbsp;instead.
<br />Returns&nbsp;the&nbsp;knife&nbsp;identifier&nbsp;used&nbsp;for&nbsp;other&nbsp;natives&nbsp;and&nbsp;in&nbsp;forwards.
<br />*/&nbsp;
<br /></span><span style="color: #0000BB"></span>
</span>
</code><!-- php buffer end -->
</div>
</code>
<hr />
</div>
</div>
<!-- END TEMPLATE: bbcode_php_printable --><!-- BEGIN TEMPLATE: bbcode_php_printable -->
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
<div class="alt2">
<hr />
<code style="white-space:nowrap">
<div dir="ltr" style="text-align:left;">
<!-- php buffer start --><code><span style="color: #000000">
<span style="color: #0000BB">native&nbsp;give_knife</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">id</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">iKnife&nbsp;</span><span style="color: #007700">)
<br /></span><span style="color: #FF8000">//Gives&nbsp;knife&nbsp;to&nbsp;a&nbsp;player.&nbsp;Self-explanatory&nbsp;arguments.
<br />//Returns&nbsp;1&nbsp;on&nbsp;success,&nbsp;-1&nbsp;if&nbsp;the&nbsp;player&nbsp;already&nbsp;has&nbsp;the&nbsp;knife.&nbsp;
<br /></span><span style="color: #0000BB"></span>
</span>
</code><!-- php buffer end -->
</div>
</code>
<hr />
</div>
</div>
<!-- END TEMPLATE: bbcode_php_printable --><!-- BEGIN TEMPLATE: bbcode_php_printable -->
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
<div class="alt2">
<hr />
<code style="white-space:nowrap">
<div dir="ltr" style="text-align:left;">
<!-- php buffer start --><code><span style="color: #000000">
<span style="color: #0000BB">native&nbsp;get_knife</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">id&nbsp;</span><span style="color: #007700">)
<br /></span><span style="color: #FF8000">//Gets&nbsp;the&nbsp;currently&nbsp;equipped&nbsp;knife&nbsp;of&nbsp;a&nbsp;player.&nbsp;
<br /></span><span style="color: #0000BB"></span>
</span>
</code><!-- php buffer end -->
</div>
</code>
<hr />
</div>
</div>
<!-- END TEMPLATE: bbcode_php_printable --><!-- BEGIN TEMPLATE: bbcode_php_printable -->
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
<div class="alt2">
<hr />
<code style="white-space:nowrap">
<div dir="ltr" style="text-align:left;">
<!-- php buffer start --><code><span style="color: #000000">
<span style="color: #0000BB">native&nbsp;has_knife</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">id</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">iKnife&nbsp;</span><span style="color: #007700">)
<br /></span><span style="color: #FF8000">//Returns&nbsp;1&nbsp;if&nbsp;player&nbsp;has&nbsp;knife,&nbsp;0&nbsp;if&nbsp;they&nbsp;don't.&nbsp;Self&nbsp;explanatory&nbsp;arguments.&nbsp;
<br /></span><span style="color: #0000BB"></span>
</span>
</code><!-- php buffer end -->
</div>
</code>
<hr />
</div>
</div>
<!-- END TEMPLATE: bbcode_php_printable --><!-- BEGIN TEMPLATE: bbcode_php_printable -->
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
<div class="alt2">
<hr />
<code style="white-space:nowrap">
<div dir="ltr" style="text-align:left;">
<!-- php buffer start --><code><span style="color: #000000">
<span style="color: #0000BB">native&nbsp;set_knife</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">id</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">iKnife&nbsp;</span><span style="color: #007700">)
<br /></span><span style="color: #FF8000">//Sets&nbsp;player's&nbsp;currently&nbsp;equipped&nbsp;knife&nbsp;to&nbsp;iKnife&nbsp;and&nbsp;redeploys&nbsp;their&nbsp;weapon.&nbsp;Returns&nbsp;-1&nbsp;if&nbsp;the&nbsp;player&nbsp;doesn't&nbsp;have&nbsp;said&nbsp;knife,&nbsp;1&nbsp;on&nbsp;success.&nbsp;
<br /></span><span style="color: #0000BB"></span>
</span>
</code><!-- php buffer end -->
</div>
</code>
<hr />
</div>
</div>
<!-- END TEMPLATE: bbcode_php_printable --><b><font size="5"><font color="#d48484">Forwards</font></font></b><br /><br /><b>Possible return values:</b><br /><!-- BEGIN TEMPLATE: bbcode_php_printable -->
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
<div class="alt2">
<hr />
<code style="white-space:nowrap">
<div dir="ltr" style="text-align:left;">
<!-- php buffer start --><code><span style="color: #000000">
<span style="color: #0000BB">enum&nbsp;_</span><span style="color: #007700">:&nbsp;</span><span style="color: #0000BB">ForwardReturns
<br /></span><span style="color: #007700">{
<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">KnifeAction_Block&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">5</span><span style="color: #007700">,&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;blocks&nbsp;the&nbsp;action&nbsp;completely
<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">KnifeAction_DoNothing&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;lets&nbsp;knifeapi&nbsp;do&nbsp;its&nbsp;job
<br /></span><span style="color: #007700">}&nbsp;
<br /></span><span style="color: #0000BB"></span>
</span>
</code><!-- php buffer end -->
</div>
</code>
<hr />
</div>
</div>
<!-- END TEMPLATE: bbcode_php_printable --><!-- BEGIN TEMPLATE: bbcode_php_printable -->
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
<div class="alt2">
<hr />
<code style="white-space:nowrap">
<div dir="ltr" style="text-align:left;">
<!-- php buffer start --><code><span style="color: #000000">
<span style="color: #0000BB">forward&nbsp;KnifeAction_TakeDamage</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">iAttacker</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">iVictim</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">Float</span><span style="color: #007700">:&nbsp;</span><span style="color: #0000BB">fDamage</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">iKnife&nbsp;</span><span style="color: #007700">)
<br /></span><span style="color: #FF8000">//Called&nbsp;on&nbsp;Ham_TakeDamage&nbsp;event.&nbsp;iKnife&nbsp;holds&nbsp;the&nbsp;knife&nbsp;ID.&nbsp;
<br /></span><span style="color: #0000BB"></span>
</span>
</code><!-- php buffer end -->
</div>
</code>
<hr />
</div>
</div>
<!-- END TEMPLATE: bbcode_php_printable --><!-- BEGIN TEMPLATE: bbcode_php_printable -->
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
<div class="alt2">
<hr />
<code style="white-space:nowrap">
<div dir="ltr" style="text-align:left;">
<!-- php buffer start --><code><span style="color: #000000">
<span style="color: #0000BB">forward&nbsp;KnifeAction_Deploy</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">iUser</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">iKnife&nbsp;</span><span style="color: #007700">)
<br /></span><span style="color: #FF8000">//Called&nbsp;on&nbsp;knife&nbsp;deploy.&nbsp;iKnife&nbsp;holds&nbsp;the&nbsp;knife&nbsp;ID.&nbsp;This&nbsp;is&nbsp;a&nbsp;post&nbsp;called&nbsp;forward,&nbsp;returning&nbsp;a&nbsp;value&nbsp;has&nbsp;no&nbsp;effect.&nbsp;
<br /></span><span style="color: #0000BB"></span>
</span>
</code><!-- php buffer end -->
</div>
</code>
<hr />
</div>
</div>
<!-- END TEMPLATE: bbcode_php_printable --><!-- BEGIN TEMPLATE: bbcode_php_printable -->
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
<div class="alt2">
<hr />
<code style="white-space:nowrap">
<div dir="ltr" style="text-align:left;">
<!-- php buffer start --><code><span style="color: #000000">
<span style="color: #0000BB">forward&nbsp;KnifeAction_PrimaryAttack</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">iUser</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">iKnife&nbsp;</span><span style="color: #007700">)
<br /></span><span style="color: #FF8000">//Called&nbsp;on&nbsp;knife&nbsp;primary&nbsp;attack.&nbsp;iKnife&nbsp;holds&nbsp;the&nbsp;knife&nbsp;ID.&nbsp;
<br /></span><span style="color: #0000BB"></span>
</span>
</code><!-- php buffer end -->
</div>
</code>
<hr />
</div>
</div>
<!-- END TEMPLATE: bbcode_php_printable --><!-- BEGIN TEMPLATE: bbcode_php_printable -->
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
<div class="alt2">
<hr />
<code style="white-space:nowrap">
<div dir="ltr" style="text-align:left;">
<!-- php buffer start --><code><span style="color: #000000">
<span style="color: #0000BB">forward&nbsp;KnifeAction_SecondaryAttack</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">iUser</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">iKnife&nbsp;</span><span style="color: #007700">)
<br /></span><span style="color: #FF8000">//See&nbsp;KnifeAction_PrimaryAttack.&nbsp;
<br /></span><span style="color: #0000BB"></span>
</span>
</code><!-- php buffer end -->
</div>
</code>
<hr />
</div>
</div>
<!-- END TEMPLATE: bbcode_php_printable --><!-- BEGIN TEMPLATE: bbcode_php_printable -->
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
<div class="alt2">
<hr />
<code style="white-space:nowrap">
<div dir="ltr" style="text-align:left;">
<!-- php buffer start --><code><span style="color: #000000">
<span style="color: #0000BB">forward&nbsp;KnifeAction_SoundPlay</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">iUser</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">iKnife</span><span style="color: #007700">,&nbsp;const&nbsp;</span><span style="color: #0000BB">szSound</span><span style="color: #007700">[&nbsp;]&nbsp;)
<br /></span><span style="color: #FF8000">//Fired&nbsp;when&nbsp;a&nbsp;sound&nbsp;is&nbsp;played.&nbsp;iKnife&nbsp;holds&nbsp;the&nbsp;knife&nbsp;ID,&nbsp;szSound&nbsp;is&nbsp;the&nbsp;music&nbsp;file&nbsp;sample.&nbsp;
<br /></span><span style="color: #0000BB"></span>
</span>
</code><!-- php buffer end -->
</div>
</code>
<hr />
</div>
</div>
<!-- END TEMPLATE: bbcode_php_printable --><b><font size="5"><font color="#d48484">Example</font></font></b><br />This will add the default CS knife. Do not use this if you commented #DEFAULT_HANDS in the API plugin.<br /><br /><!-- BEGIN TEMPLATE: bbcode_php_printable -->
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">PHP Code:</div>
<div class="alt2">
<hr />
<code style="white-space:nowrap">
<div dir="ltr" style="text-align:left;">
<!-- php buffer start --><code><span style="color: #000000">
<span style="color: #0000BB"></span><span style="color: #FF8000">#include&nbsp;&lt;&nbsp;amxmodx&nbsp;&gt;
<br />#include&nbsp;&lt;&nbsp;knife_api&nbsp;&gt;
<br />#include&nbsp;&lt;&nbsp;cstrike&nbsp;&gt;
<br />
<br /></span><span style="color: #007700">new&nbsp;</span><span style="color: #0000BB">g_iKnife
<br />
<br /></span><span style="color: #007700">new&nbsp;const&nbsp;</span><span style="color: #0000BB">VMODEL</span><span style="color: #007700">[&nbsp;]&nbsp;=&nbsp;</span><span style="color: #DD0000">"models/v_knife.mdl"
<br /></span><span style="color: #007700">new&nbsp;const&nbsp;</span><span style="color: #0000BB">PMODEL</span><span style="color: #007700">[&nbsp;]&nbsp;=&nbsp;</span><span style="color: #DD0000">"models/p_knife.mdl"
<br />
<br /></span><span style="color: #007700">const&nbsp;</span><span style="color: #0000BB">KNIFE_PRICE&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">300
<br />
<br /></span><span style="color: #007700">public&nbsp;</span><span style="color: #0000BB">plugin_precache</span><span style="color: #007700">(&nbsp;)
<br />{
<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;not&nbsp;needed&nbsp;in&nbsp;this&nbsp;case,&nbsp;it's&nbsp;for&nbsp;the&nbsp;sake&nbsp;of&nbsp;example
<br />&nbsp;&nbsp;&nbsp;&nbsp;
<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">precache_model</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">VMODEL&nbsp;</span><span style="color: #007700">)
<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">precache_model</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">PMODEL&nbsp;</span><span style="color: #007700">)
<br />&nbsp;&nbsp;&nbsp;&nbsp;
<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;ALWAYS&nbsp;precache&nbsp;your&nbsp;files.&nbsp;If&nbsp;you&nbsp;don't,&nbsp;the&nbsp;server&nbsp;will&nbsp;crash,&nbsp;knife&nbsp;API&nbsp;doesn't&nbsp;do&nbsp;it&nbsp;for&nbsp;you
<br /></span><span style="color: #007700">}
<br />
<br />public&nbsp;</span><span style="color: #0000BB">plugin_init</span><span style="color: #007700">(&nbsp;)
<br />{
<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">g_iKnife&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">register_knife</span><span style="color: #007700">(&nbsp;
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.</span><span style="color: #0000BB">v_model&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">VMODEL</span><span style="color: #007700">,
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.</span><span style="color: #0000BB">p_model&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">PMODEL</span><span style="color: #007700">,
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.</span><span style="color: #0000BB">w_model&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">""</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;don't&nbsp;need&nbsp;this,&nbsp;w_knife.mdl&nbsp;is&nbsp;bugged&nbsp;anyways,&nbsp;let's&nbsp;just&nbsp;use&nbsp;w_backpack.mdl&nbsp;or&nbsp;add&nbsp;your&nbsp;custom&nbsp;model
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">deploysound&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">""</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;we&nbsp;keep&nbsp;this&nbsp;default
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">slashsound&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">""</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;we&nbsp;keep&nbsp;this&nbsp;default
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">stabsound&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">""</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;we&nbsp;keep&nbsp;this&nbsp;default
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">whiffsound&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">""</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;we&nbsp;keep&nbsp;this&nbsp;default
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">wallsound&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">""</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;we&nbsp;keep&nbsp;this&nbsp;default
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">bDroppable&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;let's&nbsp;make&nbsp;the&nbsp;knife&nbsp;droppable
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">primarydamage&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">15.0</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;I&nbsp;think?
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">secondarydamage&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">55.0</span><span style="color: #007700">,</span><span style="color: #FF8000">//&nbsp;I&nbsp;think?
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">primarydelay&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">0.0</span><span style="color: #007700">,&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;no&nbsp;need&nbsp;to&nbsp;edit&nbsp;this
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">.</span><span style="color: #0000BB">secondarydelay&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">0.0&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;no&nbsp;need&nbsp;to&nbsp;edit&nbsp;this&nbsp;
<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">)
<br />&nbsp;&nbsp;&nbsp;&nbsp;
<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">register_plugin</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">"Knife&nbsp;API&nbsp;example"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"1.0"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"idiotstrike"&nbsp;</span><span style="color: #007700">)
<br />&nbsp;&nbsp;&nbsp;&nbsp;
<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">register_clcmd</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">"say&nbsp;/buyknife"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"cmdbuyknife"&nbsp;</span><span style="color: #007700">)
<br />}
<br />
<br />public&nbsp;</span><span style="color: #0000BB">cmdbuyknife</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">id&nbsp;</span><span style="color: #007700">)
<br />{
<br />&nbsp;&nbsp;&nbsp;&nbsp;if(&nbsp;!</span><span style="color: #0000BB">is_user_alive</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">id&nbsp;</span><span style="color: #007700">)&nbsp;)
<br />&nbsp;&nbsp;&nbsp;&nbsp;{
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">client_print</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">id</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">print_chat</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"You&nbsp;need&nbsp;to&nbsp;be&nbsp;alive."&nbsp;</span><span style="color: #007700">)
<br />&nbsp;&nbsp;&nbsp;&nbsp;}
<br />&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if(&nbsp;</span><span style="color: #0000BB">has_knife</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">id</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">g_iKnife&nbsp;</span><span style="color: #007700">)&nbsp;)
<br />&nbsp;&nbsp;&nbsp;&nbsp;{
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">client_print</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">id</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">print_chat</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"You&nbsp;already&nbsp;have&nbsp;this&nbsp;knife.&nbsp;Switch&nbsp;to&nbsp;knife&nbsp;and&nbsp;press&nbsp;R&nbsp;to&nbsp;see&nbsp;it."&nbsp;</span><span style="color: #007700">)
<br />&nbsp;&nbsp;&nbsp;&nbsp;}
<br />&nbsp;&nbsp;&nbsp;&nbsp;else
<br />&nbsp;&nbsp;&nbsp;&nbsp;{
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new&nbsp;</span><span style="color: #0000BB">iMoney&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">cs_get_user_money</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">id&nbsp;</span><span style="color: #007700">)
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(&nbsp;</span><span style="color: #0000BB">iMoney&nbsp;</span><span style="color: #007700">&lt;&nbsp;</span><span style="color: #0000BB">KNIFE_PRICE&nbsp;</span><span style="color: #007700">)
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">client_print</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">id</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">print_center</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"You&nbsp;have&nbsp;insufficient&nbsp;funds."&nbsp;</span><span style="color: #007700">)
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">give_knife</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">id</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">g_iKnife&nbsp;</span><span style="color: #007700">)
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">cs_set_user_money</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">id</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">iMoney&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">KNIFE_PRICE&nbsp;</span><span style="color: #007700">)
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br />&nbsp;&nbsp;&nbsp;&nbsp;}
<br />&nbsp;&nbsp;&nbsp;&nbsp;
<br />&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">PLUGIN_HANDLED
<br /></span><span style="color: #007700">}&nbsp;
<br /></span><span style="color: #0000BB"></span>
</span>
</code><!-- php buffer end -->
</div>
</code>
<hr />
</div>
</div>
<!-- END TEMPLATE: bbcode_php_printable -->The resources are not necessary if you decide to comment #DEFAULT_HANDS and use knife as default instead.<br /><br /><b><font size="5"><font color="#d48484">Video</font></font></b><br /><a href="https://www.youtube.com/watch?v=o3NdqBupyZE&amp;feature=youtu.be" target="_blank">Video of Knife API with the example plugin on YouTube</a><br /><br /></font></div>


<br /> <div style="padding:6px">








<fieldset class="fieldset">
<legend>Attached Files</legend>
<table cellpadding="0" cellspacing="3" border="0">
<!-- BEGIN TEMPLATE: postbit_attachment -->
<tr>
<td><img class="inlineimg" src="https://forums.allie.../attach/sma.gif" alt="File Type: sma" width="16" height="16" border="0" style="vertical-align:baseline" /></td>
<td>

<a href="http://www.amxmodx.o...?file_id=133423"><strong>Get Plugin</strong></a> or
<a href="https://forums.allie...38;d=1399912972">Get Source</a> (knifeapi.sma - 16.3 KB)

</td>
</tr>
<!-- END TEMPLATE: postbit_attachment --><!-- BEGIN TEMPLATE: postbit_attachment -->
<tr>
<td><img class="inlineimg" src="https://forums.allie.../attach/inc.gif" alt="File Type: inc" width="16" height="16" border="0" style="vertical-align:baseline" /></td>
<td>


<a href="https://forums.allie...38;d=1399912972">knife_api.inc</a> (900 Bytes)


</td>
</tr>
<!-- END TEMPLATE: postbit_attachment --><!-- BEGIN TEMPLATE: postbit_attachment -->
<tr>
<td><img class="inlineimg" src="https://forums.allie.../attach/zip.gif" alt="File Type: zip" width="16" height="16" border="0" style="vertical-align:baseline" /></td>
<td>


<a href="https://forums.allie...38;d=1399915424">resources.zip</a> (244.5 KB)


</td>
</tr>
<!-- END TEMPLATE: postbit_attachment -->
</table>
</fieldset>


</div>

<!-- END TEMPLATE: postbit_external -->

Wyświetl pełny artykuł




Użytkownicy przeglądający ten temat: 0

0 użytkowników, 0 gości, 0 anonimowych