Weapon Skin System
Version: Models API v0.6-18, Skin System v0.5-45
Author: Mistrick
Description: A set of plugins for work with weapon models.
API:
weapon_models_api.inc
PHP Code:
enum
{
WEAPON_CAN_PICKUP,
WEAPON_BLOCK_PICKUP
};
enum
{
WEAPON_MODEL_IGNORED,
WEAPON_MODEL_CHANGED
};
enum
{
ADD_BY_WEAPONBOX,
ADD_BY_ARMORY_ENTITY,
ADD_BY_BUYZONE
};
/**
* Called when weapon deployed.
*
* @param id Player index.
* @param weapon Weapon entity index.
* @param weaponid CSW_ const.
*/
forward cs_weapon_deploy(id, weapon, weaponid);
/**
* Called when weapon holstered.
*
* @param id Player index.
* @param weapon Weapon entity index.
* @param weaponid CSW_ const.
*/
forward cs_weapon_holster(id, weapon, weaponid);
/**
* Called when weapon droped.
* Forward should return WEAPON_BLOCK_PICKUP for block pickup
*
* @param id Player index.
* @param weaponbox Weaponbox entity index.
* @param weapon Weapon entity index.
* @param weaponid CSW_ const.
*/
forward cs_weapon_can_pickup(id, weaponbox, weapon, weaponid);
/**
* Called when weapon droped.
* Forward should return WEAPON_MODEL_CHANGED if weaponbox model changed
*
* @param id Player index.
* @param weaponbox Weaponbox entity index.
* @param weapon Weapon entity index.
* @param weaponid CSW_ const.
*/
forward cs_weapon_drop(id, weaponbox, weapon, weaponid);
/**
* Called when weapon added to player.
*
* @param id Player index.
* @param weapon Weapon entity index.
* @param weaponid CSW_ const.
* @param type Add type.
*/
forward cs_weapon_add_to_player(id, weapon, weaponid, type);
weapon_skin_system.inc
PHP Code:
/**
* Called when load skins from file.
*
* @param index Skin index
* @param weaponid Skin CSW_ const
* @param name Skin name
*/
forward wss_loaded_skin(index, weaponid, name[]);
/**
* Get weapon skin.
*
* @param weapon Weapon enity index
*/
native wss_get_weapon_skin_index(weapon);
/**
* Get skin name by index.
*
* @param skin_index Skin index
* @param name String for name
* @param len Max string len
*/
native wss_get_skin_name(skin_index, name[], len);
/**
* Change player weapon skin.
* If weaponid is NULL then reset all player skins.
*
* wss_set_user_skin(id, 0) - reset all player's skins
* wss_set_user_skin(id, CSW_AK47) - reset only ak47 skin
*
* @param id Player index
* @param weaponid Weapon CSW_ const
* @param skin_index Skin index from wss_loaded_skin()
*/
native wss_set_user_skin(id, weaponid, skin_index = 0);
Example:
PHP Code:
#include <amxmodx>
#include <weapon_models_api>
#include <weapon_skin_system>
#define PLUGIN "Weapon Skins: Addon"
#define VERSION "0.1"
#define AUTHOR "Mistrick"
#pragma semicolon 1
enum SkinInfo
{
SkinIndex,
SkinWeaponid
};
enum Skins
{
SKIN_FRONTSIDE
};
new g_iWeaponSkins[Skins][SkinInfo];
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
}
public wss_loaded_skin(index, weaponid, name[])
{
// Skin name from weapon_skins.ini
if(equal(name, "AK-47 Frontside"))
{
g_iWeaponSkins[SKIN_FRONTSIDE][SkinIndex] = index;
g_iWeaponSkins[SKIN_FRONTSIDE][SkinWeaponid] = weaponid;
}
}
public client_putinserver(id)
{
if(get_user_flags(id) & ADMIN_LEVEL_H)
{
wss_set_user_skin(id, g_iWeaponSkins[SKIN_FRONTSIDE][SkinWeaponid], g_iWeaponSkins[SKIN_FRONTSIDE][SkinIndex]);
}
}
public cs_weapon_can_pickup(id, weaponbox, weapon, weaponid)
{
new skin = wss_get_weapon_skin_index(weapon);
if(!skin)
{
return WEAPON_CAN_PICKUP;
}
if(skin == g_iWeaponSkins[SKIN_FRONTSIDE][SkinIndex] && ~get_user_flags(id) & ADMIN_LEVEL_H)
{
return WEAPON_BLOCK_PICKUP;
}
return WEAPON_CAN_PICKUP;
}
Changelog: GitHub