Raised This Month: $ Target: $400
 0% 

[SOLVED]Best way to randomly choose a random player from the enemy team?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Infractem
Member
Join Date: Dec 2016
Old 01-26-2017 , 09:11   Re: [Snippet request]Best way to randomly choose a random player from the enemy team?
Reply With Quote #3

I made this code using the other parts of the plugin I am editing right now(cypis' killstreak plugin)
The thing is this bombs EVERY enemy on the map, I only need a single random enemy to get bombed. Can you help me with this one, please?

Code:
public CreatePredator2(id)
{
	new num, players[32];
	get_players(players, num, "gh");
	for(new a = 0; a < num; a++)
	{
		new i = players[a];
		if(get_user_team(id) != get_user_team(i))
			client_cmd(i, "spk sound/mw/predator_enemy.wav");
		else
			client_cmd(i, "spk sound/mw/predator_friend.wav");
	}
	set_task(5.0, "predator_continue", id)
	predator[id] = false;
}

public predator_continue(id)
{
	new num, players[32], PlayerCoords[3];
	get_players(players, num, "gh")
	for(new a=0; a<num; a++)
	{      
		if(!is_user_alive(players[a]) || get_user_team(players[a]) == get_user_team(id)) 
			continue;
		get_user_origin(players[a], PlayerCoords);
		
		new Float:LocVec[3]; 
		IVecFVec(PlayerCoords, LocVec); 
		create_ent(id, "bomb", "models/p_hegrenade.mdl", 2, 10, LocVec);
	}
}
Infractem is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:42.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode