AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Unapproved/Old Plugins (https://forums.alliedmods.net/forumdisplay.php?f=27)
-   -   Weapon Skin System [API] (https://forums.alliedmods.net/showthread.php?t=291730)

Mistrick 12-19-2016 12:25

Weapon Skin System [API]
 
1 Attachment(s)
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

EFFx 12-19-2016 13:27

Re: Weapon Skin System [API]
 
Gj

Craxor 12-19-2016 13:51

Re: Weapon Skin System [API]
 
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 ?

Mistrick 12-19-2016 14:17

Re: Weapon Skin System [API]
 
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.

klippy 12-19-2016 15:21

Re: Weapon Skin System [API]
 
Quote:

Originally Posted by Mistrick (Post 2479104)
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.

gabuch2 12-20-2016 06:50

Re: Weapon Skin System [API]
 
CS only :/

HamletEagle 01-08-2017 09:42

Re: Weapon Skin System [API]
 
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.

marcola 10-27-2023 14:41

Re: Weapon Skin System [API]
 
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 10-27-2023 14:43

Re: Weapon Skin System [API]
 
Quote:

Originally Posted by marcola (Post 2812119)
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


All times are GMT -4. The time now is 09:50.

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