Raised This Month: $ Target: $400
 0% 

Weapon Skin System [API]


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Plugin Info:     Modification:   Counter-Strike        Category:   Technical/Development       
Mistrick
Senior Member
Join Date: Aug 2012
Location: Russia
Old 12-19-2016 , 12:25   Weapon Skin System [API]
Reply With Quote #1

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(idweaponweaponid);

/**
 * Called when weapon holstered.
 * 
 * @param id                    Player index.
 * @param weapon                Weapon entity index.
 * @param weaponid                CSW_ const.
 */
forward cs_weapon_holster(idweaponweaponid);

/**
 * 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(idweaponboxweaponweaponid);

/**
 * 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(idweaponboxweaponweaponid);

/**
 * 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(idweaponweaponidtype); 
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(indexweaponidname[]);

/**
 * 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_indexname[], 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(idweaponidskin_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(PLUGINVERSIONAUTHOR);
}

public 
wss_loaded_skin(indexweaponidname[])
{
    
// 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(idg_iWeaponSkins[SKIN_FRONTSIDE][SkinWeaponid], g_iWeaponSkins[SKIN_FRONTSIDE][SkinIndex]);
    }
}

public 
cs_weapon_can_pickup(idweaponboxweaponweaponid)
{
    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
Attached Files
File Type: zip weapon_skin_system_v0.5-45_v0.6-18.zip (6.7 KB, 1034 views)
Mistrick is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:47.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode