owner_2019 Opublikowano Kwiecień 26, 2016 o 13:21 Udostępnij Opublikowano Kwiecień 26, 2016 o 13:21 Give the infinity ammo for a player, who will buy it Ammo will be reset during the infection Use smlib.inc and zombieplague.inc to compile the file. Spoiler PHP Code: /** * ============================================================================ * * Zombie Plague Mod #3 Generation * * * Copyright (C) 2015 Nikita Ushakov (Ireland, Dublin) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * ============================================================================ **/#include <sourcemod>#include <sdktools>#include <sdkhooks>#include <smlib>#include <zombieplague>#pragma newdecls required/** * @section Information about extra items. **/#define EXTRA_ITEM_NAME "Infinity Ammo" #define EXTRA_ITEM_COST 15#define EXTRA_ITEM_LEVEL 0#define EXTRA_ITEM_ONLINE 0#define EXTRA_ITEM_LIMIT 0/** * @endsection **/ /** * Record plugin info. **/public Plugin myinfo ={ name = "[ZP] ExtraItem: infinity Ammo", author = "qubka (Nikita Ushakov)", description = "", version = "1.0", url = "https://forums.alliedmods.net/showthread.php?t=272546"}// Item indexint iItem;// Booleanbool InfinityAmmo[MAXPLAYERS+1];/** * Plugin is loading. **/public void OnPluginStart(){ // Initilizate extra item iItem = ZP_RegisterExtraItem(EXTRA_ITEM_NAME, EXTRA_ITEM_COST, ZP_TEAM_HUMAN, EXTRA_ITEM_LEVEL, EXTRA_ITEM_ONLINE, EXTRA_ITEM_LIMIT); // Hook spawn event HookEvent("weapon_fire", OnWeaponFire, EventHookMode_Post);}/** * Event callback (weapon_fire) * The player is spawning. * * @param gEventHook The event handle. * @param gEventName Name of the event. * @dontBroadcast If true, event is broadcasted to all clients, false if not. **/public Action OnWeaponFire(Event gEventHook, const char[] gEventName, bool iDontBroadcast){ // Get real player index from event key int clientIndex = GetClientOfUserId(GetEventInt(gEventHook, "userid")); // Verify that the client is exist if(IsPlayerExist(clientIndex)) { // If the client have infinity ammo if(InfinityAmmo[clientIndex]) { // Get active weapon int iWeapon = Client_GetActiveWeapon(clientIndex); // If weapon exist if(iWeapon != INVALID_ENT_REFERENCE) { // Get ammo in clip int iClip1 = Weapon_GetPrimaryClip(iWeapon); int iClip2 = Weapon_GetSecondaryClip(iWeapon); // Set new amount of ammo if(iClip1 > -1) Weapon_SetPrimaryClip(iWeapon, iClip1+1); if(iClip2 > -1) Weapon_SetSecondaryClip(iWeapon, iClip2+1); } } }}/** * Called after select an extraitem in equipment menu. * * @param clientIndex The index of the buyer. * @param extraitemIndex Index of extraitem from ZP_RegisterExtraItem() native. */public Action ZP_OnExtraBuyCommand(int clientIndex, int extraitemIndex){ // Verify that the client is connected and alive if(!IsPlayerExist(clientIndex)) { return Plugin_Handled; } // Check our item index if(extraitemIndex == iItem) { // Return ammopacks if(ZP_IsPlayerZombie(clientIndex) || ZP_IsPlayerSurvivor(clientIndex)) { return Plugin_Handled; } // Set ammo InfinityAmmo[clientIndex] = true; } // Allow buying return Plugin_Continue;}//**********************************************//* OTHER FUNCTIONS *//**********************************************/** * Called once a client is authorized and fully in-game, and * after all post-connection authorizations have been performed. * * This callback is gauranteed to occur on all clients, and always * after each OnClientPutInServer() call. * * @param clientIndex The client index. */public void OnClientPutInServer(int clientIndex){ // Reset ammo InfinityAmmo[clientIndex] = false;}/** * Called when a client became a zombie. * * @param clientIndex The client to infect. * @param infectorIndex The attacker who did the infect. * */public void ZP_OnClientInfected(int clientIndex, int infectorIndex){ // Reset ammo InfinityAmmo[clientIndex] = false;} Attached Files include.zip (69.5 KB) Wyświetl pełny artykuł Odnośnik do komentarza Udostępnij na innych stronach Więcej opcji udostępniania...
Rekomendowane odpowiedzi
Jeśli chcesz dodać odpowiedź, zaloguj się lub zarejestruj nowe konto
Jedynie zarejestrowani użytkownicy mogą komentować zawartość tej strony.
Zarejestruj nowe konto
Załóż nowe konto. To bardzo proste!
Zarejestruj sięZaloguj się
Posiadasz już konto? Zaloguj się poniżej.
Zaloguj się