AMXX-BG.INFO knifeapi.inc Raw include

knifeapi.inc

Original include source with line numbers.

Back Download .inc
1 // I don't really know what this does.
2 #pragma library "knifeapi"
3
4 /**************************************************
5 ************ API ENUMS AND STRUCTURES ************
6 *************************************************/
7
8 enum KnifeProperties
9 {
10 KN_STR_WeaponName, // name of the weapon shown in the menu
11 KN_STR_VModel, // v_model path including models/
12 KN_STR_PModel, // p_model path including models/
13 KN_STR_WModel, // w_model path including models/
14 KN_STR_DeploySound, // deploy sound path
15 KN_STR_SlashSound, // slash sound path
16 KN_STR_StabSound, // stab sound path
17 KN_STR_WhiffSound, // whiff (air) sound path
18 KN_STR_WallSound, // wall hit sound path
19 KN_STR_SpriteName, // if you're using a custom sprite, change this to the .txt filename (weapon_custom for example) - DON'T CHANGE IF YOU'RE NOT USING A CUSTOM SPRITE!!!
20 KN_CLL_Droppable, // should be droppable?
21 KN_CLL_PrimaryDamage, // primary damage multiplier (1.0 - default damage, 2.0 - double damage etc.)
22 KN_CLL_SecondaryDamage, // secondary damage multiplier (1.0 - default damage, 2.0 - double damage etc.)
23 KN_CLL_PrimaryNextAttack, // time between primary attacks in seconds
24 KN_CLL_SecondaryNextAttack, // time between secondary attacks in seconds
25 KN_CLL_PrimaryRange, // range of the primary attack
26 KN_CLL_SecondaryRange, // range of the secondary attack
27 KN_CLL_PrimaryDamageDelay, // delay between button press and the actual knife hit for primary damage
28 KN_CLL_SecondaryDamageDelay,// ^ for secondary damage
29 KN_CLL_PrimaryDmgBits, // such as DMG_BULLET | DMG_ALWAYSGIB (makes the enemies explode), DMG_BULLET | DMG_NEVERGIB default
30 KN_CLL_SecondaryDmgBits, // ^ for secondary
31 KN_CLL_TeamLock, // if not 0, other team won't be able to pick up/deploy the knife
32 KN_CLL_NextAttackDependency,// if true, a primary attack also modifies the secondary next attack by the same amount (and vice versa); true by default
33 KN_CLL_IgnoreFriendlyFire // ignore friendly fire?
34 };
35
36 enum _:ForwardReturns
37 {
38 KnifeAction_Block = 5,
39 KnifeAction_DoNothing
40 };
41
42 /****************************************
43 ************ PLUGIN NATIVES ************
44 ***************************************/
45
46 /* Knife_Register(): Registers a knife.
47
48 * @params: See KnifeProperties, they're the same
49 * @info: You can use additional settings with Knife_SetProperty
50 * @return: (Int) Pointer to the knife
51 */
52 native Knife_Register(
53 const WeaponName[] = "New Knife",
54 const VModel[],
55 const PModel[] = "",
56 const WModel[] = "",
57 const DeploySound[] = "weapons/knife_deploy1.wav",
58 const SlashSound[] = "weapons/knife_hit1.wav",
59 const StabSound[] = "weapons/knife_stab.wav",
60 const WhiffSound[] = "weapons/knife_slash1.wav",
61 const WallSound[] = "weapons/knife_hitwall1.wav",
62 Float:PrimaryDamage = 1.0,
63 Float:SecondaryDamage = 1.0
64 );
65
66 /* Knife_GetTotal(): Returns the amount of knives registered.
67
68 * @info: Used for loops of knives: for(new i=1; i<=Knife_GetTotal(); i++)
69
70 * @return: (Int) amount of knives registered
71 */
72 native Knife_GetTotal();
73
74 /* Knife_GetProperty(): Retrieves a property of a knife from the KnifeProperties enum.
75
76 * @param (Int) Knife: Knife index
77 * @param (Int) Value: Value from the KnifeProperties enum
78 * @params (any...): If you're using a value from KN_STR_X, the next two params are output string and buffer size,
79 otherwise it's only the output cell to which the data is saved by reference
80
81 * @return: (Int) 1 on success, 0 on failure/error
82 */
83 native Knife_GetProperty(Knife, KnifeProperties:Value, any:...);
84
85 /* Knife_SetProperty(): Sets a property of a knife from the KnifeProperties enum.
86
87 * @param (Int) Knife: Knife index
88 * @param (Int) Value: Value from the KnifeProperties enum
89 * @params (any...): String/cell with the value
90
91 * @return: (Int) 1 on success, 0 on failure/error
92 */
93 native Knife_SetProperty(Knife, KnifeProperties:Value, any:...);
94
95 /* Knife_PlayerGive(): Gives a knife to a player.
96
97 * @param (Int) Player: Index of the player
98 * @param (Int) Knife: Knife index
99 * @param (bool) Set: If true, the player will automatically equip the knife
100
101 * @return: (Int) 1 on success, 0 on failure/error
102 */
103 native Knife_PlayerGive(Player, Knife, bool:Set = true);
104
105 /* Knife_PlayerGetCurrent(): Returns the current knife a player has equipped.
106
107 * @param (Int) Player: Index of the player
108
109 * @return: (Int) 0 - default knife, X - knife ID, -1 - error/failure
110 */
111 native Knife_PlayerGetCurrent(Player);
112
113 /* Knife_PlayerSetCurrent(): Force-equips a knife on the player. Player must own the knife.
114
115 * @param (Int) Player: Index of the player to give the knife to
116 * @param (Int) Knife: Knife index
117
118 * @return: (Int) 1 on success, 0 on failure/error
119 */
120 native Knife_PlayerSetCurrent(Player, Knife);
121
122 /* Knife_PlayerHas(): Check whether a player has a knife.
123
124 * @param (Int) Player: Index of the player
125 * @param (Int) Knife: Knife index
126
127 * @return: (Int) 1 on yes, 0 on failure/error/no
128 */
129 native Knife_PlayerHas(Player, Knife);
130
131 /* Knife_PlayerSetLock(): Prevents a player from changing their knife.
132
133 * @param (Int) Player: Index of the player
134 * @param (Bool) Locked: Lock status - true: locked, false: unlocked
135
136 * @return: nothing
137 */
138 native Knife_PlayerSetLock(Player, bool:Locked);
139
140 /* Knife_PlayerGetLock(): Checks player's knife lock status.
141
142 * @param (Int) Player: Index of the player
143
144 * @return: (Bool) true: locked, false: unlocked
145 */
146 native bool:Knife_PlayerGetLock(Player);
147
148 /* Knife_PlayerRemoveAll(): Removes all knives except default from the player.
149
150 * @param (Int) Player: Index of the player
151
152 * @return: nothing
153 */
154 native Knife_PlayerRemoveAll(Player);
155
156 /**********************************
157 ************ FORWARDS ************
158 *********************************/
159
160 /* KnifeAction_ProcessAttack_Pre(): Called when an attack is about to happen.
161 Pre hook: This gets called before the animation delay if there is any.
162 You can block the action with KnifeAction_Block.
163 * @param (Int) Player: Index of the player(attacker)
164 * @param (Int) Knife: Knife index
165 * @param (bool) PrimaryAttack: true: yes, false: no
166 */
167 forward KnifeAction_ProcessAttack_Pre(Player, Knife, bool:PrimaryAttack);
168
169 /* KnifeAction_ProcessAttack_Post(): Called when an attack has happened.
170 Post hook: This gets called after the animation delay, if there's any.
171 You cannot block this forward. Block KnifeAction_DealDamage instead.
172 * @param (Int) Player: Index of the player(attacker)
173 * @param (Int) Victim: Player receiving the damage. If there was no player (wall/air slash), Victim is 0.
174 * @param (Int) Knife: Knife index
175 * @param (bool) PrimaryAttack: true: yes, false: no
176 * @param (Vector) EndPoint: Ending point of the knife trace. This is the origin where the damage has happened.
177 I recommend playing your custom sounds/showing various sprites using this.
178 * @param (Vector) AimVector: Player's aiming direction
179 */
180 forward KnifeAction_ProcessAttack_Post(Player, Victim, Knife, bool:PrimaryAttack, Float:EndPoint[3], Float:AimVector[3]);
181
182 /* KnifeAction_DealDamage(): Called right before an attack happening
183 Pre hook: You can block the action with KnifeAction_Block.
184 * @param (Int) Attacker: Index of the player(attacker)
185 * @param (Int) Victim: Player receiving the damage
186 * @param (Int) Knife: Knife index
187 * @param (Float) Damage: Damage received with modifiers in mind (hitboxes/backstab/custom damage multiplier)
188 * @param (bool) PrimaryAttack: true: yes, false: no
189 * @param (Vector) EndPoint: Ending point of the knife trace. This is the origin where the damage has happened.
190 I recommend playing your custom sounds/showing various sprites using this.
191 * @param (Vector) AimVector: Player's aiming direction
192 * @param (Int) Hitzone: Damage hitzone, such as HIT_HEAD.
193 */
194 forward KnifeAction_DealDamage(Attacker, Victim, Knife, Float:Damage, bool:PrimaryAttack, DamageBits, bool:Backstab,
195 Float:EndPoint[3], Float:AimVector[3], Hitzone
196 );
197
198 /* KnifeAction_Deploy(): Called when a player draws a knife.
199 Post hook: You cannot block this forward.
200 * @param (Int) Attacker: Index of the player
201 * @param (Int) Knife: Knife index
202 */
203 forward KnifeAction_Deploy(Player, Knife);
204
205 /* KnifeAction_SoundPlay(): Called when a knife sound is about to play.
206 Pre hook: You can block the action with KnifeAction_Block.
207 * @param (Int) Player: Index of the player
208 * @param (Int) Knife: Knife index
209 * @param (String) Sound: Sound played
210 */
211 forward KnifeAction_SoundPlay(Player, Knife, const Sound[]);
212