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

Item deploy bug


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ace67
Senior Member
Join Date: Sep 2020
Location: France
Old 10-26-2023 , 14:09   Item deploy bug
Reply With Quote #1

I have a problem the weapon remains bugged and moves to the left and also, it acts as if it was a knife. If anyone can fix the "Super M4A1" weapon bug

If im right is the issue

PHP Code:
public ham_ItemDeploy_Post_M4(weapon_ent)
{
    static 
owner;
    
owner get_pdata_cbase(weapon_ent414);

    if ( 
is_user_alive(owner) && g_HasSuperM4A1[owner] )
    {
        
set_pev(ownerpev_viewmodel2g_ModelSuperM4A1);
    }





PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <hamsandwich>
#include <fakemeta>
 
#define VERSION "5.4"
#define IsPlayer(%1) ( 1 <= %1 <= g_iMaxPlayers )
#define MAX_PLAYERS 32
#define Ham_Player_ResetMaxSpeed Ham_Item_PreFrame

#define FURIEN_VIP ADMIN_RESERVATION
 
new g_iMaxPlayers
new g_iRoundsCount
 
new const g_ModelSuperKnife[] = "models/superknife.mdl"
new const g_ModelSuperM4A1[] = "models/v_golden_m4a1.mdl"
 
new bool:g_HasSuperKnife[MAX_PLAYERS+1]
new 
bool:g_HasSuperM4A1[MAX_PLAYERS+1]
new 
bool:g_HasSpeed[MAX_PLAYERS+1]
new 
bool:g_HasGravityT[MAX_PLAYERS+1]
new 
bool:g_HasGravityCt[MAX_PLAYERS+1]
 
enum _:ItemsT {
    
Item_SuperKnife_T 1,
    
Item_Gravity_T,
    
Item_Speed
}

enum _:ItemsCT {
    
Item_SuperKnife_Ct 1,
    
Item_Gravity_Ct,
    
Item_M249,
    
Item_G3SG1,
    
Item_He,
    
Item_Flash,
    
Item_SuperM4A1
}

new 
g_pCvarTCost[ItemsT], g_pCvarCTCost[ItemsCT]
new 
g_pCvarQuantityGravityTg_pCvarQuantityGravityCt
new g_pCvarQuantitySpeed
 
public plugin_init()
{
    
register_plugin("BaseBuilder Shop"VERSION"Ace67")

    
register_logevent("sv_roundstart"2"1=Round_Start");
 
    
register_clcmd("say /shop""ShowShop")
    
register_clcmd("say_team /shop""ShowShop")
    
register_clcmd("say shop""ShowShop");
    
register_clcmd("say_team shop""ShowShop");
 
    
g_pCvarTCost[Item_SuperKnife_T] = register_cvar("shopbb_cost_superknife_t""10000")
    
g_pCvarTCost[Item_Gravity_T] = register_cvar("shopbb_cost_gravity_t""8000")
    
g_pCvarTCost[Item_Speed] = register_cvar("shopbb_cost_speed""6000")
    
g_pCvarCTCost[Item_SuperKnife_Ct] = register_cvar("shopbb_cost_superknife_ct""800")
    
g_pCvarCTCost[Item_Gravity_Ct] = register_cvar("shopbb_cost_gravity_ct""8000")
    
g_pCvarCTCost[Item_M249] = register_cvar("shopbb_cost_m249""7000")
    
g_pCvarCTCost[Item_G3SG1] = register_cvar("shopbb_cost_g3sg1""8000")
    
g_pCvarCTCost[Item_He] = register_cvar("shopbb_cost_he""12000")
    
g_pCvarCTCost[Item_Flash] = register_cvar("shopbb_cost_flash""2000")
    
g_pCvarCTCost[Item_SuperM4A1] = register_cvar("shopbb_cost_SuperM4A1""9000")
 
    
g_pCvarQuantityGravityT register_cvar("shopbb_quantity_gravity_t""0.125")
    
g_pCvarQuantityGravityCt register_cvar("shopbb_quantity_gravity_ct""0.125")
    
g_pCvarQuantitySpeed register_cvar("shopbb_quantity_speed""400.0"
 
    
RegisterHam(Ham_Spawn"player""Player_Spawn_Post"1)
    
RegisterHam(Ham_TakeDamage"player""ham_TakeDamage_Pre")
    
RegisterHam(Ham_Item_Deploy"weapon_knife""ham_ItemDeploy_Post"1)
    
RegisterHam(Ham_Item_Deploy"weapon_m4a1""ham_ItemDeploy_Post_M4"1);
    
RegisterHam(Ham_Player_ResetMaxSpeed"player""Player_ResetMaxSpeed"1)
 
    
g_iMaxPlayers get_maxplayers()
 
    
set_cvar_num("sv_maxspeed"999)
}
 
public 
plugin_precache()
{
    
precache_model(g_ModelSuperKnife)
    
precache_model(g_ModelSuperM4A1)
}

public 
sv_roundstart()
{
    
g_iRoundsCount++;
}

public 
Player_ResetMaxSpeedid )
{
    if ( 
is_user_alive id ) )
    {
         if ( 
get_user_maxspeed(id) != -1.0 )
         {
              if ( 
g_HasSpeed[id] )
              {
                   
set_user_maxspeed(id600.0)
              }
         }
    }
}
 
