Advertisement
FlacoBey

Untitled

Jan 29th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include <sdkhooks>
  4.  
  5. public OnPluginStart()
  6. {
  7. HookEvent("item_pickup", eItemPickup, EventHookMode_Post);
  8. }
  9.  
  10. public Action eItemPickup(Event event, const char[] name, bool dontBroadcast)
  11. {
  12. char sItemName[128];
  13. event.GetString("item", sItemName, sizeof(sItemName));
  14. if(StrContains(sItemName, "weapon_ammo", false))
  15. {
  16. int iSurvivor = GetClientOfUserId(event.GetInt("userid"));
  17. if(bIsSurvivor(iSurvivor))
  18. {
  19. GiveFunction(iSurvivor, "ammo")
  20. }
  21. }
  22. }
  23.  
  24. void GiveFunction(int client, char[] name)
  25. {
  26. char sBuf[32];
  27. int flags = GetCommandFlags("give");
  28. SetCommandFlags("give", flags & ~FCVAR_CHEAT);
  29. FormatEx(sBuf, sizeof sBuf, "give %s", name);
  30. FakeClientCommand(client, sBuf);
  31. }
  32.  
  33. stock bool bIsSurvivor(int client)
  34. {
  35. return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement