-
-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ammo constants for max clip ammo and max backpack ammo #544
base: master
Are you sure you want to change the base?
Conversation
Update to latest dev build
Aaaand the old commits popped up again. If someone knows how to fix that, let me know, if not, so be it. |
The function is there exactly because you shouldn't hardcode that stuff, this is just going backwards. |
Why not give names to enums? This enums can declare array sizes |
@rsKliPPy In order to use that function, the value of it will needs to be cached in a variable in order for it to be optimized. static const some_ammo = cs_get_weapon_info(CSW_AK47, CS_WEAPONINFO_GUN_CLIP_SIZE)
give_item(id, "weapon_ak47")
cs_set_user_bpammo(id, CSW_AK47, some_ammo) Imagine what you have to do when you have multiple weapons - it's very inconvenient. These values never change by default so it's better to have them as constants. You can get the weapon cost with the same function, but we still have price constants in the file. @wopox1337 It will give a tag mismatch when used in one of the existing functions, e.g. |
You won't be setting ammo every frame, chill. |
Since there is a cstrike_const.inc file, I'd agree implementing these constants. |
@rsKliPPy I'm aware of that, but I'm also aware that plugin approvers will say to precache the value for maximum optimization and "good practice". |
I don't think you have to cache the result. Using the native directly also accounts for plugins altering WeaponInfoStruct on the fly to change bpammo/price/etc(not very likely to happen, but still). |
^ That's mainly the reason. That's said, having constants to get the original and default value could make sense but doesn't seem really useful at first glance. |
What do you mean? |
To prevent using magic numbers. Most usual case is giving a weapon to a player:
The number 30 here should have a constant, as well as all others. I know there's
cs_get_weapon_info
, but there's no need to use a function here.