Guest User

Untitled

a guest
Apr 19th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.56 KB | None | 0 0
  1.  
  2. #include <amxmodx>
  3. #include <amxmisc>
  4. #include <cstrike>
  5. #include <engine>
  6.  
  7. #define PLUGIN "Spawn_Weapon"
  8. #define VERSION "1.0"
  9. #define AUTHOR "Mariko <3"
  10.  
  11. #define MAX_INFO_TARGET 20
  12.  
  13. public plugin_init()
  14. {
  15.     register_plugin(PLUGIN, VERSION, AUTHOR);
  16.    
  17.     register_clcmd("say /spawn","Spawn_Weapon");
  18. }
  19.  
  20. public Spawn_Weapon(id)
  21. {
  22.     new Float:Origin[3];
  23.     new ok = SearchOriginInfoTarget(Origin);
  24.    
  25.     client_print(id, print_chat, "Nombre d'entite info_target : %d", ok);
  26.    
  27.     if(ok)
  28.     {
  29.         new weapon;
  30.         if(random(10) > 6) weapon = CSW_M3; // 30 %
  31.         else weapon = CSW_MAC10; // 70 %
  32.        
  33.         client_print(id, print_chat, "Entite placee : %d", SpawnArmouryEntity(weapon, Origin));
  34.     }
  35. }
  36.  
  37. SearchOriginInfoTarget(Float:Origin[3])
  38. {
  39.     new ent;
  40.     new count;
  41.     new Float:OriginInfoTarget[MAX_INFO_TARGET][3];
  42.    
  43.     while (ent = find_ent_by_class(ent, "info_target"))
  44.     {
  45.         entity_get_vector(ent, EV_VEC_origin, OriginInfoTarget[count]);
  46.         count++;
  47.        
  48.         if(count == MAX_INFO_TARGET) break;
  49.     }
  50.    
  51.     if(!count) return 0; // Pas d'entité Info Target
  52.    
  53.     new has = random(count);
  54.    
  55.     Origin[0] = OriginInfoTarget[has][0];
  56.     Origin[1] = OriginInfoTarget[has][1];
  57.     Origin[2] = OriginInfoTarget[has][2] + 64;
  58.        
  59.     return count;
  60. }
  61.  
  62. SpawnArmouryEntity(CSW_WEAPONID, Float:vecOrigin[3], szCount[] = "1")
  63. {
  64.     new iEnt = create_entity("armoury_entity");
  65.  
  66.     if(iEnt > 0 && cs_set_armoury_type(iEnt, CSW_WEAPONID))
  67.     {
  68.         DispatchKeyValue(iEnt, "count", szCount);
  69.         entity_set_vector(iEnt, EV_VEC_origin, vecOrigin);
  70.         DispatchSpawn(iEnt);
  71.         return iEnt;
  72.     }
  73.     return 0;
  74. }
Add Comment
Please, Sign In to add comment