public 
client_connectid )
{
    
client_cmd(id"cl_forwardspeed 999;cl_sidespeed 999;cl_backspeed 999")
    
g_HasSuperKnife[id] = false
    g_HasSuperM4A1
[id] = false
    g_HasSpeed
[id] = false;
}

public 
client_disconnect(id)
{
    
g_HasSuperKnife[id] = false;
    
g_HasSuperM4A1[id] = false;
}
 
public 
ShowShop(id)
{
    if ( 
is_user_alive(id) )
    {
        new 
Text[32]

        if ( 
cs_get_user_team(id) == CS_TEAM_T )
        {
            new 
menu menu_create ("\w^x03[\r ZOMBIE SHOP \w]""ShopT")
            
formatex(Textcharsmax(Text), "\wSuperKnife \y[\r%d $\y]"get_pcvar_num(g_pCvarTCost[Item_SuperKnife_T]))
            
menu_additem(menuText"1")
            
formatex(Textcharsmax(Text), "\wLow Gravity \y[\r%d $\y]"get_pcvar_num(g_pCvarTCost[Item_Gravity_T]))
            
menu_additem(menuText"2")
            
formatex(Textcharsmax(Text), "\wFast Speed \y[\r%d $\y]"get_pcvar_num(g_pCvarTCost[Item_Speed]))
            
menu_additem(menuText"3")
 
            
menu_setprop(menuMPROP_EXITNAME"Quit")
            
menu_setprop(menuMPROP_EXITMEXIT_ALL)
 
            
menu_display(idmenu)
        }
 
        else
        {
            new 
menu2 menu_create ("\w^x03[\r HUMAN SHOP \w]""ShopCt")
            
formatex(Textcharsmax(Text), "\wSuperKnife \y[\r%d $\y]"get_pcvar_num(g_pCvarCTCost[Item_SuperKnife_Ct]))
            
menu_additem(menu2Text"1")
            
formatex(Textcharsmax(Text), "\wLow Gravity \y[\r%d $\y]"get_pcvar_num(g_pCvarCTCost[Item_Gravity_Ct]))
            
menu_additem(menu2Text"2")
            
formatex(Textcharsmax(Text), "\wM249 \y[\r%d $\y]"get_pcvar_num(g_pCvarCTCost[Item_M249]))
            
menu_additem(menu2Text"3")
            
formatex(Textcharsmax(Text), "\wG3SG1 \y[\r%d $\y]"get_pcvar_num(g_pCvarCTCost[Item_G3SG1]))
            
menu_additem(menu2Text"4")
            
formatex(Textcharsmax(Text), "\wHE Grenade \y[\r%d $\y]"get_pcvar_num(g_pCvarCTCost[Item_He]))
            
menu_additem(menu2Text"5")
            
formatex(Textcharsmax(Text), "\wFlashbang \y[\r%d $\y]"get_pcvar_num(g_pCvarCTCost[Item_Flash]))
            
menu_additem(menu2Text"6")
            
formatex(Textcharsmax(Text), "\wS.M4A1 (VIP) \y[\r%d $\y]"get_pcvar_num(g_pCvarCTCost[Item_SuperM4A1]))
            
menu_additem(menu2Text"7")
 
            
menu_setprop(menu2MPROP_EXITNAME"Quit")
            
menu_setprop(menu2MPROP_EXITMEXIT_ALL)
 
            
menu_display(idmenu2)
        }
    }
    else
    {
        
client_print(idprint_chat"You must be alive for buy !")
    }
}
 
public 
ShopT(idmenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
 
    if ( !
is_user_alive(id) )
    {
        
client_print(idprint_chat"You must be alive for buy !")
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
 
    new 
info[3]
    new 
accesscallback
    menu_item_getinfo
(menuitemaccessinfo2__callback)
 
    new 
key str_to_num(info)
    new 
iNewMoney cs_get_user_money(id) - get_pcvar_num(g_pCvarTCost[key])
 
    if ( 
iNewMoney )
    {
        
client_print(idprint_chat"You don't have enough money !")
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    else
    {
        switch(
key)
        {
            case 
Item_SuperKnife_T:
            {
                if ( 
g_HasSuperKnife[id] )
                {
                    
client_print(idprint_chat"You have already the SuperKnife !")
                    
menu_destroy(menu)
                    return 
PLUGIN_HANDLED
                
}
                
give_item(id"weapon_knife")
                
set_pev(idpev_viewmodel2"models/superknife.mdl")
                
cs_set_user_money(idiNewMoney1)
                
g_HasSuperKnife[id] = true;
                
client_print(idprint_chat"You have bought SuperKnife !")
            }
 
            case 
Item_Gravity_T:
            {
                if(
g_iRoundsCount == 2) {
                    
client_print(idprint_chat"You cannot buy Gravity on first round !")
                    
menu_destroy(menu)
                    return 
PLUGIN_HANDLED
                
}

                if ( 
g_HasGravityT[id] )
                {
                    
client_print(idprint_chat"You have already Low Gravity !")
                    
menu_destroy(menu)
                    return 
PLUGIN_HANDLED
                
}
                
cs_set_user_money(idiNewMoney1)
                
set_user_gravity(idget_pcvar_float(g_pCvarQuantityGravityT) )
                
client_print(idprint_chat"You have bought Low Gravity !")
                
g_HasGravityT[id] = true;
            }
 
            case 
Item_Speed:
            {
                if ( 
g_HasSpeed[id] )
                {
                    
client_print(idprint_chat"You have already Fast Speed !")
                    
menu_destroy(menu)
                    return 
PLUGIN_HANDLED
                
}
                
cs_set_user_money(idiNewMoney1)
                
set_user_maxspeed(id,get_pcvar_float(g_pCvarQuantitySpeed) )
                
g_HasSpeed[id] = true;
                
client_print(idprint_chat"You have bought Fast Speed !")
            }
        }
    }
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED
}
 
public 
ShopCt(idmenu2item)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu2)
        return 
PLUGIN_HANDLED
    
}

    if (!
is_user_alive(id))
    {
        
client_print(idprint_chat"You must be alive to buy items!")
        
menu_destroy(menu2)
        return 
PLUGIN_HANDLED
    
}

    new 
info[3]
    new 
accesscallback
    menu_item_getinfo
(menu2itemaccessinfo2__callback)

    new 
key str_to_num(info)
    new 
