RSSy MYGO.pl Opublikowano Czerwiec 3, 2021 o 20:00 RSSy Udostępnij Opublikowano Czerwiec 3, 2021 o 20:00 A Theater Items API For Insurgency(2014) This API provides the function of querying the class names of gear and weapon upgrade of player equipment, and also provides the function of giving weapon the weapon upgrade. Command PHP Code: "sm_update_theater_items" // Force update the theater items name record list "listweapons" // List all weapons in the currently loaded theater "listupgrades" // List all weapon upgrades in the currently loaded theater "listexplosives" // List all explosives in the currently loaded theater "listplayergear" // List all player gear in the currently loaded theater Installation Guide Code: Put TheaterItemsAPI.smx into "sourcemod\plugins\" Put TheaterItemsAPI.inc into "sourcemod\scripting\include" Add "#include <TheaterItemsAPI>" at the top of your plugin code and check the TheaterItemsAPI.inc file when you edit your own plugin Main API Spoiler PHP Code: /** * Get theater item's index by weapon upgrade Name * * @param cWeaponUpgradeName Weapon upgrade name in theater. * @return Weapon upgrade theater item's index if found, -1 otherwise. */ int GetTheaterItemIdByWeaponUpgradeName(char[] cWeaponUpgradeName) /** * Get theater item's index by Player gear Name * * @param cPlayerGearName Player gear name in theater. * @return Player gear theater item's index if found, -1 otherwise. */ int GetTheaterItemIdByPlayerGearName(char[] cPlayerGearName) /** * Get weapon upgrade name by theater weapon upgrade item's index * * @param iItemIndex Theater weapon upgrade item's index * @param cItemName Buffer to store the item's name. * @param len Maximum length of string buffer * @return True on success, false otherwise. */ bool GetWeaponUpgradeItemName(int iItemIndex, char[] cItemName, int len) /** * Get player gear name by theater player gear item's index * * @param iItemIndex Theater player gear item's index * @param cItemName Buffer to store the item's name. * @param len Maximum length of string buffer * @return True on success, false otherwise. */ bool GetPlayerGearItemName(int iItemIndex, char[] cItemName, int len) /** * Check if client has gear by gear name. (this "has" only mean player actually equipped and wearing it, but not necessarily equipped it in the inventory.) * * @param client Client index * @param cGearName Gear name for check * @return Whether client has the gear */ bool IsClientHasGear(int client, char[] cGearName) /** * Check if client equipped gear by gear name. (this "equipped" only mean equipped in the inventory, but it's not necessarily actually equipped. player may not be wearing it) * * @param client Client index * @param cGearName Gear name for check * @return Whether client Equipped the gear */ bool IsClientEquippedGear(int client, char[] cGearName) /** * Check if weapon has upgrade by upgrade name * * @param iWeaponID Weapon index * @param cUpgradeName Weapon Upgrade name for check * @return Whether weapon has the upgrade */ bool IsWeaponHasUpgrade(int iWeaponID, char[] cUpgradeName) /** * Give weapon a upgrade by upgrade name * * @param iWeaponID Weapon index * @param iUpgradeSlotType Weapon upgrade slot type * @param cUpgradeName Weapon Upgrade name in theater * @return True on success, false otherwise. */ bool GiveUpgradeToWeaponByName(int iWeaponID, WEAPON_UPGRADE_SLOT iUpgradeSlotType, char[] cUpgradeName) /** * Give weapon a upgrade by upgrade theater item's index * * @param iWeaponID Weapon index * @param iUpgradeSlotType Weapon upgrade slot type * @param iUpgradeID Weapon Upgrade theater item's index * @return True on success, false otherwise. */ bool GiveUpgradeToWeaponByTheaterId(int iWeaponID, WEAPON_UPGRADE_SLOT iUpgradeSlotType, int iUpgradeID) Example Code Spoiler PHP Code: #include <TheaterItemsAPI> ... void CheckClientGear(int client) { if (IsClientHasGear(client, "nightvision")) { // Do something about client wearing a night vision // ... } return; } void GiveClientANewWeaponWithSomeUpgrades(int client) { int iWeaponID = GivePlayerItem(client, "weapon_mk18"); if (iWeaponID > MaxClients && IsValidEntity(iWeaponID)) { SetEntProp(iWeaponID, Prop_Send, "m_upgradeSlots", GetTheaterItemIdByWeaponUpgradeName("optic_eotech"), 4, view_as<int>(WEAPON_UPGRADE_OPTICS)); SetEntProp(iWeaponID, Prop_Send, "m_upgradeSlots", GetTheaterItemIdByWeaponUpgradeName("siderail_flashlight_rail"), 4, view_as<int>(WEAPON_UPGRADE_SIDERAIL)); } return; } void GiveClientsWeaponAnOpticalSight(int client) { int iWeaponID = GetEntPropEnt(client, Prop_Data, "m_hActiveWeapon"); GiveUpgradeToWeaponByName(iWeaponID, WEAPON_UPGRADE_OPTICS, "optic_eotech"); return; } 中文服务器使用此插件请务必署名加鸣谢。 没有x社区提供的服务器的支持不会有此插件的诞生。 LinkGithub Attached Files TheaterItemsAPI.smx (11.1 KB) Get Plugin or Get Source (TheaterItemsAPI.sp - 9.9 KB) TheaterItemsAPI.inc (10.2 KB) Wyświetl pełny artykuł Odnośnik do komentarza Udostępnij na innych stronach Więcej opcji udostępniania...
Rekomendowane odpowiedzi