Raised This Month: $32 Target: $400
 8% 

[ZPSp 4.2] Adding CSO/Custom weapons in primary/secondary


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Perfect Scrash
Senior Member
Join Date: Aug 2013
Location: Brazil
Old 07-12-2018 , 20:03   [ZPSp 4.2] Adding CSO/Custom weapons in primary/secondary
Reply With Quote #1

First at all: You need a Zombie Plague Special 4.2 or Higher Plugin and Include for making this, and a extra item thats not for ZP 5.0 (Because of natives incompatibles).

Now you need to make this steps for making this with sucess.

First Step: Change the anothers zombie plague include to zombie_plague_special.
Example:
Find:
Code:
#include <zombieplague>
And change to:
Code:
#include <zombie_plague_special>
Second Step: Changing a Extra Item native to Register Weapon
Find the native zp_register_extra_item and change to zp_register_weapon
Example:
Find:
Code:
g_itemid = zp_register_extra_item("Thanathos-7", 60, ZP_TEAM_HUMAN)
And change to:
Code:
g_itemid = zp_register_weapon("Thanathos-7", WPN_PRIMARY)
Note: If your custom weapon is a pistol use WPN_SECONDARY in the native zp_register_weapon:

Example with Elemental - Find:
Code:
g_itemid = zp_register_extra_item("Elemental \r[Fire & Ice]", 40, ZP_TEAM_HUMAN)
And Change to:
Code:
g_itemid = zp_register_weapon("Elemental \r[Fire & Ice]", WPN_SECONDARY)
Third Step: Converting the extra item selected forward to weapon selected.Find the forward zp_extra_item_selected and change to zp_weapon_selected_post and convert it.
Example - Find:
Code:
public zp_extra_item_selected(id, itemid)
{
    if(itemid != g_itemid)
        return
        
    get_thanatos(id)
}
And change to:
Code:
public zp_weapon_selected_post(id, wpn_type, weaponid)
{
    if(wpn_type != WPN_PRIMARY) // Prevent bugs with a another weapons
        return;

    if(weaponid != g_itemid) // Prevent bugs with a another weapons
        return
        
    get_thanatos(id)
}
If your weapon is a pistol use the elemental with example:
Find:
Code:
public zp_extra_item_selected(player, itemid)
{
    if (itemid == g_itemid) 
    {
        drop_prim(player)
        g_elemental[player] = true
        client_printcolor(player,"/g[ZP]/y You Bought the /tElemental /g[Fire & Ice]")
        give_item(player, "weapon_elite")
    }
}
And Change to:
Code:
public zp_weapon_selected_post(player, wpn_type, weaponid)
{
    if(wpn_type != WPN_SECONDARY) // Prevent bugs with a another weapons
        return;

    if (weaponid == g_itemid) 
    {
        drop_prim(player)
        g_elemental[player] = true
        client_printcolor(player,"/g[ZP]/y You Bought the /tElemental /g[Fire & Ice]")
        give_item(player, "weapon_elite")
    }
}
Making for admins/vips (Optional):
Put this in the code:
Code:
public zp_weapon_selected_pre(id, wpn_type, weaponid)
{
    if(wpn_type != WPN_PRIMARY)// Use WPN_SECONDARY if your gun is a pistol
        return PLUGIN_CONTINUE

    if(weaponid != g_itemid)
        return PLUGIN_CONTINUE

    zp_weapon_menu_textadd("\y[*VIP*]")

    if(!(get_user_flags(id) & ADMIN_RESERVATION))
        return ZP_PLUGIN_HANDLED;

    return PLUGIN_CONTINUE
}
Note: Use WPN_SECONDARY if your gun is a pistol.

After making this steps, compile and Test:
View full code example:
Thanathos 7:
Before converting:
Spoiler


After:
Spoiler


Elemental
Before:
Spoiler


After:
Spoiler
__________________
Perfect Scrash is offline
Send a message via Skype™ to Perfect Scrash
 



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