Quote:
Originally Posted by mug1wara
You could just use AddCommandListener, also it didn't work with GivePlayerAmmo for some reason :/
Here's a sample plugin:
PHP Code:
#include <sdktools>
#pragma semicolon 1
public void OnMapStart() { AddCommandListener(Cmd_Callback, "+attack"); /* Mouse1 */ AddCommandListener(Cmd_Callback, "+attack2"); /* Mouse2 I think, not sure */ }
public Action Cmd_Callback(int iClient, const char[] sCommand, int iArgs) { CreateTimer(1.5, Timer_Ammo, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE); }
public Action Timer_Ammo(Handle hTimer) { for (int i = 1; i <= MaxClients; i++) { if (IsClientInGame(i)) { if (IsPlayerAlive(i)) { int iAmmo = GetEntProp(i, Prop_Data, "m_iAmmo"); /* Get ammo count */ SetEntProp(i, Prop_Sned, "m_iClip1", 0); /* Remove ammo */ SetEntProp(i, Prop_Send, "m_iClip1", iAmmo + 1); /* Give the player it's original ammo, but + 1 */ } } } return Plugin_Continue; }
|
+attack and similar aren't commands, they are "buttons" and cannot be intercepted via command listeners.
Please do not post false or misleading information.
Quote:
Originally Posted by Ilusion9
PHP Code:
public void OnPluginStart() { for(int i = 1; i <= MaxClients; i++) { if(IsClientInGame(i) && IsPlayerAlive(i)) { if(...) // check if the client needs ammo and maybe check if that client is not in +attack with GetClientButtons() { GiveAmmo(i); // your function for ammo } } } }
use this logic.
|
That would only happen when the plugin starts, which is usually before there are even any players in the server. This code does nothing.
__________________