qubka
Zombie Plague Разработчик
- Сообщения
- 245
- Реакции
- 245
Как создать экстра предмет
Все экстра предметы - отдельные плагины, метод, как ZP 4.3 в CS 1.6
Для дополнительной информации смотрите include/zombieplague/extraitems.inc
У вас всё будет работать только,если вы будете следовать ниже приведённой инструкцие!
Как создать свой экстра предмет:
Создайте плагин экстра предмета
PHP:#include <sourcemod> #include <sdktools> #include <zombieplague> #pragma newdecls required /** * Record plugin info. **/ public Plugin myinfo = { name = "[ZP] ExtraItem: Armor", author = "qubka (Nikita Ushakov)", description = "Addon of extra items", version = "2.0", url = "https://forums.alliedmods.net/showthread.php?t=290657" } /** * @section Information about extra items. **/ #define EXTRA_ITEM_NAME "anti infection armor" // Only will be taken from translation file #define EXTRA_ITEM_INFO "" // Only will be taken from translation file #define EXTRA_ITEM_COST 5 #define EXTRA_ITEM_LEVEL 2 #define EXTRA_ITEM_ONLINE 1 #define EXTRA_ITEM_LIMIT 0 #define EXTRA_ITEM_GROUP "" /** * @endsection **/ // Initialize variable bool bArmored[MAXPLAYERS+1]; // Variables for the key sound block int gSound; // Item index int gItem; #pragma unused gItem /** * Called after a library is added that the current plugin references optionally. * A library is either a plugin name or extension name, as exposed via its include file. **/ public void OnLibraryAdded(const char[] sLibrary) { // Validate library if(!strcmp(sLibrary, "zombieplague", false)) { // Initialize extra item gItem = ZP_RegisterExtraItem(EXTRA_ITEM_NAME, EXTRA_ITEM_COST, EXTRA_ITEM_LEVEL, EXTRA_ITEM_ONLINE, EXTRA_ITEM_LIMIT, EXTRA_ITEM_GROUP); } } /** * Called after a zombie core is loaded. **/ public void ZP_OnEngineExecute(/*void*/) { // Sounds gSound = ZP_GetSoundKeyID("ARMOR_BUY_SOUNDS"); } /** * Called when a client is disconnecting from the server. * * @param clientIndex The client index. **/ public void OnClientDisconnect(int clientIndex) { // Reset variable bArmored[clientIndex] = false; } /** * Called when a client became a zombie/nemesis. * * @param victimIndex The client index. * @param attackerIndex The attacker index. * @param nemesisMode Indicates that client will be a nemesis. * @param respawnMode Indicates that infection was on spawn. **/ public void ZP_OnClientInfected(int clientIndex, int attackerIndex, bool nemesisMode, bool respawnMode) { // Reset variable bArmored[clientIndex] = false; } /** * Called when a client became a human/survivor. * * @param clientIndex The client index. * @param survivorMode Indicates that client will be a survivor. * @param respawnMode Indicates that humanizing was on spawn. **/ public void ZP_OnClientHumanized(int clientIndex, bool survivorMode, bool respawnMode) { // Reset variable bArmored[clientIndex] = false; } /** * Called before show an extraitem in the equipment menu. * * @param clientIndex The client index. * @param extraitemIndex The index of extraitem from ZP_RegisterExtraItem() native. * * @return Plugin_Handled to disactivate showing and Plugin_Stop to disabled showing. Anything else * (like Plugin_Continue) to allow showing and calling the ZP_OnClientBuyExtraItem() forward. **/ public Action ZP_OnClientValidateExtraItem(int clientIndex, int extraitemIndex) { // Check the item index if(extraitemIndex == gItem) { // Validate class if(ZP_IsPlayerZombie(clientIndex) || ZP_IsPlayerSurvivor(clientIndex)) { return Plugin_Stop; } // Validate access if(GetClientArmor(clientIndex) >= 100) { return Plugin_Handled; } } // Allow showing return Plugin_Continue; } /** * Called after select an extraitem in the equipment menu. * * @param clientIndex The client index. * @param extraitemIndex The index of extraitem from ZP_RegisterExtraItem() native. **/ public void ZP_OnClientBuyExtraItem(int clientIndex, int extraitemIndex) { // Check the item index if(extraitemIndex == gItem) { // Give item SetEntProp(clientIndex, Prop_Send, "m_ArmorValue", 100, 1); // Validate no armor before if(!bArmored[clientIndex]) { // Gets the client origin static float vPosition[3]; GetClientAbsOrigin(clientIndex, vPosition); // Create an effect FakeCreateParticle(clientIndex, vPosition, _, "nimb_final", 9999.9); bArmored[clientIndex] = true; } // Emit sound ZP_EmitSoundKeyID(clientIndex, gSound, SNDCHAN_VOICE); } }
Вот и всё!Наш Экстра предмет готов.
Кучу других примеров ищите в папке ../addons/sourcemod/scripting/..
Последнее редактирование: