| 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(id, item, name[], price) //ignore
{
if(g_iItemID == item)//ignore
{
if(user_has_weapon(id, WEAPON_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(id, data);
client_print_color(id, print_team_default, "%s %L", TTT_TAG, id, "TTT_ITEM2", name, id, "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.
|