5 // GetEntPropArraySize - PropSend/PropData
7 // GetEntPropString - PropData
9 // GetEntProp - PropSend/PropData
10 // GetEntPropEnt - PropSend/PropData
12 // SetEntProp - PropSend/PropData
14 public OnPluginStart()
16 RegConsoleCmd("sm_listammo", sm_listammo, "sm_listammo <send|data> [target] - Lists current ammo for self or specified player");
17 RegConsoleCmd("sm_listweapons", sm_listweapons, "sm_listweapons <send|data> [target] - Lists current weapons for self or specified player");
18 RegConsoleCmd("sm_setammo", sm_setammo, "sm_setammo <ammotype> <amount> <send|data> [target]");
19 RegConsoleCmd("sm_teststrings", sm_teststrings);
22 public Action:sm_listammo(client, argc)
24 decl String:buffer[64];
28 GetCmdArg(2, buffer, sizeof(buffer));
29 target = FindTarget(client, buffer, false, false);
32 ReplyToCommand(client, "Bad client");
33 return Plugin_Handled;
38 ReplyToCommand(client, "Dillweed");
39 return Plugin_Handled;
42 new PropType:proptype = PropType:-1;
43 GetCmdArg(1, buffer, sizeof(buffer));
44 if (!strcmp(buffer, "send"))
46 else if (!strcmp(buffer, "data"))
50 new max = GetEntPropArraySize(target, proptype, "m_iAmmo");
51 for (new i = 0; i < max; i++)
53 if ((ammo = GetEntProp(target, proptype, "m_iAmmo", _, i)) > 0)
54 ReplyToCommand(client, "Slot %d, Ammo %d", i, ammo);
57 return Plugin_Handled;
60 public Action:sm_listweapons(client, argc)
62 decl String:buffer[64];
66 GetCmdArg(2, buffer, sizeof(buffer));
67 target = FindTarget(client, buffer, false, false);
70 ReplyToCommand(client, "Bad client");
71 return Plugin_Handled;
76 ReplyToCommand(client, "Dillweed");
77 return Plugin_Handled;
80 new PropType:proptype = PropType:-1;
81 GetCmdArg(1, buffer, sizeof(buffer));
82 if (!strcmp(buffer, "send"))
84 else if (!strcmp(buffer, "data"))
87 new weapon, String:classname[64];
88 new max = GetEntPropArraySize(target, proptype, "m_hMyWeapons");
89 for (new i = 0; i < max; i++)
91 if ((weapon = GetEntPropEnt(target, proptype, "m_hMyWeapons", i)) == -1)
94 GetEdictClassname(weapon, classname, sizeof(classname));
95 ReplyToCommand(client, "Slot %d - \"%s\"", i, classname);
98 return Plugin_Handled;
101 public Action:sm_setammo(client, argc)
103 decl String:buffer[64];
107 GetCmdArg(4, buffer, sizeof(buffer));
108 target = FindTarget(client, buffer, false, false);
111 ReplyToCommand(client, "Bad client");
112 return Plugin_Handled;
115 else if (client == 0)
117 ReplyToCommand(client, "Dillweed");
118 return Plugin_Handled;
121 new PropType:proptype = PropType:-1;
122 GetCmdArg(3, buffer, sizeof(buffer));
123 if (!strcmp(buffer, "send"))
124 proptype = Prop_Send;
125 else if (!strcmp(buffer, "data"))
126 proptype = Prop_Data;
128 new max = GetEntPropArraySize(target, proptype, "m_iAmmo");
130 GetCmdArg(1, buffer, sizeof(buffer));
131 new ammotype = StringToInt(buffer);
135 ReplyToCommand(client, "Ammotype out of bounds");
136 return Plugin_Handled;
139 GetCmdArg(2, buffer, sizeof(buffer));
140 new amount = StringToInt(buffer);
142 SetEntProp(target, proptype, "m_iAmmo", amount, _, ammotype);
144 return Plugin_Handled;
147 public Action:sm_teststrings(client, argc)
149 new gpe = CreateEntityByName("game_player_equip");
150 DispatchKeyValue(gpe, "tf_weapon_rocketlauncher", "2");
151 DispatchKeyValue(gpe, "tf_weapon_pistol", "1");
153 decl String:value[64];
154 for (new i = 0; i < 2; i++)
156 GetEntPropString(gpe, Prop_Data, "m_weaponNames", value, sizeof(value), i);
157 ReplyToCommand(client, "At %d, I see a \"%s\"", i, value);
160 AcceptEntityInput(gpe, "Kill");
162 return Plugin_Handled;