Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdktools>
- #include <sdkhooks>
- public OnPluginStart()
- {
- HookEvent("item_pickup", eItemPickup, EventHookMode_Post);
- }
- public Action eItemPickup(Event event, const char[] name, bool dontBroadcast)
- {
- char sItemName[128];
- event.GetString("item", sItemName, sizeof(sItemName));
- if(StrContains(sItemName, "weapon_ammo", false))
- {
- int iSurvivor = GetClientOfUserId(event.GetInt("userid"));
- if(bIsSurvivor(iSurvivor))
- {
- GiveFunction(iSurvivor, "ammo")
- }
- }
- }
- void GiveFunction(int client, char[] name)
- {
- char sBuf[32];
- int flags = GetCommandFlags("give");
- SetCommandFlags("give", flags & ~FCVAR_CHEAT);
- FormatEx(sBuf, sizeof sBuf, "give %s", name);
- FakeClientCommand(client, sBuf);
- }
- stock bool bIsSurvivor(int client)
- {
- return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement