Raised This Month: $51 Target: $400
 12% 

Weapon Skin System [API]


Post New Thread Reply   
 
Thread Tools Display Modes
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, 1003 views)
Mistrick is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 12-19-2016 , 13:27   Re: Weapon Skin System [API]
Reply With Quote #2

Gj
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 12-19-2016 , 13:51   Re: Weapon Skin System [API]
Reply With Quote #3

Mistik, i check a little the code and it is amazing, i have just some suggestions:

- > Put both of them in just one sma and one Inc file if you can, would be more nice.
- > Not only models, can you add an option for changing also the shooting sprite flame ?
__________________
Project: Among Us
Craxor is offline
Send a message via ICQ to Craxor
Mistrick
Senior Member
Join Date: Aug 2012
Location: Russia
Old 12-19-2016 , 14:17   Re: Weapon Skin System [API]
Reply With Quote #4

Craxor, Different functions - different plugins. I am not maniac to put all in one plugin.
I don't know anything about the shooting sprite flame. With API you can add any function for any skin model.
Mistrick is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 12-19-2016 , 15:21   Re: Weapon Skin System [API]
Reply With Quote #5

Quote:
Originally Posted by Mistrick View Post
I don't know anything about the shooting sprite flame. With API you can add any function for any skin model.
I think he meant muzzleflash. I don't think it's changeable.
klippy is offline
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 12-20-2016 , 06:50   Re: Weapon Skin System [API]
Reply With Quote #6

CS only :/
__________________
gabuch2 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-08-2017 , 09:42   Re: Weapon Skin System [API]
Reply With Quote #7

I don't understand how is this supposed to be usefull.
The weapon_model_api is totally useless, it's hooking ham forwards and firing your custom ones from them. Why should someone use your api and not simply hook the original forward? It's more direct and better way. If you want to create an API, it should actually do something usefull, that is harder without it, not to re-name some functions.

The weapon_skin_system is not that bad, but it does not do much, just set some models. My point is: that's not something hard, there are a lot of tutorials and threads about that. You don't gain anyt advantage from using this API.

Since the section needs to be cleaned, I'll unapprove this for now. If you plan to improve this and add more functionalities PM me or any other active approver.
__________________

Last edited by HamletEagle; 01-08-2017 at 09:43.
HamletEagle is offline
marcola
Junior Member
Join Date: Oct 2023
Old 10-27-2023 , 14:41   Re: Weapon Skin System [API]
Reply With Quote #8

I have 2 suggestions:

- Create first menu with weapon category based on weapon name("weapon_ak47") like:

Skin Menu

1. Knife
2. Awp
3. AK
...

9 Next
0 Exit

then next menu will be filtered and you will have the index of the skin in menu data:
menu_additem(menu, skin_info[SkinName], **index from loop**, 0);

- Save skin selection in nVault with steam id as key because its boring select skins every changelevel/server restart
marcola is offline
marcola
Junior Member
Join Date: Oct 2023
Old 10-27-2023 , 14:43   Re: Weapon Skin System [API]
Reply With Quote #9

Quote:
Originally Posted by marcola View Post
I have 2 suggestions:

- Create first menu with weapon category based on weapon name("weapon_ak47") like:

Skin Menu

1. Knife
2. Awp
3. AK
...

9 Next
0 Exit

then next menu will be filtered and you will have the index of the skin in menu data:
menu_additem(menu, skin_info[SkinName], **index from loop**, 0);

- Save skin selection in nVault with steam id as key because its boring select skins every changelevel/server restart
I'd like to do these features but I suck in pawn language lol
marcola is offline
Reply



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 23:44.


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