Raised This Month: $ Target: $400
 0% 

Killing players in ESF


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Rixorster
Senior Member
Join Date: Jul 2005
Old 02-24-2006 , 08:46   Killing players in ESF
Reply With Quote #1

Im stuck at one point, and im wondering, how can i kill all clients on the enemy team by using for example: .KillSpecial?
I was thinking about using user_kill, but i cant use it to kill all players on enemy team, cause with it i cant determine which players are enemies :S
__________________
You never know, what will happen the day after tomorrow...

+karma if i helped you!
Rixorster is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 02-24-2006 , 11:56  
Reply With Quote #2

Code:
stock kill_team(id) {     new iPlayers[32], iPlayersnum     get_players(iPlayers,iPlayersnum)     for(new iCount = 0;iCount <= iPlayersnum;iCount++)         if(get_user_team(id) != get_user_team(iPlayers[iCount]))             user_kill(iCount) }

That should kill everyone not on the same team as the id passed into the function.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 02-24-2006 , 12:15  
Reply With Quote #3

Alternately, if you want it to have a better chance of working and have it optimized a bit at the same time...

Code:
 stock kill_team(id) {     new myTeam = get_user_team(id)     new iPlayers[32], iPlayersnum     get_players(iPlayers,iPlayersnum,"a")     for(new iCount = 0;iCount <= iPlayersnum;iCount++)         otherID = iPlayers[iCount]         if(myTeam != get_user_team(otherID))             user_kill(otherID) }
Brad is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 02-24-2006 , 12:22  
Reply With Quote #4

If you want to get even craftier still... you can add the "e" flag in get_players() as well and pass in the name of the other team so that you don't have to do any checks within the loop itself.
Brad is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 02-24-2006 , 12:29  
Reply With Quote #5

Yeah, my bad, yours won't work either though Brad.

Mine had an error in the user_kill section, should have been iPlayers[iCount], but Brad optimized it (incorrectly). Here's a fixed version:

Code:
stock kill_team(id) {     new iTeam = get_user_team(id), iIndex     new iPlayers[32], iPlayersnum     get_players(iPlayers,iPlayersnum,"a")     for(new iCount = 0;iCount <= iPlayersnum;iCount++)     {         iIndex = iPlayers[iCount]         if(iTeam != get_user_team(iIndex))             user_kill(iIndex)     } }
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 02-24-2006 , 12:41  
Reply With Quote #6

Er, I actually optimized it correctly. What I failed to do was hug the 'for' block. Not an optimizing error. More a syntax error.
Brad is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 02-24-2006 , 12:42  
Reply With Quote #7

Yeah, whatever. Both of ours were wrong anyways so it doesn't really matter.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 02-24-2006 , 12:48  
Reply With Quote #8

I was just pointing out your false statement. No 'tude involved.

@Rixorster:
Let us know how this works for you.
Brad is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 02-24-2006 , 12:52  
Reply With Quote #9

Quote:
Originally Posted by Brad
I was just pointing out your false statement. No 'tude involved.

@Rixorster:
Let us know how this works for you.
Well I could correct you for using slang for probably the first time I have ever seen you do as such, but that would just serve no constructive purpose. *Ahem.*
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Marticus
Member
Join Date: Nov 2004
Old 02-24-2006 , 14:03  
Reply With Quote #10

Hawk, kindly stop being asinine. A strong statement was made and no effort was put forth to qualify the statement with factual evidence. I also would have been concerned, not because of my pride, but because it could be confusing to new people looking for code examples.

For the record, it is best to use good grammar when calling someone out for their blatant use of slang.

Best,
-Marticus
Marticus is offline
Reply



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 16:53.


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