AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Killing players in ESF (https://forums.alliedmods.net/showthread.php?t=24486)

Rixorster 02-24-2006 08:46

Killing players in ESF
 
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

Hawk552 02-24-2006 11:56

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.

Brad 02-24-2006 12:15

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 02-24-2006 12:22

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.

Hawk552 02-24-2006 12:29

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)     } }

Brad 02-24-2006 12:41

Er, I actually optimized it correctly. What I failed to do was hug the 'for' block. Not an optimizing error. More a syntax error. :)

Hawk552 02-24-2006 12:42

Yeah, whatever. Both of ours were wrong anyways so it doesn't really matter.

Brad 02-24-2006 12:48

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

@Rixorster:
Let us know how this works for you.

Hawk552 02-24-2006 12:52

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.*

Marticus 02-24-2006 14:03

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


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

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