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

Knife Models [XP System & Skills Support]


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-06-2017 , 06:57   Re: Knife Models
Reply With Quote #11

It's much work, I don't fell like doing it. I made a transformation of this plugin that you can use for other weapons. Here's the code:

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <formatin>

#define PLUGIN_VERSION "1.4"
#define MAX_SKINS 30

enum _:Info
{
    
Name[32],
    
VModel[128],
    
PModel[128],
    
Flag
}

enum _:Weapon
{
    
Name[16],
    
NameLower[16],
    
weapon_id[20],
    
CSW_ID
}

new 
g_eSkins[MAX_SKINS][Info]
new 
g_eWeapon[Weapon]
new 
g_eSkinsNum
new g_iSkin[33]
new 
g_szDefaultV[32]
new 
g_szDefaultP[32]
new 
g_iSayText

public plugin_init()
{    
    
register_plugin(formatin("%s Models"g_eWeapon[Name]), PLUGIN_VERSION"OciXCrom")
    
register_cvar("CRXWeaponModels"PLUGIN_VERSIONFCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
    
register_event("CurWeapon""OnSelectWeapon""be""1=1"formatin("2=%i"g_eWeapon[CSW_ID]))
    
    
register_clcmd(formatin("say /%s"g_eWeapon[NameLower]), "ShowMenu")
    
register_clcmd(formatin("say_team /%s"g_eWeapon[NameLower]), "ShowMenu")
    
    
g_iSayText get_user_msgid("SayText")
}

public 
plugin_precache()
{
    new 
szWeapon[32]
    
get_plugin(-1szWeaponcharsmax(szWeapon))
    
replace(szWeaponcharsmax(szWeapon), "crx_""")
    
replace(szWeaponcharsmax(szWeapon), "_models.amxx""")
    
    
copy(g_eWeapon[Name], charsmax(g_eWeapon[Name]), szWeapon)
    
strtolower(szWeapon)
    
copy(g_eWeapon[NameLower], charsmax(g_eWeapon[NameLower]), szWeapon)
    
formatex(g_eWeapon[weapon_id], charsmax(g_eWeapon[weapon_id]), "weapon_%s"szWeapon)
    
g_eWeapon[CSW_ID] = get_weaponid(g_eWeapon[weapon_id])
    
    
register_dictionary("WeaponModels.txt")
    
    if(!
g_eWeapon[CSW_ID])
        
set_fail_state(formatin("%L"LANG_SERVER"WM_INVALID_WEAPON"g_eWeapon[weapon_id]))
        
    
formatex(g_szDefaultVcharsmax(g_szDefaultV), "models/v_%s.mdl"g_eWeapon[NameLower])
    
formatex(g_szDefaultPcharsmax(g_szDefaultP), "models/p_%s.mdl"g_eWeapon[NameLower])
        
    
/*log_amx("Name: %s", g_eWeapon[Name])
    log_amx("NameLower: %s", g_eWeapon[NameLower])
    log_amx("weapon_id: %s", g_eWeapon[weapon_id])
    log_amx("CSW_ID: %i", g_eWeapon[CSW_ID])*/
    
    
ReadFile()
}

ReadFile()
{
    new 
szConfigsName[256], szFilename[256]
    
get_configsdir(szConfigsNamecharsmax(szConfigsName))
    
formatex(szFilenamecharsmax(szFilename), "%s/%sModels.ini"szConfigsNameg_eWeapon[Name])
    new 
iFilePointer fopen(szFilename"rt")
    
    if(
iFilePointer)
    {
        new 
szData[300], szFlag[2]
        
        while(!
feof(iFilePointer))
        {
            
fgets(iFilePointerszDatacharsmax(szData))
            
trim(szData)
            
            switch(
szData[0])
            {
                case 
EOS';': continue
                default:
                {
                    
parse(szData,     g_eSkins[g_eSkinsNum][Name], charsmax(g_eSkins[][Name]),    g_eSkins[g_eSkinsNum][VModel], charsmax(g_eSkins[][VModel]),
                    
g_eSkins[g_eSkinsNum][PModel], charsmax(g_eSkins[][PModel]), szFlagcharsmax(szFlag))
                    
                    if(!
is_blank(g_eSkins[g_eSkinsNum][VModel]))
                        
precache_model(g_eSkins[g_eSkinsNum][VModel])
                        
                    if(!
is_blank(g_eSkins[g_eSkinsNum][PModel]))
                        
precache_model(g_eSkins[g_eSkinsNum][PModel])
                        
                    
g_eSkins[g_eSkinsNum][Flag] = is_blank(szFlag) ? ADMIN_ALL read_flags(szFlag)
                        
                    
szFlag[0] = EOS
                    g_eSkinsNum
++
                }
            }
        }
        
        
fclose(iFilePointer)
    }
}

public 
ShowMenu(id)
{
    new 
szTitle[128]
    
formatex(szTitlecharsmax(szTitle), "%L"id"WM_MENU_TITLE"g_eWeapon[Name])
    
    new 
iMenu menu_create(szTitle"MenuHandler")
    
    for(new 
iFlags get_user_flags(id), ig_eSkinsNumi++)
    {
        if(
g_eSkins[i][Flag] == ADMIN_ALL || iFlags g_eSkins[i][Flag])
            
menu_additem(iMenuformatin("%s %s"g_eSkins[i][Name], g_iSkin[id] == formatin("%L"id"WM_MENU_SELECTED") : formatin("")))
        else
            
menu_additem(iMenuformatin("%s %L"g_eSkins[i][Name], id"WM_MENU_VIP_ONLY"), .paccess g_eSkins[i][Flag])
    }
    
    if(
menu_pages(iMenu) > 1)
        
menu_setprop(iMenuMPROP_TITLEformatin("%s%L"szTitleid"WM_MENU_TITLE_PAGE"))
        
    
menu_display(idiMenu)
    return 
PLUGIN_HANDLED
}

public 
MenuHandler(idiMenuiItem)
{
    if(
iItem != MENU_EXIT)
    {
        if(
g_iSkin[id] == iItem)
            
ColorChat(id"%L"id"WM_CHAT_ALREADY")
        else
        {
            
g_iSkin[id] = iItem
            
            
if(is_user_alive(id) && get_user_weapon(id) == g_eWeapon[CSW_ID])
                
OnSelectWeapon(id)
            
            
ColorChat(id"%L"id"WM_CHAT_SELECTED"g_eSkins[iItem][Name])
        }
    }
    
    
menu_destroy(iMenu)
    return 
PLUGIN_HANDLED
}

public 
client_putinserver(id)
    
g_iSkin[id] = 0

public OnSelectWeapon(id)
{
    if(
is_blank(g_eSkins[g_iSkin[id]][VModel]))
        
set_pev(idpev_viewmodel2g_szDefaultV)
    else 
set_pev(idpev_viewmodel2g_eSkins[g_iSkin[id]][VModel])
    
    if(
is_blank(g_eSkins[g_iSkin[id]][PModel]))
        
set_pev(idpev_weaponmodel2g_szDefaultP)
    else 
set_pev(idpev_weaponmodel2g_eSkins[g_iSkin[id]][PModel])
}

bool:is_blank(szString[])
    return 
szString[0] == EOS
    
ColorChat
(const id, const szInput[], any:...)
{
    new 
iPlayers[32], iCount 1
    
static szMessage[191]
    
vformat(szMessagecharsmax(szMessage), szInput3)
    
format(szMessage[0], charsmax(szMessage), "%L %s"id id LANG_PLAYER"WM_CHAT_PREFIX"g_eWeapon[Name], szMessage)
    
    
replace_all(szMessagecharsmax(szMessage), "!g""^4")
    
replace_all(szMessagecharsmax(szMessage), "!n""^1")
    
replace_all(szMessagecharsmax(szMessage), "!t""^3")
    
    if(
id)
        
iPlayers[0] = id
    
else
        
get_players(iPlayersiCount"ch")
    
    for(new 
iiCounti++)
    {
        if(
is_user_connected(iPlayers[i]))
        {
            
message_begin(MSG_ONE_UNRELIABLEg_iSayText_iPlayers[i])
            
write_byte(iPlayers[i])
            
write_string(szMessage)
            
message_end()
        }
    }

The plugin needs to be named crx_<WEAPON NAME HERE>_models.amxx. So, if you want models for ak47, you will name the plugin crx_AK47_models.amxx. The command will be /ak47 and the config file configs/AK47Models.ini. Inside it you can add models like this:

PHP Code:
"Cool AK47" "v_model.mdl" "p_model.mdl" "flag" 
Also, the lang file located in data/lang/WeaponModels.txt:

PHP Code:
[en]
WM_CHAT_PREFIX = !g[%s Models]!n
WM_CHAT_ALREADY 
This skin is already selected!
WM_CHAT_SELECTED You have selected the skin !g%s
WM_MENU_TITLE 
= \y< \rChoose your %s model \y>
WM_MENU_TITLE_PAGE = ^n\r-- \yPage:\r
WM_MENU_SELECTED 
= \y~ \rSELECTED \y~
WM_MENU_VIP_ONLY = \y~ \rVIP \y~
WM_INVALID_WEAPON Invalid weapon ^"%s^"

[mk]
WM_CHAT_PREFIX = !g[%s Models]!n
WM_CHAT_ALREADY 
Ovoj skin vekje e izbran!
WM_CHAT_SELECTED Go izbra skinot !g%s
WM_MENU_TITLE 
= \y< \rIzberi model za %\y>
WM_MENU_TITLE_PAGE = ^n\r-- \yStranica:\r
WM_MENU_SELECTED 
= \y~ \rIZBRAN \y~
WM_MENU_VIP_ONLY = \y~ \rVIP \y~
WM_INVALID_WEAPON Nevalidno oruzhje ^"%s^"

[bg]
WM_CHAT_PREFIX = !g[%s Models]!n
WM_CHAT_ALREADY 
Tozi skin veche e izbran!
WM_CHAT_SELECTED Izbra skina !g%s
WM_MENU_TITLE 
= \y< \rIzberi model za %\y>
WM_MENU_TITLE_PAGE = ^n\r-- \yStranica:\r
WM_MENU_SELECTED 
= \y~ \rIZBRAN \y~
WM_MENU_VIP_ONLY = \y~ \rVIP \y~
WM_INVALID_WEAPON Nevalidno orujie ^"%s^" 
If you want another weapon, copy the plugin + the .ini file and change its name, for example crx_M4A1_models.amxx and M4A1Models.ini.
__________________

Last edited by OciXCrom; 04-06-2017 at 06:58.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
 



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 02:36.


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