-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimplified-infinite-ammo.sp
57 lines (48 loc) · 1.58 KB
/
simplified-infinite-ammo.sp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <sourcemod>
#define PLUGIN_VERSION "1.0"
public Plugin:myinfo = {
name = "Infinite Reserve Ammo",
author = "Modified for GunGame",
description = "Gives all players infinite reserve ammo",
version = PLUGIN_VERSION,
url = ""
};
new activeoffset;
new maxclients;
public OnPluginStart()
{
// Get weapon offset
activeoffset = FindSendPropInfo("CAI_BaseNPC", "m_hActiveWeapon");
// Create timer for infinite ammo checks
CreateTimer(0.1, AmmoTimer, _, TIMER_REPEAT);
}
public OnMapStart() {
maxclients = MaxClients;
}
public Action:AmmoTimer(Handle:timer)
{
new iWeapon;
new iAmmoType;
for(new iClient = 1; iClient <= maxclients; iClient++)
{
if(IsClientInGame(iClient) && IsPlayerAlive(iClient))
{
iWeapon = GetEntDataEnt2(iClient, activeoffset);
if(IsValidEntity(iWeapon)) {
// Get primary ammo type
iAmmoType = GetEntProp(iWeapon, Prop_Send, "m_iPrimaryAmmoType");
if(iAmmoType != -1) {
// Set reserve ammo to max (999)
SetEntProp(iClient, Prop_Send, "m_iAmmo", 999, _, iAmmoType);
}
// Get and set secondary ammo type
iAmmoType = GetEntProp(iWeapon, Prop_Send, "m_iSecondaryAmmoType");
if(iAmmoType != -1) {
// Set secondary reserve ammo to max
SetEntProp(iClient, Prop_Send, "m_iAmmo", 999, _, iAmmoType);
}
}
}
}
return Plugin_Continue;
}