Solved unlimited clip

Installation Problems Support
Post Reply
czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 598
Joined: 7 years ago
Contact:

unlimited clip

#1

Post by czirimbolo » 5 years ago

hey, I got a problem with unlimited plugin for vips. For some reason, this unlimited clip does not work for all weapons. Errors:

L 10/25/2018 - 20:22:02: [AMXX] Displaying debug trace (plugin "ze_vip_unlimited_clip.amxx", version "1.0")
L 10/25/2018 - 20:22:02: [AMXX] Run time error 10: native error (native "set_pdata_int")
L 10/25/2018 - 20:22:02: [AMXX] [0] ze_vip_unlimited_clip.sma::fm_set_weapon_ammo (line 102)
L 10/25/2018 - 20:22:02: [AMXX] [1] ze_vip_unlimited_clip.sma::message_cur_weapon (line 86)
L 10/25/2018 - 20:22:02: [FAKEMETA] Invalid entity 0

Code: Select all

#include <zombie_escape>
 
new const g_item_name[] = {"Unlimited Clip \r(One Round)"}
const g_item_cost = 10
 
// CS Offsets
#if cellbits == 32
const OFFSET_CLIPAMMO = 51
#else
const OFFSET_CLIPAMMO = 65
#endif
const OFFSET_LINUX_WEAPONS = 4
 
// Max Clip for weapons
new const MAXCLIP[] = { -1, 13, -1, 10, 1, 7, -1, 30, 30, 1, 30, 20, 25, 30, 35, 25, 12, 20,
            10, 30, 100, 8, 30, 30, 20, 2, 7, 30, 30, -1, 50 }
 
new g_itemid_infammo, g_has_unlimited_clip[33]
 
public plugin_init()
{
    register_plugin("[ZE] Extra: Unlimited Clip", "1.0", "MeRcyLeZZ")
   
    g_itemid_infammo = ze_register_item(g_item_name, g_item_cost, 0)
    ze_set_item_vip(g_itemid_infammo, "VIP_A")
 
    register_message(get_user_msgid("CurWeapon"), "message_cur_weapon")
}
 
public ze_select_item_pre(id, itemid)
{
    // Return Available and we will block it in Post, So it dosen't affect other plugins
    if (itemid != g_itemid_infammo)
        return ZE_ITEM_AVAILABLE
   
    // Available for Humans only, So don't show it for zombies
    if (ze_is_user_zombie(id))
        return ZE_ITEM_DONT_SHOW
   
    return ZE_ITEM_AVAILABLE
}
 
// Player buys our upgrade, set the unlimited ammo flag
public ze_select_item_post(player, itemid)
{
    if (itemid != g_itemid_infammo)
        return
   
    g_has_unlimited_clip[player] = true
}
 
// Reset flags for all players on newround
public ze_user_humanized(id)
{
    g_has_unlimited_clip[id] = false;
}
 
// Unlimited clip code
public message_cur_weapon(msg_id, msg_dest, msg_entity)
{
    // Player doesn't have the unlimited clip upgrade
    if (!g_has_unlimited_clip[msg_entity])
        return;
   
    // Player not alive or not an active weapon
    if (!is_user_alive(msg_entity) || get_msg_arg_int(1) != 1)
        return;
   
    static weapon, clip
    weapon = get_msg_arg_int(2) // get weapon ID
    clip = get_msg_arg_int(3) // get weapon clip
   
    // Unlimited Clip Ammo
    if (MAXCLIP[weapon] > 2) // skip grenades
    {
        set_msg_arg_int(3, get_msg_argtype(3), MAXCLIP[weapon]) // HUD should show full clip all the time
       
        if (clip < 2) // refill when clip is nearly empty
        {
            // Get the weapon entity
            static wname[32], weapon_ent
            get_weaponname(weapon, wname, sizeof wname - 1)
            weapon_ent = fm_find_ent_by_owner(-1, wname, msg_entity)
           
            // Set max clip on weapon
            fm_set_weapon_ammo(weapon_ent, MAXCLIP[weapon])
        }
    }
}
 
// Find entity by its owner (from fakemeta_util)
stock fm_find_ent_by_owner(entity, const classname[], owner)
{
    while ((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", classname)) && pev(entity, pev_owner) != owner) {}
   
    return entity;
}
 
// Set Weapon Clip Ammo
stock fm_set_weapon_ammo(entity, amount)
{
    set_pdata_int(entity, OFFSET_CLIPAMMO, amount, OFFSET_LINUX_WEAPONS);
}
Image

User avatar
Night Fury
Mod Developer
Mod Developer
Posts: 677
Joined: 7 years ago
Contact:

#2

Post by Night Fury » 5 years ago

Code: Select all

#include <zombie_escape>
 
new const g_item_name[] = {"Unlimited Clip \r(One Round)"}
const g_item_cost = 10
 
// CS Offsets
#if cellbits == 32
const OFFSET_CLIPAMMO = 51
#else
const OFFSET_CLIPAMMO = 65
#endif
const OFFSET_LINUX_WEAPONS = 4
 
// Max Clip for weapons
new const MAXCLIP[] = { -1, 13, -1, 10, 1, 7, -1, 30, 30, 1, 30, 20, 25, 30, 35, 25, 12, 20,
            10, 30, 100, 8, 30, 30, 20, 2, 7, 30, 30, -1, 50 }
 
new g_itemid_infammo, g_has_unlimited_clip[33]
 
public plugin_init()
{
    register_plugin("[ZE] Extra: Unlimited Clip", "1.0", "MeRcyLeZZ")
   
    g_itemid_infammo = ze_register_item(g_item_name, g_item_cost, 0)
    ze_set_item_vip(g_itemid_infammo, "VIP_A")
 
    register_message(get_user_msgid("CurWeapon"), "message_cur_weapon")
}
 
public ze_select_item_pre(id, itemid)
{
    // Return Available and we will block it in Post, So it dosen't affect other plugins
    if (itemid != g_itemid_infammo)
        return ZE_ITEM_AVAILABLE
   
    // Available for Humans only, So don't show it for zombies
    if (ze_is_user_zombie(id))
        return ZE_ITEM_DONT_SHOW
   
    return ZE_ITEM_AVAILABLE
}
 
// Player buys our upgrade, set the unlimited ammo flag
public ze_select_item_post(player, itemid)
{
    if (itemid != g_itemid_infammo)
        return
   
    g_has_unlimited_clip[player] = true
}
 
// Reset flags for all players on newround
public ze_user_humanized(id)
{
    g_has_unlimited_clip[id] = false;
}
 
// Unlimited clip code
public message_cur_weapon(msg_id, msg_dest, msg_entity)
{
    if (!pev_valid(msg_entity))
        return
    // Player not alive or not an active weapon
    if (!is_user_alive(msg_entity) || get_msg_arg_int(1) != 1)
        return;

    // Player doesn't have the unlimited clip upgrade
    if (!g_has_unlimited_clip[msg_entity])
        return;
   
    static weapon, clip
    weapon = get_msg_arg_int(2) // get weapon ID
    clip = get_msg_arg_int(3) // get weapon clip
   
    // Unlimited Clip Ammo
    if (MAXCLIP[weapon] > 2) // skip grenades
    {
        set_msg_arg_int(3, get_msg_argtype(3), MAXCLIP[weapon]) // HUD should show full clip all the time
       
        if (clip < 2) // refill when clip is nearly empty
        {
            // Get the weapon entity
            static wname[32], weapon_ent
            get_weaponname(weapon, wname, sizeof wname - 1)
            weapon_ent = fm_find_ent_by_owner(-1, wname, msg_entity)
           
            // Set max clip on weapon
            fm_set_weapon_ammo(weapon_ent, MAXCLIP[weapon])
        }
    }
}
 
// Find entity by its owner (from fakemeta_util)
stock fm_find_ent_by_owner(entity, const classname[], owner)
{
    while ((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", classname)) && pev(entity, pev_owner) != owner) {}
   
    return entity;
}
 
// Set Weapon Clip Ammo
stock fm_set_weapon_ammo(entity, amount)
{
    set_pdata_int(entity, OFFSET_CLIPAMMO, amount, OFFSET_LINUX_WEAPONS);
}
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 598
Joined: 7 years ago
Contact:

#3

Post by czirimbolo » 5 years ago

what did you change? its the same code?

not working and the same errors

L 10/26/2018 - 17:35:17: [AMXX] Displaying debug trace (plugin "ze_vip_unlimited_clip.amxx", version "1.0")
L 10/26/2018 - 17:35:17: [AMXX] Run time error 10: native error (native "set_pdata_int")
L 10/26/2018 - 17:35:17: [AMXX] [0] ze_vip_unlimited_clip.sma::fm_set_weapon_ammo (line 102)
L 10/26/2018 - 17:35:17: [AMXX] [1] ze_vip_unlimited_clip.sma::message_cur_weapon (line 86)
Image

User avatar
Night Fury
Mod Developer
Mod Developer
Posts: 677
Joined: 7 years ago
Contact:

#4

Post by Night Fury » 5 years ago

czirimbolo wrote: 5 years ago what did you change? its the same code?

not working and the same errors

L 10/26/2018 - 17:35:17: [AMXX] Displaying debug trace (plugin "ze_vip_unlimited_clip.amxx", version "1.0")
L 10/26/2018 - 17:35:17: [AMXX] Run time error 10: native error (native "set_pdata_int")
L 10/26/2018 - 17:35:17: [AMXX] [0] ze_vip_unlimited_clip.sma::fm_set_weapon_ammo (line 102)
L 10/26/2018 - 17:35:17: [AMXX] [1] ze_vip_unlimited_clip.sma::message_cur_weapon (line 86)
viewtopic.php?p=9021#p9021
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 598
Joined: 7 years ago
Contact:

#5

Post by czirimbolo » 5 years ago

L 10/27/2018 - 10:52:52: [FAKEMETA] Invalid entity 0
L 10/27/2018 - 10:52:52: [AMXX] Displaying debug trace (plugin "ze_vip_unlimited_clip.amxx", version "1.0")
L 10/27/2018 - 10:52:52: [AMXX] Run time error 10: native error (native "set_pdata_int")
L 10/27/2018 - 10:52:52: [AMXX] [0] ze_vip_unlimited_clip.sma::fm_set_weapon_ammo (line 104)
L 10/27/2018 - 10:52:52: [AMXX] [1] ze_vip_unlimited_clip.sma::message_cur_weapon (line 88)
Image

User avatar
Night Fury
Mod Developer
Mod Developer
Posts: 677
Joined: 7 years ago
Contact:

#6

Post by Night Fury » 4 years ago

Still want it?
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 598
Joined: 7 years ago
Contact:

#7

Post by czirimbolo » 4 years ago

its fixed
Image

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 1 guest