<div><b><br /><font size="8"><font color="orange">[BB] Addon: Ammo-Pack System</font></font><font color="orange"><br /></font><font size="6">Author: <font color="orange">crnova<br /></font>Version: <font color="orange">1.0</font></font><font color="orange"><br /></font></b><font color="orange"><br /><br /><br /><font size="5">Description:</font></font><br /><br />- This plugin adds in an Ammo-Pack system similar to that one of <a href="https://forums.allie...ad.php?t=72505"target="_blank">Zombie Plague Mod</a>.<br /><br /><br /><font size="5"><font color="orange">Features:</font></font><br /><br />- API Shop.<br />- Hud Info.<br />- nVault saving.<br />- Ammo-Pack rewards for both humans & zombies.<br />- Ammo-Pack as price.<br /><br /><font size="5"><font color="orange">Requirements:</font></font><br /><br />- HudInfo plugin is required in order to see how much ammo pack you got! (download in this post)<br />- AMXMODX 1.8+<br />- Base Builder<br />- Modules<br /><div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">Code:</div>
<hr /><code style="margin:0px" dir="ltr" style="text-align:left"> <br />#include <hamsandwich><br />#include <nvault><br />#include <fakemeta></code><hr />
</div><font size="5"><font color="orange">Installation:</font></font><br /><br />- The "bb_ammopacks.inc" file will go in 'addonsamxmodxscriptingincludes' folder.<br />- The sma files must be compiled locally and the output .amxx file will go in 'addonsamxmodxplugins' folder.<br /><br /><br /><font size="5"><font color="orange">Api Tutorial:</font></font><br /><br />- Alright so i'm gonna show you how to make your sub-plugin for the Ammo-Pack API Shop, first thing you should is register the shop item you're about to add, now in example<br /><br /><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: #007700">public </span><span style="color: #0000BB">plugin_init</span><span style="color: #007700">()
<br />{
<br /> </span><span style="color: #0000BB">bb_shop_item_add</span><span style="color: #007700">( </span><span style="color: #DD0000">"Double Health"</span><span style="color: #007700">, </span><span style="color: #0000BB">50</span><span style="color: #007700">, </span><span style="color: #DD0000">"DoubleHealth_Handler"</span><span style="color: #007700">)
<br />}
<br /></span><span style="color: #0000BB"></span>
</span>
</code><!-- php buffer end -->
</div>
</code>
<hr />
</div>
</div>The first parameter is the name of the shop item that's gonna show up in the shop menu, the second parameter is the price for the item, and the last parameter is the item handler,<br /><br />Example for item Handler:<br /><br /><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: #007700">public </span><span style="color: #0000BB">DoubleHealth_Handler</span><span style="color: #007700">(</span><span style="color: #0000BB">id</span><span style="color: #007700">)
<br />{
<br /> </span><span style="color: #0000BB">set_user_health</span><span style="color: #007700">( </span><span style="color: #0000BB">id</span><span style="color: #007700">, </span><span style="color: #0000BB">get_user_health</span><span style="color: #007700">(</span><span style="color: #0000BB">id</span><span style="color: #007700">) * </span><span style="color: #0000BB">2</span><span style="color: #007700">)
<br />}
<br /></span><span style="color: #0000BB"></span>
</span>
</code><!-- php buffer end -->
</div>
</code>
<hr />
</div>
</div>Basically what the item will do, is double the purchaser's health, in example before we bought the item, our health was 2000, after we bought the item it's 4000.<br /><br />the full sub-plugin is gonna look like this<br /><br /><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 <amxmisc> //No need to include amxmodx, because when amxmisc is included, amxmodx is included too
<br />#include <fun> // the include that's gonna handle our "set_user_health" function
<br />
<br />//Initialize our sub-plugin
<br /></span><span style="color: #007700">public </span><span style="color: #0000BB">plugin_init</span><span style="color: #007700">()
<br />{
<br /> </span><span style="color: #0000BB">bb_shop_item_add</span><span style="color: #007700">( </span><span style="color: #DD0000">"Double Health"</span><span style="color: #007700">, </span><span style="color: #0000BB">50</span><span style="color: #007700">, </span><span style="color: #DD0000">"DoubleHealth_Handler"</span><span style="color: #007700">) </span><span style="color: #FF8000">//Add our shop item
<br /></span><span style="color: #007700">}
<br />
<br /></span><span style="color: #FF8000">//Handle our shop item
<br /></span><span style="color: #007700">public </span><span style="color: #0000BB">DoubleHealth_Handler</span><span style="color: #007700">(</span><span style="color: #0000BB">id</span><span style="color: #007700">)
<br />{
<br /> </span><span style="color: #0000BB">set_user_health</span><span style="color: #007700">( </span><span style="color: #0000BB">id</span><span style="color: #007700">, </span><span style="color: #0000BB">get_user_health</span><span style="color: #007700">(</span><span style="color: #0000BB">id</span><span style="color: #007700">) * </span><span style="color: #0000BB">2</span><span style="color: #007700">) </span><span style="color: #FF8000">//the function that's gonna double the purchaser's health.
<br /></span><span style="color: #007700">}
<br /></span><span style="color: #0000BB"></span>
</span>
</code><!-- php buffer end -->
</div>
</code>
<hr />
</div>
</div><br /><font size="5"><font color="orange">Cvars, Commands and Natives:</font></font><br /><br /><font size="2"><font color="blue">Cvars:</font></font><br /><div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">Code:</div>
<hr /><code style="margin:0px" dir="ltr" style="text-align:left">// Ammopack reward for the zombie that killed the human<br />// default = "25"<br />ap_human_killed_reward "25"<br /><br />// Ammopack reward for the human that killed the zombie.<br />// default = "5"<br />ap_zombie_killed_reward "5"</code><hr />
</div><font size="2"><font color="blue">Commands:</font></font><br /><div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">Code:</div>
<hr /><code style="margin:0px" dir="ltr" style="text-align:left">"say /shop" // Opens our shop menu<br />"amx_give_ap <name> <amount>" // Gives our target Ammo-pack, accessible only by immunity admins!<br />"amx_remove_ap <name> <amount>" //Takes ammo-pack from our target, accessible only by immunity admins!</code><hr />
</div><font size="2"><font color="blue">Natives:</font></font><br /><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">/*
<br />* @param name Item Name
<br />* @param cost Item Cost
<br />* @param handler Item Function Handler
<br />*/
<br />
<br /></span><span style="color: #0000BB">native bb_shop_item_add</span><span style="color: #007700">( const </span><span style="color: #0000BB">szName</span><span style="color: #007700">[], const </span><span style="color: #0000BB">iCost</span><span style="color: #007700">, const </span><span style="color: #0000BB">szHandler</span><span style="color: #007700">[])
<br />
<br /></span><span style="color: #FF8000">/*
<br />* @param index player index
<br />* @return returns player index ammo pack
<br />*/
<br />
<br /></span><span style="color: #0000BB">native bb_get_user_ap</span><span style="color: #007700">(</span><span style="color: #0000BB">Index</span><span style="color: #007700">)
<br /></span><span style="color: #0000BB"></span>
</span>
</code><!-- php buffer end -->
</div>
</code>
<hr />
</div>
</div><br /><font size="5"><font color="orange">Changelog</font></font><br /><br /><div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px">Code:</div>
<hr /><code style="margin:0px" dir="ltr" style="text-align:left">v1.0 - Released</code><hr />
</div><br /><font size="5"><font color="orange">Credits:</font></font><br /><br />- <a href="https://forums.allie...er.php?u=33273"target="_blank">MeRcyLeZZ</a> for the idea.</div>
<br /> <div style="padding:6px">
<fieldset class="fieldset">
<legend>Attached Files</legend>
<table cellpadding="0" cellspacing="3" border="0">
<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...69"><strong>GetPlugin</strong></a> or
<a href="https://forums.allie...1456258649">GetSource</a> (bb_hudinfo.sma - 1.8 KB)
</td>
</tr><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...73"><strong>GetPlugin</strong></a> or
<a href="https://forums.allie...1456260076">GetSource</a> (bb_ammopacks.sma - 8.0 KB)
</td>
</tr><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...mopacks.inc</a>(1,018 Bytes)
</td>
</tr>
</table>
</fieldset>
</div>
Wyświetl pełny artykuł
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.
|
Guest Message by DevFuse

[BB] Addon: Ammo-Pack System
Temat rozp. Adminek AMXX.PL, 23.02.2016 22:03
Brak odpowiedzi do tego tematu
Użytkownicy przeglądający ten temat: 0
0 użytkowników, 0 gości, 0 anonimowych