<div>Give the infinity ammo for a player, who will buy it<br />Ammo will be reset during the infection<br /><br />Use <b>smlib.inc</b> and <b>zombieplague.inc</b> to compile the file.<br /><br /><div style="margin: 5px;">
<div class="smallfont" style="margin-bottom: 2px;">
<b>Spoiler</b> <input value="Show" style="margin: 0px; padding: 0px; width: 45px; font-size: 10px;" onclick="if(this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != 'inline')
{ this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'inline'; this.innerText = ''; this.value = 'Hide'; }
else
{ this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value='Show'; }" type="button">
</div>
<div class="alt2" style="border: 1px inset; padding: 6px;">
<div class="spoiler" style="display: none;"><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 /> * ============================================================================<br /> *<br /> * Zombie Plague Mod #3 Generation<br /> *<br /> *<br /> * Copyright © 2015 Nikita Ushakov (Ireland, Dublin)<br /> *<br /> * This program is free software: you can redistribute it and/or modify<br /> * it under the terms of the GNU General Public License as published by<br /> * the Free Software Foundation, either version 3 of the License, or<br /> * (at your option) any later version.<br /> *<br /> * This program is distributed in the hope that it will be useful,<br /> * but WITHOUT ANY WARRANTY; without even the implied warranty of<br /> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br /> * GNU General Public License for more details.<br /> *<br /> * You should have received a copy of the GNU General Public License<br /> * along with this program. If not, see <http://www.gnu.org/l...enses/>.<br/> *<br /> * ============================================================================<br /> **/<br /><br />#include <sourcemod><br />#include <sdktools><br />#include <sdkhooks><br />#include <smlib><br />#include <zombieplague><br /><br />#pragma newdecls required<br /><br />/**<br /> * @section Information about extra items.<br /> **/<br />#define EXTRA_ITEM_NAME "Infinity Ammo" <br />#define EXTRA_ITEM_COST 15<br />#define EXTRA_ITEM_LEVEL 0<br />#define EXTRA_ITEM_ONLINE 0<br />#define EXTRA_ITEM_LIMIT 0<br />/**<br /> * @endsection<br /> **/<br /> <br />/**<br /> * Record plugin info.<br /> **/<br /></span><span style="color: #007700">public </span><span style="color: #0000BB">Plugin myinfo </span><span style="color: #007700">=<br />{<br /> </span><span style="color: #0000BB">name </span><span style="color: #007700">= </span><span style="color: #DD0000">"[ZP] ExtraItem: infinity Ammo"</span><span style="color: #007700">,<br /> </span><span style="color: #0000BB">author </span><span style="color: #007700">= </span><span style="color: #DD0000">"qubka (Nikita Ushakov)"</span><span style="color: #007700">, <br /> </span><span style="color: #0000BB">description </span><span style="color: #007700">= </span><span style="color: #DD0000">""</span><span style="color: #007700">,<br /> </span><span style="color: #0000BB">version </span><span style="color: #007700">= </span><span style="color: #DD0000">"1.0"</span><span style="color: #007700">,<br /> </span><span style="color: #0000BB">url </span><span style="color: #007700">= </span><span style="color: #DD0000">"https://forums.alliedmods.net/showthread.php?t=272546"<br /></span><span style="color: #007700">}<br /><br /></span><span style="color: #FF8000">// Item index<br /></span><span style="color: #0000BB">int iItem</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// Boolean<br /></span><span style="color: #0000BB">bool InfinityAmmo</span><span style="color: #007700">[</span><span style="color: #0000BB">MAXPLAYERS</span><span style="color: #007700">+</span><span style="color: #0000BB">1</span><span style="color: #007700">];<br /><br /></span><span style="color: #FF8000">/**<br /> * Plugin is loading.<br /> **/<br /></span><span style="color: #007700">public </span><span style="color: #0000BB">void OnPluginStart</span><span style="color: #007700">()<br />{<br /> </span><span style="color: #FF8000">// Initilizate extra item<br /> </span><span style="color: #0000BB">iItem </span><span style="color: #007700">= </span><span style="color: #0000BB">ZP_RegisterExtraItem</span><span style="color: #007700">(</span><span style="color: #0000BB">EXTRA_ITEM_NAME</span><span style="color: #007700">, </span><span style="color: #0000BB">EXTRA_ITEM_COST</span><span style="color: #007700">, </span><span style="color: #0000BB">ZP_TEAM_HUMAN</span><span style="color: #007700">, </span><span style="color: #0000BB">EXTRA_ITEM_LEVEL</span><span style="color: #007700">, </span><span style="color: #0000BB">EXTRA_ITEM_ONLINE</span><span style="color: #007700">, </span><span style="color: #0000BB">EXTRA_ITEM_LIMIT</span><span style="color: #007700">);<br /><br /> </span><span style="color: #FF8000">// Hook spawn event<br /> </span><span style="color: #0000BB">HookEvent</span><span style="color: #007700">(</span><span style="color: #DD0000">"weapon_fire"</span><span style="color: #007700">, </span><span style="color: #0000BB">OnWeaponFire</span><span style="color: #007700">, </span><span style="color: #0000BB">EventHookMode_Post</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #FF8000">/**<br /> * Event callback (weapon_fire)<br /> * The player is spawning.<br /> * <br /> * @param gEventHook The event handle.<br /> * @param gEventName Name of the event.<br /> * @dontBroadcast If true, event is broadcasted to all clients, false if not.<br /> **/<br /></span><span style="color: #007700">public </span><span style="color: #0000BB">Action OnWeaponFire</span><span style="color: #007700">(</span><span style="color: #0000BB">Event gEventHook</span><span style="color: #007700">, const </span><span style="color: #0000BB">char</span><span style="color: #007700">[] </span><span style="color: #0000BB">gEventName</span><span style="color: #007700">, </span><span style="color: #0000BB">bool iDontBroadcast</span><span style="color: #007700">)<br />{<br /> </span><span style="color: #FF8000">// Get real player index from event key<br /> </span><span style="color: #0000BB">int clientIndex </span><span style="color: #007700">= </span><span style="color: #0000BB">GetClientOfUserId</span><span style="color: #007700">(</span><span style="color: #0000BB">GetEventInt</span><span style="color: #007700">(</span><span style="color: #0000BB">gEventHook</span><span style="color: #007700">, </span><span style="color: #DD0000">"userid"</span><span style="color: #007700">)); <br /><br /> </span><span style="color: #FF8000">// Verify that the client is exist<br /> </span><span style="color: #007700">if(</span><span style="color: #0000BB">IsPlayerExist</span><span style="color: #007700">(</span><span style="color: #0000BB">clientIndex</span><span style="color: #007700">))<br /> {<br /> </span><span style="color: #FF8000">// If the client have infinity ammo<br /> </span><span style="color: #007700">if(</span><span style="color: #0000BB">InfinityAmmo</span><span style="color: #007700">[</span><span style="color: #0000BB">clientIndex</span><span style="color: #007700">])<br /> {<br /> </span><span style="color: #FF8000">// Get active weapon<br /> </span><span style="color: #0000BB">int iWeapon </span><span style="color: #007700">= </span><span style="color: #0000BB">Client_GetActiveWeapon</span><span style="color: #007700">(</span><span style="color: #0000BB">clientIndex</span><span style="color: #007700">);<br /> <br /> </span><span style="color: #FF8000">// If weapon exist<br /> </span><span style="color: #007700">if(</span><span style="color: #0000BB">iWeapon </span><span style="color: #007700">!= </span><span style="color: #0000BB">INVALID_ENT_REFERENCE</span><span style="color: #007700">)<br /> {<br /> </span><span style="color: #FF8000">// Get ammo in clip<br /> </span><span style="color: #0000BB">int iClip1 </span><span style="color: #007700">= </span><span style="color: #0000BB">Weapon_GetPrimaryClip</span><span style="color: #007700">(</span><span style="color: #0000BB">iWeapon</span><span style="color: #007700">);<br /> </span><span style="color: #0000BB">int iClip2 </span><span style="color: #007700">= </span><span style="color: #0000BB">Weapon_GetSecondaryClip</span><span style="color: #007700">(</span><span style="color: #0000BB">iWeapon</span><span style="color: #007700">);<br /> <br /> </span><span style="color: #FF8000">// Set new amount of ammo<br /> </span><span style="color: #007700">if(</span><span style="color: #0000BB">iClip1 </span><span style="color: #007700">> -</span><span style="color: #0000BB">1</span><span style="color: #007700">) </span><span style="color: #0000BB">Weapon_SetPrimaryClip</span><span style="color: #007700">(</span><span style="color: #0000BB">iWeapon</span><span style="color: #007700">, </span><span style="color: #0000BB">iClip1</span><span style="color: #007700">+</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /> if(</span><span style="color: #0000BB">iClip2 </span><span style="color: #007700">> -</span><span style="color: #0000BB">1</span><span style="color: #007700">) </span><span style="color: #0000BB">Weapon_SetSecondaryClip</span><span style="color: #007700">(</span><span style="color: #0000BB">iWeapon</span><span style="color: #007700">, </span><span style="color: #0000BB">iClip2</span><span style="color: #007700">+</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /> }<br /> }<br /> }<br />}<br /><br /></span><span style="color: #FF8000">/**<br /> * Called after select an extraitem in equipment menu.<br /> * <br /> * @param clientIndex The index of the buyer.<br /> * @param extraitemIndex Index of extraitem from ZP_RegisterExtraItem() native.<br /> */<br /></span><span style="color: #007700">public </span><span style="color: #0000BB">Action ZP_OnExtraBuyCommand</span><span style="color: #007700">(</span><span style="color: #0000BB">int clientIndex</span><span style="color: #007700">, </span><span style="color: #0000BB">int extraitemIndex</span><span style="color: #007700">)<br />{<br /> </span><span style="color: #FF8000">// Verify that the client is connected and alive<br /> </span><span style="color: #007700">if(!</span><span style="color: #0000BB">IsPlayerExist</span><span style="color: #007700">(</span><span style="color: #0000BB">clientIndex</span><span style="color: #007700">))<br /> {<br /> return </span><span style="color: #0000BB">Plugin_Handled</span><span style="color: #007700">;<br /> }<br /> <br /> </span><span style="color: #FF8000">// Check our item index<br /> </span><span style="color: #007700">if(</span><span style="color: #0000BB">extraitemIndex </span><span style="color: #007700">== </span><span style="color: #0000BB">iItem</span><span style="color: #007700">)<br /> {<br /> </span><span style="color: #FF8000">// Return ammopacks<br /> </span><span style="color: #007700">if(</span><span style="color: #0000BB">ZP_IsPlayerZombie</span><span style="color: #007700">(</span><span style="color: #0000BB">clientIndex</span><span style="color: #007700">) || </span><span style="color: #0000BB">ZP_IsPlayerSurvivor</span><span style="color: #007700">(</span><span style="color: #0000BB">clientIndex</span><span style="color: #007700">))<br /> {<br /> return </span><span style="color: #0000BB">Plugin_Handled</span><span style="color: #007700">;<br /> }<br /> <br /> </span><span style="color: #FF8000">// Set ammo<br /> </span><span style="color: #0000BB">InfinityAmmo</span><span style="color: #007700">[</span><span style="color: #0000BB">clientIndex</span><span style="color: #007700">] = </span><span style="color: #0000BB">true</span><span style="color: #007700">;<br /> }<br /> <br /> </span><span style="color: #FF8000">// Allow buying<br /> </span><span style="color: #007700">return </span><span style="color: #0000BB">Plugin_Continue</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #FF8000">//**********************************************<br />//* OTHER FUNCTIONS *<br />//**********************************************<br /><br />/**<br /> * Called once a client is authorized and fully in-game, and <br /> * after all post-connection authorizations have been performed. <br /> *<br /> * This callback is gauranteed to occur on all clients, and always <br /> * after each OnClientPutInServer() call.<br /> * <br /> * @param clientIndex The client index. <br /> */<br /></span><span style="color: #007700">public </span><span style="color: #0000BB">void OnClientPutInServer</span><span style="color: #007700">(</span><span style="color: #0000BB">int clientIndex</span><span style="color: #007700">)<br />{<br /> </span><span style="color: #FF8000">// Reset ammo<br /> </span><span style="color: #0000BB">InfinityAmmo</span><span style="color: #007700">[</span><span style="color: #0000BB">clientIndex</span><span style="color: #007700">] = </span><span style="color: #0000BB">false</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #FF8000">/**<br /> * Called when a client became a zombie.<br /> * <br /> * @param clientIndex The client to infect.<br /> * @param infectorIndex The attacker who did the infect.<br /> *<br /> */<br /></span><span style="color: #007700">public </span><span style="color: #0000BB">void ZP_OnClientInfected</span><span style="color: #007700">(</span><span style="color: #0000BB">int clientIndex</span><span style="color: #007700">, </span><span style="color: #0000BB">int infectorIndex</span><span style="color: #007700">)<br />{<br /> </span><span style="color: #FF8000">// Reset ammo<br /> </span><span style="color: #0000BB">InfinityAmmo</span><span style="color: #007700">[</span><span style="color: #0000BB">clientIndex</span><span style="color: #007700">] = </span><span style="color: #0000BB">false</span><span style="color: #007700">;<br />}
<br /></span><span style="color: #0000BB"></span>
</span>
</code><!-- php buffer end -->
</div>
</code>
<hr />
</div>
</div></div>
</div>
</div></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/zip.gif"alt="File Type: zip" width="16" height="16" border="0" style="vertical-align:baseline" /></td>
<td>
<a href="https://forums.allie...include.zip</a>(69.5 KB)
</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

[CS:GO/ZP] ExtraItem: Infinity Ammo
Temat rozp. Adminek AMXX.PL, 26.04.2016 14:21
Brak odpowiedzi do tego tematu
Użytkownicy przeglądający ten temat: 0
0 użytkowników, 0 gości, 0 anonimowych