Page 1 of 1

Threading a Take/Give Weapons script!

Posted: Fri Sep 26, 2003 11:07 am
by The Jackal
I am trying another script. Its for a sniper only server. What I have done is script it so that when a player joins the server, he automatically joins a team and selects the sniper rifle.

I am stumped at the next step. I would like to take all his weapons after he dies and respawns and give him a set list. But my script does not work!

Code: Select all

$player thread _weapon

_weapon:

wait .1

 self waittill death 
 self waittill spawn
 self takeall
 wait .1
 self weapon weapons/springfield.tik 
 self useweaponclass rifle    
 self ammo rifle 50
 self weapon weapons/silencedpistol.tik
 wait .5

thread _weapon

end
I read several threads and the seem to do it this way.

Posted: Sat Sep 27, 2003 7:52 am
by jv_map
I don't think self waittill spawn works. :(

Posted: Sat Sep 27, 2003 7:55 am
by Major Pain
Take a look @ this:

/tutorials/player_weapons.php

Posted: Sat Sep 27, 2003 10:23 pm
by The Jackal
Major Pain that method does not work.

For some reason, "waittill spawn" and "waittill death" does nothing. Once I ignore them the script runs, but it takes all and gives specific weapon and keeps looping it.

Code: Select all

while(1)
{
wait .1
for(local.p = 1; local.p < $player.size+1;local.p++)
  {
   if ($player != NULL && $player[local.p].health > 0 $player[local.p].dmteam != "spectator" && $player[local.p].dmteam == "allies")
	{
//	waittill death 
// 	waittill spawn
 	$player[loca.p][local.p] takeall
 	wait .1
 	$player[loca.p] weapon weapons/springfield.tik 
 	$player[loca.p] useweaponclass rifle    
 	$player[loca.p] ammo rifle 50
 	$player[loca.p] weapon weapons/silencedpistol.tik
	}
 	if ($player != NULL && $player[local.p].health > 0 $player[local.p].dmteam != "spectator" && $player[local.p].dmteam == "axis")
	{
//	waittill death 
// 	waittill spawn
 	$player[loca.p][local.p] takeall
 	wait .1
 	$player[loca.p] weapon weapons/kar98sniper.tik 
 	$player[loca.p] useweaponclass rifle    
 	$player[loca.p] ammo rifle 50
 	$player[loca.p] weapon weapons/silencedpistol.tik
	}
  }
wait .1
}
end
I am stuck at getting the script to watch the player till he dies and respawns. HELP!

Posted: Sun Sep 28, 2003 7:43 am
by jv_map
waittill death for some reason may not be used on players, but it is easily replaced by:

while(self != NIL && isAlive self)
waitframe

The (self != NIL) check is to see whether the player is still on the server.

The waittill spawn is much more troublesome though. I've only found one effective way to do so, which is by glueing a very small trigger to every player. When this trigger is triggered, this is a proof the player is in the game.

Posted: Sun Sep 28, 2003 5:45 pm
by The Jackal
Can you give me an example script of the kind of trigger ? Because the script requires a "waittill spawn" effect workaround.

Posted: Mon Sep 29, 2003 4:24 pm
by jv_map
Instead of self waittill spawn type self waitthread player_join_game

Code: Select all

player_join_game:
	local.trigger = spawn trigger_multiple
	local.trigger setsize ( -16 -16 -16) (16 16 16)
	local.trigger glue self
	while(1)
	{
		local.trigger waittill trigger
		if(parm.other == self)
			break
		waitframe
	}
	local.trigger remove
end
(quoted from global/jv_mp_players.scr <-- included in bots scripts)