Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <amxmisc>
- #include <cstrike>
- #include <engine>
- #define PLUGIN "Spawn_Weapon"
- #define VERSION "1.0"
- #define AUTHOR "Mariko <3"
- #define MAX_INFO_TARGET 20
- public plugin_init()
- {
- register_plugin(PLUGIN, VERSION, AUTHOR);
- register_clcmd("say /spawn","Spawn_Weapon");
- }
- public Spawn_Weapon(id)
- {
- new Float:Origin[3];
- new ok = SearchOriginInfoTarget(Origin);
- client_print(id, print_chat, "Nombre d'entite info_target : %d", ok);
- if(ok)
- {
- new weapon;
- if(random(10) > 6) weapon = CSW_M3; // 30 %
- else weapon = CSW_MAC10; // 70 %
- client_print(id, print_chat, "Entite placee : %d", SpawnArmouryEntity(weapon, Origin));
- }
- }
- SearchOriginInfoTarget(Float:Origin[3])
- {
- new ent;
- new count;
- new Float:OriginInfoTarget[MAX_INFO_TARGET][3];
- while (ent = find_ent_by_class(ent, "info_target"))
- {
- entity_get_vector(ent, EV_VEC_origin, OriginInfoTarget[count]);
- count++;
- if(count == MAX_INFO_TARGET) break;
- }
- if(!count) return 0; // Pas d'entité Info Target
- new has = random(count);
- Origin[0] = OriginInfoTarget[has][0];
- Origin[1] = OriginInfoTarget[has][1];
- Origin[2] = OriginInfoTarget[has][2] + 64;
- return count;
- }
- SpawnArmouryEntity(CSW_WEAPONID, Float:vecOrigin[3], szCount[] = "1")
- {
- new iEnt = create_entity("armoury_entity");
- if(iEnt > 0 && cs_set_armoury_type(iEnt, CSW_WEAPONID))
- {
- DispatchKeyValue(iEnt, "count", szCount);
- entity_set_vector(iEnt, EV_VEC_origin, vecOrigin);
- DispatchSpawn(iEnt);
- return iEnt;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment