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

[CSS] Custom Weapon World/View Model Interface


Post New Thread Reply   
 
Thread Tools Display Modes
Author
SkydiveX
Member
Join Date: Jul 2012
Location: England
Plugin ID:
3644
Plugin Version:
1.1
Plugin Category:
Technical/Development
Plugin Game:
Counter-Strike: Source
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Add's support for custom view/worldmodels.
    Unapprover:
    Reason for Unapproving:
    No source code / include files uploaded, GitHub links are broken, fix it and use the Report Post button for a new review.
    Old 05-06-2013 , 09:03   [CSS] Custom Weapon World/View Model Interface
    Reply With Quote #1

    The Custom Weapon Interface

    After a day or so of coding I've created a pretty simple, cool and amazing interface for custom weapons.
    It allows you to change weapon viewmodels and worldmodels.

    Dependencies:
    SDKHooks

    If you're using a custom weapon model. Make sure that you add the files to the downloads table like this:
    Code:
    public OnMapStart()
    {
        AddFileToDownloadsTable(PATH OF FILE);
    }
    Remember to include the .vtx file extension with a few files. Many people get muddled up on this.

    dx90.vtx
    dx80.vtx
    xbox.vtx
    sw.vtx


    Natives:
    Code:
    /**
     * @brief Registers a custom Weapon and Returns it's index.
     *
     * @param        String            WeaponToReplace
     * @param        String            WeaponName
     * @return        Integer            WeaponID
     */
    native WX_RegisterWeapon(const String:replace[], const String:name[]);
    
    /**
     * @brief    Sets the weapons View/World Model.
     *
     * @param        Integer            WeaponID
     * @param        String            Path
     * @noreturn
     */
    native WX_SetWeaponViewModel(WeaponID, const String:path[]);
    native WX_SetWeaponWorldModel(WeaponID, const String:path[]);
    
    /**
     * @brief    Returns Model Index.
     *
     * @param         Integer        WeaponID
     * @return        Integer        ModelIndex
     */
    native WX_GetWeaponViewModel(WeaponID);
    native WX_GetWeaponWorldModel(WeaponID);
    
    /**
     * @brief Gets Weapon Name by its ID.
     *
     * @param         Integer       The Ability
     * @param        Integer        WeaponID
     * @return        String        WeaponName
     */
    native WX_GetWeaponName(Weapon, String:buffer[]);
    
    /**
     * @brief Returns how many registered weapons there are.
     *
     * @return Number of registered Weapons
     */
    native WX_RegisteredWeapons();
    
    /**
     * @brief Sets the active state for ALL PLAYERS
     * @param        Integer        WeaponID
     * @param        Bool        Active
     * @noreturn
     */
    native WX_SetDefaultActiveState(WeaponID, bool:Active);
    
    /**
     * @brief Checks if a weapon is active for the Client.
     *
     * @param         Client        A Player
     * @param        Integer        WeaponID
     * @return        Bool        Active
     */
    native WX_IsActive(Client, WeaponID);
    
    /**
     * @brief Set if a weapon is active
     *
     * @param         Client        A Player
     * @param        Integer        WeaponID
     * @param        Bool        Active
     * @noreturn
     */
    native WX_SetActive(Client, WeaponID, bool:Active);
    Forwards:

    Code:
    /**
     * @brief When a custom weapon has been given to the player
     *
     * @param        Client        A Player
     * @param        Integer        WeaponID
     * @noreturn
     */
    forward WXF_OnWeaponGiven(Client, WeaponID);
    
    /**
     * @brief When a custom weapon has been removed from the player
     *
     * @param        Client        A Player
     * @param        Integer        WeaponID
     * @noreturn
     */
    forward WXF_OnWeaponRemoved(Client, WeaponID);
    Example Usage:
    Code:
    #pragma semicolon 1
    
    #include <sourcemod>
    #include <cstrike>
    #include <sdktools>
    #include <WeaponAPI>
    
    public Plugin:myinfo=
    {
        name="Weapon Interface Example",
        author="Skydive",
        description="Changes Many Weapons!",
        version="1.0",
        url=""
    };
    
    new WeaponUMP;
    
    public OnPluginStart()
    {
        WeaponUMP = WX_RegisterWeapon("weapon_ump45","UMP-->P90 And Burn");
        WX_SetWeaponViewModel(WeaponUMP,"models/Weapons/v_smg_p90.mdl");
        WX_SetWeaponWorldModel(WeaponUMP,"models/Weapons/w_smg_p90.mdl");
        WX_SetDefaultActiveState(WeaponUMP,true);
        WX_SetDefaultRenderMode(WeaponUMP, RENDER_TRANSCOLOR);
        WX_SetDefaultRenderColor(WeaponUMP,0,255,0,255);
    
        HookEvent("player_hurt",Event_PlayerHurt);
        HookEvent("player_spawn",Event_PlayerSpawn);
    
        //Create Global Forwards
        StartWeaponForwards();
    }
    
    public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
    {
        new Client = GetClientOfUserId(GetEventInt(event, "userid"));
        if(GetClientTeam(Client) == CS_TEAM_CT)
        {
             //Enable UMP P90 for Client
             WX_SetActive(Client,WeaponUMP,true);
        }
        else if(GetClientTeam(Client) == CS_TEAM_T)
        {
            //Disable UMP P90 for Client
             WX_SetActive(Client,WeaponUMP,false);
        }
    }
    
    public Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
    {
        new Victim = GetClientOfUserId(GetEventInt(event, "userid"));
        new Attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
        
        new WeaponIndex = GetEntPropEnt(Attacker, Prop_Send, "m_hActiveWeapon");
        
        if(Attacker > 0 && IsPlayerAlive(Attacker))
        {
            if(WX_WeaponID(WeaponIndex) == WeaponUMP)
            {
                IgniteEntity(Victim,2.0);
            }
        }
    }
    The WeaponInterface Plugin in the Source is Necessary for this to function.
    Compile it and add it in your "/plugins" folder too.


    Link To Download:

    Use an SVN client to download them.

    Special Thanks to blodia who posted the Weapon View Model code for me to alter.


    Please leave appropriate feedback and suggestions, I've released this early. It's lacking many features.

    This plugin is still in development. Will be updated periodically. Keep A Look Out!

    CHANGELOG
    Spoiler


    Direct Link to GitHub:
    https://github.com/Skydive/WeaponAPI/tree/master/Version/
    __________________

    _____________________________________________ _______________
    Pastafarian and proud!

    Last edited by SkydiveX; 05-19-2013 at 10:59.
    SkydiveX is offline
    HvG Community
    AlliedModders Donor
    Join Date: Sep 2012
    Old 05-11-2013 , 17:29   Re: [CSS] Custom Weapon World/View Model Interface
    Reply With Quote #2

    nice plugin
    HvG Community is offline
    ilga80
    Senior Member
    Join Date: Nov 2012
    Old 05-12-2013 , 06:56   Re: [CSS] Custom Weapon World/View Model Interface
    Reply With Quote #3

    And world models don't work.
    also with sv_pure -1
    ilga80 is offline
    SkydiveX
    Member
    Join Date: Jul 2012
    Location: England
    Old 05-17-2013 , 11:41   Re: [CSS] Custom Weapon World/View Model Interface
    Reply With Quote #4

    Quote:
    Originally Posted by ilga80 View Post
    And world models don't work.
    also with sv_pure -1
    They don't? Hmm. I'll work on a fix. Currently busy at the moment. Exams and such.
    __________________

    _____________________________________________ _______________
    Pastafarian and proud!
    SkydiveX is offline
    Haltan
    New Member
    Join Date: May 2013
    Old 05-18-2013 , 18:31   Re: [CSS] Custom Weapon World/View Model Interface
    Reply With Quote #5

    Hi,
    This is a nice plugin , it work great with viewmodel (didn't tried for worldmodel) even if it's flooding this in my logs:
    Quote:
    L 05/19/2013 - 00:00:50: [SM] Native "GetEntPropEnt" reported: Entity 1 (1) is invalid
    L 05/19/2013 - 00:00:50: [SM] Displaying call stack trace for plugin "WeaponInterface.smx":
    L 05/19/2013 - 00:00:50: [SM] [0] Line 383, WeaponInterface.sp::ChangeWorldModel()
    L 05/19/2013 - 00:03:27: [SM] Native "GetEntPropEnt" reported: Entity 1 (1) is invalid
    L 05/19/2013 - 00:03:27: [SM] Displaying call stack trace for plugin "WeaponInterface.smx":
    L 05/19/2013 - 00:03:27: [SM] [0] Line 372, WeaponInterface.sp::WeaponHook()
    Whatever,i was wondering if you could make a version where we can choose which steamID have the model or not.
    Thanks.
    Haltan is offline
    SkydiveX
    Member
    Join Date: Jul 2012
    Location: England
    Old 05-19-2013 , 08:02   Re: [CSS] Custom Weapon World/View Model Interface
    Reply With Quote #6

    Quote:
    Originally Posted by Haltan View Post
    Hi,
    This is a nice plugin , it work great with viewmodel (didn't tried for worldmodel) even if it's flooding this in my logs:


    Whatever,i was wondering if you could make a version where we can choose which steamID have the model or not.
    Thanks.
    Just released a new update.
    use PX_SetActive(Client, WeaponID);
    Look at the example code packaged in the GitHub repository. It conatains how to do it by teams.
    I'm pretty sure you know how to adapt the code there.
    __________________

    _____________________________________________ _______________
    Pastafarian and proud!
    SkydiveX is offline
    Haltan
    New Member
    Join Date: May 2013
    Old 05-19-2013 , 08:15   Re: [CSS] Custom Weapon World/View Model Interface
    Reply With Quote #7

    Thanks you very much,
    I'll try to adapt the code !

    EDIT : your link don't work , this one work : https://github.com/Skydive/WeaponAPI...r/Version/v1.1

    Last edited by Haltan; 05-19-2013 at 08:16.
    Haltan is offline
    SkydiveX
    Member
    Join Date: Jul 2012
    Location: England
    Old 05-19-2013 , 08:49   Re: [CSS] Custom Weapon World/View Model Interface
    Reply With Quote #8

    Quote:
    Originally Posted by Haltan View Post
    EDIT : your link don't work , this one work : https://github.com/Skydive/WeaponAPI...r/Version/v1.1
    Oooh. Thanks for pointing that out! Updated the information on it. Use an SVN client to download from that link.
    __________________

    _____________________________________________ _______________
    Pastafarian and proud!
    SkydiveX is offline
    ilga80
    Senior Member
    Join Date: Nov 2012
    Old 05-19-2013 , 09:20   Re: [CSS] Custom Weapon World/View Model Interface
    Reply With Quote #9

    Quote:
    Originally Posted by SkydiveX View Post
    Use an SVN client to download from that link.
    Wherefore?!
    use this and enjoy https://github.com/Skydive/WeaponAPI/archive/master.zip
    ilga80 is offline
    blodia
    Veteran Member
    Join Date: Sep 2009
    Location: UK
    Old 05-19-2013 , 10:45   Re: [CSS] Custom Weapon World/View Model Interface
    Reply With Quote #10

    lol don't i get any credit since a lot of the viewmodel code is just copy and pasted from the snippet i put up in the tutorial section.

    Last edited by blodia; 05-19-2013 at 10:46.
    blodia 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 05:33.


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