AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Change weapon clip (https://forums.alliedmods.net/showthread.php?t=335968)

The overrated maniac 01-17-2022 18:43

Change weapon clip
 
I have a deagle with 1 bullet and 35 to load. I shoot that bullet, I reaload and I want to have only 1 bullet and not 7.
I saw apis that do that, I dont want to use them because they have a lot of things and I only need one

fysiks 01-17-2022 19:16

Re: Change weapon clip
 
If a method exists to do what you want, you should use it until you find something better. The excuse "I don't want to use it because they have too many other features" is a very bad excuse unless there is tangible evidence that it actually affects the behavior of the used functionality.

To what method are you referring? Maybe it can be used to create something better.

The overrated maniac 01-17-2022 21:24

Re: Change weapon clip
 
2 Attachment(s)
Quote:

Originally Posted by fysiks (Post 2768681)
If a method exists to do what you want, you should use it until you find something better. The excuse "I don't want to use it because they have too many other features" is a very bad excuse unless there is tangible evidence that it actually affects the behavior of the used functionality.

To what method are you referring? Maybe it can be used to create something better.

I dont understand the code so I cant change it, its cs_weapons_api and I got it from ttt, its used for newton launcher item and others.

This is the STRUCT, but I dont know where data[STRUCT_CSWA_CLIP] comes from and how to get the code to only use it and not all.
PHP Code:

//on plugin init
cvar_weapon_clip    my_register_cvar("ttt_newton_clip",    "1",    "Newton Launcher clip ammo. (Default: 1)");
    
cvar_weapon_ammo    my_register_cvar("ttt_newton_ammo",    "10",    "Newton Launcher backpack ammo. (Default: 10)");
    
cvar_weapon_speed    my_register_cvar("ttt_newton_speed",    "2.0",    "Newton Launcher attack speed delay. (Default: 2.0)");
    
cvar_weapon_damage    my_register_cvar("ttt_newton_damage",    "0.0",    "Newton Launcher damage multiplier. (Default: 0.0)");
    
cvar_weapon_reload    my_register_cvar("ttt_newton_reload",    "2.0",    "Newton Launcher reload speed. (Default: 2.0)");
    
cvar_weapon_recoil    my_register_cvar("ttt_newton_recoil",    "0.0",    "Newton Launcher recoil. (Default: 0.0)");
    
cvar_weapon_force    my_register_cvar("ttt_newton_force",    "100.0","Newton Launcher force. (Default: 100.0)");
    
cvar_weapon_price    my_register_cvar("ttt_price_newton",    "1",    "Newton Launcher price. (Default: 1)");

// after
public ttt_item_selected(iditemname[], price//ignore
{
    if(
g_iItemID == item)//ignore
    
{
        if(
user_has_weapon(idWEAPON_CSWID))//ignore
            
engclient_cmd(id"drop"WEAPON_NAME);//ignore

        
static data[STOREABLE_STRUCTURE];
        if(!
data[STRUCT_CSWA_CSW])
        {
            
data[STRUCT_CSWA_ITEMID] = g_iItemID;
            
data[STRUCT_CSWA_CSW] = WEAPON_CSWID;
            
data[STRUCT_CSWA_CLIP] = get_pcvar_num(cvar_weapon_clip);
            
data[STRUCT_CSWA_MAXCLIP] = get_pcvar_num(cvar_weapon_clip);
            
data[STRUCT_CSWA_AMMO] = get_pcvar_num(cvar_weapon_ammo);
            
data[STRUCT_CSWA_STACKABLE] = true;
            
data[STRUCT_CSWA_SILENCED] = -1;
            
data[STRUCT_CSWA_SPEEDDELAY] = _:get_pcvar_float(cvar_weapon_speed);
            
data[STRUCT_CSWA_DAMAGE] = _:get_pcvar_float(cvar_weapon_damage);
            
data[STRUCT_CSWA_RELOADTIME] = _:get_pcvar_float(cvar_weapon_reload);
            
//data[STRUCT_CSWA_RECOIL] = _:get_pcvar_float(cvar_weapon_recoil);
            
data[STRUCT_CSWA_MODEL_V] = g_szModels[0];
            
data[STRUCT_CSWA_MODEL_P] = g_szModels[1];
            
data[STRUCT_CSWA_MODEL_W] = g_szModels[2];
        }

        
cswa_give_specific(iddata);

        
client_print_color(idprint_team_default"%s %L"TTT_TAGid"TTT_ITEM2"nameid"TTT_ITEM5");//ignore
        
return PLUGIN_HANDLED;
    }

    return 
PLUGIN_CONTINUE;


below is the api, I dont know if something else is needed, but in the api I didnt found the method to do it.

DJEarthQuake 01-17-2022 21:32

Re: Change weapon clip
 
Why not cs_set_weapon_ammo?

The overrated maniac 01-17-2022 22:24

Re: Change weapon clip
 
Quote:

Originally Posted by DJEarthQuake (Post 2768687)

I want only 1 bullet after the user reload. Shoot, reload, shoot, reload. Not shoot shoot shoot shoot reload shoot shoot shoot shoot reload. Can it be done with that? max 1 shoot?

fysiks 01-17-2022 23:15

Re: Change weapon clip
 
You already said that and he gave you an option to try. Try it and see if you can get it to work. FYI, GunGame does this for the AWP in event_curweapon() using cs_set_weapon_ammo().

The overrated maniac 01-18-2022 22:08

Re: Change weapon clip
 
Quote:

Originally Posted by fysiks (Post 2768694)
FYI, GunGame does this for the AWP in event_curweapon() using cs_set_weapon_ammo().

Thanks


All times are GMT -4. The time now is 11:30.

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