Client Kill Help :-)

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
User avatar
The Jackal
Sergeant Major
Posts: 101
Joined: Wed May 07, 2003 10:09 am
Contact:

Client Kill Help :-)

Post by The Jackal »

OK OK - I know I am about to get banned for posting all my noob scripts. But a guy's gotta practice. :lol:

This script is supposed to give admin KILL power over clients. I know there is MOHAA CI w/ MaM scripts that does that. But where is the fun in just using someone else's script?

Please tell me what I did wrong. Here is the killer script:

Code: Select all

_start:

level waittill spawn

setcvar "clientkill" " "

local.playerind = getcvar "clientkill"

while(1)
{
wait .1

for(local.p = 1; local.p < $player.size+1;local.p++)
	{
	if($player[local.p].health > 0 && $player[local.p].dmteam != "spectator" && $player[local.p] == local.playerind ) 
		{
		 $player[local.p] stufftext ("kill")
		 wait .5
		 $player[local.p] iprint "You Have Been Eliminated By The Host"
		 wait .1
		 setcvar "clientkill" " "
		}
		else
		{
		 // I may need this?
		}

	}

wait (1)
}
end
Thanks again. Don't forget to look for my other noob scripts, that I posted. :P

I wish I could help some people in this forum. But I am really new to scripting. I try to help however I can at the mohadmin forum. Just FYI. :shock:
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

if(... && $player[local.p] == local.playerind)

should be

if(... && local.p == local.playerind)

but that's a bad solution :wink:

Better just kill $player[local.p] :wink:
Image
User avatar
The Jackal
Sergeant Major
Posts: 101
Joined: Wed May 07, 2003 10:09 am
Contact:

Post by The Jackal »

Well that did not work. Made sense, but something else is screwed (can I use that word?). Basically I know that the client number that I will enter into the cvar will differ from that player number array by 1 - since 0 is not a valid player array. But I could've fixed that after, by using

Code: Select all

 local.victim = local.p-1
The problem I am getting now, is that when I enter the client number into the cvar from the console, it does zip. It does not even cycle thru the script and reset the cvar to null.

I am open to better ideas on how to kill the client via a console command. I like my little script, so I could use the help to show where I am straying.

Here is what it looks like now:

Code: Select all

_start:

level waittill spawn

setcvar "clientkill" " "

while(1)
{
wait .1

for(local.p = 1; local.p < $player.size+1;local.p++)
   {
   local.victim = local.p-1
   if($player[local.p].health > 0 && $player[local.p].dmteam != "spectator" && local.victim == (getcvar (clientkill)) )
      {
       $player[local.p] stufftext ("kill")
       wait .5
       $player[local.p] iprint "You Have Been Eliminated By The Host"
       wait .1
       setcvar "clientkill" " "
      }
      else
      {
       // I may need this?
      }

   }

wait (1)
}
end
User avatar
The Jackal
Sergeant Major
Posts: 101
Joined: Wed May 07, 2003 10:09 am
Contact:

RE:

Post by The Jackal »

Scorpio Midget at TMT give me the following script. i tried it and it presents the same issue as mentioned above. It does not cycle thru script.

Code: Select all

_start:
 
level waittill spawn
 
setcvar "clientkill" ""
 
while(1) 
{                                     // Why are there two WHILE statements?
 
while (1)
{
	wait 1
 
	
	local.cvar = getcvar "clientkill"
	if (local.cvar!="")
	{
	  local.clientkill = int (local.cvar)
 
	  if (local.clientkill>=0 && local.clientkill<$player.size)
 break
	}
}
 
	local.p=local.clientkill+1;
 
	local.player = $player[local.p];
 
	if(local.player.health > 0 && local.player.dmteam != "spectator") 
	{
		 // player commits suicide
		 local.player stufftext ("kill")
 
		 wait .5 // wait a bit
 
		 local.player iprint "You Have Been Eliminated By The Host"
	} 
 
	// reset cvar
	setcvar "clientkill" ""
}
end
His script is way cooler. But the transmission is broken somewhere.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Both scripts are needlessly complicated, always try to keep your code as simply and tidy as possible.

Example:

Code: Select all

main:
  while(1)
  {
    if(getcvar clientkill != "")
    {
      local.p = int(getcvar clientkill) + 1
      $player[local.p] hurt 100
      setcvar clientkill "" // don't kill twice
    }
    waitframe
  }
end
There is however no way to tell which player will be killed this way :?. This is a limitation of what you can do with the mohaa scripting language without major work-arounds.
Image
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

The Jackal wrote:but something else is screwed (can I use that word?).
Sure, you don't have to be excessively polite here. Just respect others as you go and you should be pretty ok. :) See forum rules if in doubt :wink:
Image
Post Reply