iNewMoney cs_get_user_money(id) - get_pcvar_num(g_pCvarCTCost[key])

    if (
iNewMoney 0)
    {
        
client_print(idprint_chat"You don't have enough money!")
        
menu_destroy(menu2)
        return 
PLUGIN_HANDLED
    
}
    else
    {
        switch (
key)
        {
            case 
Item_SuperKnife_Ct:
            {
                if (
g_HasSuperKnife[id])
                {
                    
client_print(idprint_chat"You have already the SuperKnife!")
                    
menu_destroy(menu2)
                    return 
PLUGIN_HANDLED
                
}
                
cs_set_user_money(idiNewMoney1)
                
g_HasSuperKnife[id] = true;
                
client_print(idprint_chat"You have bought SuperKnife!")
            }

            case 
Item_Gravity_Ct:
            {
                if (
g_HasGravityCt[id])
                {
                    
client_print(idprint_chat"You have already Low Gravity!")
                    
menu_destroy(menu2)
                    return 
PLUGIN_HANDLED
                
}
                
cs_set_user_money(idiNewMoney1)
                
set_user_gravity(idget_pcvar_float(g_pCvarQuantityGravityCt))
                
client_print(idprint_chat"You have bought Low Gravity!")
                
g_HasGravityCt[id] = true;
            }

            case 
Item_M249:
            {
                if (
user_has_weapon(idCSW_M249))
                {
                    
client_print(idprint_chat"You have already M249!")
                    
menu_destroy(menu2)
                    return 
PLUGIN_HANDLED
                
}
                
cs_set_user_money(idiNewMoney1)
                
cs_set_user_bpammo(idCSW_M249200)
                
give_item(id"weapon_m249")
                
client_print(idprint_chat"You have bought M249!")
            }

            case 
Item_G3SG1:
            {
                if (
user_has_weapon(idCSW_G3SG1))
                {
                    
client_print(idprint_chat"You have already G3SG1!")
                    
menu_destroy(menu2)
                    return 
PLUGIN_HANDLED
                
}
                
cs_set_user_money(idiNewMoney1)
                
cs_set_user_bpammo(idCSW_G3SG1200)
                
give_item(id"weapon_g3sg1")
                
client_print(idprint_chat"You have bought G3SG1!")
            }

            case 
Item_He:
            {
                if (
user_has_weapon(idCSW_HEGRENADE))
                {
                    
client_print(idprint_chat"You have already Grenade!")
                    
menu_destroy(menu2)
                    return 
PLUGIN_HANDLED
                
}
                
cs_set_user_money(idiNewMoney1)
                
give_item(id"weapon_hegrenade")
                
client_print(idprint_chat"You have bought HeGrenade!")
            }

            case 
Item_Flash:
            {
                if (
cs_get_user_bpammo(idCSW_FLASHBANG) == 2)
                {
                    
client_print(idprint_chat"You have already 2 flashbangs!")
                    
menu_destroy(menu2)
                    return 
PLUGIN_HANDLED
                
}
                
cs_set_user_money(idiNewMoney1)
                
give_item(id"weapon_flashbang")
                
client_print(idprint_chat"You have bought Flashbang!")
            }

            case 
Item_SuperM4A1:
            {
                if (!(
get_user_flags(id) & FURIEN_VIP))
                {
                    
client_print(idprint_chat"You must be a VIP to buy the Super M4A1!")
                    
menu_destroy(menu2)
                    return 
PLUGIN_HANDLED
                
}
                if (
g_HasSuperM4A1[id])
                {
                    
client_print(idprint_chat"You have already Super M4A1!")
                    
menu_destroy(menu2)
                    return 
PLUGIN_HANDLED
                
}
                
cs_set_user_money(idiNewMoney1)
                
cs_set_user_bpammo(idCSW_M4A1200)
                
give_item(id"weapon_m4a1")
                
client_print(idprint_chat"You have bought Super M4A1!")
                
g_HasSuperM4A1[id] = true;
            }
        }
    }
    
menu_destroy(menu2)
    return 
PLUGIN_HANDLED
}


public 
Player_Spawn_Post(id)
{
    if (
is_user_alive(id))
    {
        
client_print(idprint_chat"Say /shop in the chat to buy an item!");

        if (
g_HasSuperKnife[id] && get_user_weapon(id) == CSW_KNIFE)
        {
            
set_pev(idpev_viewmodel2g_ModelSuperKnife);
        }

        if (
g_HasSuperM4A1[id] && get_user_weapon(id) == CSW_M4A1)
        {
            
set_pev(idpev_viewmodel2g_ModelSuperM4A1);
        }

        
g_HasSuperKnife[id] = false;
        
g_HasSuperM4A1[id] = false;
        
g_HasSpeed[id] = false;
    }
}
 
public 
ham_TakeDamage_Pre(victiminflictorattackerFloat:damagedamage_bits)
{
    if ( 
IsPlayer(attacker) && g_HasSuperKnife[attacker] && is_user_alive(attacker) && inflictor == attacker && get_user_weapon(attacker) == CSW_KNIFE )
    {
        
SetHamParamFloat4damage 154.0 )
    }
    
    if ( 
IsPlayer(attacker) && g_HasSuperM4A1[attacker] && is_user_alive(attacker) && inflictor == attacker && get_user_weapon(attacker) == CSW_M4A1 )
    {
        
SetHamParamFloat4damage 3.5 );
    }
}
 
public 
ham_ItemDeploy_Post(weapon_ent)
{
    static 
owner
    owner 
get_pdata_cbase(weapon_ent414)
 
    if ( 
is_user_alive(owner) && g_HasSuperKnife[owner] )
    {
        
set_pev(ownerpev_viewmodel2g_ModelSuperKnife);
    }
}

public 
ham_ItemDeploy_Post_M4(weapon_ent)
{
    static 
owner;
    
owner get_pdata_cbase(weapon_ent414);

    if ( 
is_user_alive(owner) && g_HasSuperM4A1[owner] )
    {
        
set_pev(ownerpev_viewmodel2g_ModelSuperM4A1);
    }


Last edited by Ace67; 10-26-2023 at 14:11.
Ace67 is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 10-26-2023 , 14:24   Re: Item deploy bug
Reply With Quote #2

Remove this at player spawn:
Code:
if (g_HasSuperKnife[id] && get_user_weapon(id) == CSW_KNIFE)
        {
            set_pev(id, pev_viewmodel2, g_ModelSuperKnife);
        }

if (g_HasSuperM4A1[id] && get_user_weapon(id) == CSW_M4A1)
        {
            set_pev(id, pev_viewmodel2, g_ModelSuperM4A1);
        }
and instead add
Code:
if ( g_HasSuperKnife[id] && get_user_weapon(id) == CSW_KNIFE )
		{
			set_pev(id, pev_viewmodel2, "models/v_your_default_knife_model.mdl")
		}
You have m4a1 model despite you are playing with a knife because bb forces you to use knife on build time. That should fix your code.
__________________
Jhob94 is offline
Ace67
Senior Member
Join Date: Sep 2020
Location: France
Old 10-26-2023 , 14:50   Re: Item deploy bug
Reply With Quote #3

Quote:
Originally Posted by Jhob94 View Post
Remove this at player spawn:
Code:
if (g_HasSuperKnife[id] && get_user_weapon(id) == CSW_KNIFE)
        {
            set_pev(id, pev_viewmodel2, g_ModelSuperKnife);
        }

if (g_HasSuperM4A1[id] && get_user_weapon(id) == CSW_M4A1)
        {
            set_pev(id, pev_viewmodel2, g_ModelSuperM4A1);
        }
and instead add
Code:
if ( g_HasSuperKnife[id] && get_user_weapon(id) == CSW_KNIFE )
		{
			set_pev(id, pev_viewmodel2, "models/v_your_default_knife_model.mdl")
		}
You have m4a1 model despite you are playing with a knife because bb forces you to use knife on build time. That should fix your code.
Is still bug

I mean the M4A1 not spawning in the hands. It's when we press the key "1" for weapon. Its doing like its a knife

I will share video you will understand: https://streamable.com/xv8b7c

Last edited by Ace67; 10-26-2023 at 15:10.
Ace67 is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 10-26-2023 , 15:35   Re: Item deploy bug
Reply With Quote #4

That’s because it’s a knife. On item_deploy of m4 verify if it’s a m4 before setting the model.
__________________
Jhob94 is offline
amirwolf
Senior Member
Join Date: Feb 2019
Location: Iran
Old 10-26-2023 , 15:54   Re: Item deploy bug
Reply With Quote #5

It is better to make the purchase menu available after the construction time
__________________
amirwolf is offline
Ace67
Senior Member
Join Date: Sep 2020
Location: France
Old 10-26-2023 , 15:57   Re: Item deploy bug
Reply With Quote #6

Quote:
Originally Posted by Jhob94 View Post
That’s because it’s a knife. On item_deploy of m4 verify if it’s a m4 before setting the model.
It is but, that doing it only on build phase after the weapon came back to the right hands
That’s the bug
Ace67 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 01:48.


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