Quote:
Originally Posted by Jelle
I believe get_user_weapon() returns the CSW_* value of the gun the index is holding, so I do not quite understand what you are trying to explain me here.
I think it was cs_get_user_weapon() which gave a number.
But why add a 0 after each weapon? And I do not quite follow you on how to store max clips and such. I rarely use arrays. Is it any faster to do it that way, and not with a switch?
|
Add this to your bookmarks:
http://www.amxmodx.org/funcwiki.php
cs_get_weapon_id( weapon_entity_index ) returns the CSW_ constant of the weapon entity index passed to it.
get_user_weapon( player_index ) returns the CSW_ constant of the weapon a player is holding.
Both of these return the same thing (a number / CSW_ constant). The difference is what you pass to the function as a parameter.
What you should be using is get_user_weapon() since you are passing a player-id.
The array method I was showing you will allow you to not use switch statement which will make your code more efficient.
Since there are no weapons with an index (CSW_ value) of 0 or 2, we need to put placeholders in these locations so the remainder of the array will stay in order (this can be any number since it will never be used). Maybe this code will be easier to understand...you can continue for the remaining weapons, there are no other 'empty slots'.
PHP Code:
new const GunMax[ 31 ] =
{
0, //0 - empty slot
13, //1 - P228
0, //2 - empty slot
10, //3 - SCOUT
0, //4 - HEGRENADE
7, //5 - XM1014
0, //6 - C4
30, //7 - MAC10
30, //8 - AUG
0, //9 - SMOKEGRENADE
15, //10 - ELITE
// etc for all weapons
}
Just be sure the weapons are all in order identical to the CSW constants.
Code:
/* Id of weapons in CS */
#define CSW_P228 1
#define CSW_SCOUT 3
#define CSW_HEGRENADE 4
#define CSW_XM1014 5
#define CSW_C4 6
...
__________________