Give players another weapon when they respawn?

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
TriggerHappy
Private
Posts: 6
Joined: Sun May 21, 2006 9:09 pm

Give players another weapon when they respawn?

Post by TriggerHappy »

Hi again guys, I've searched through the forums but all the scripts I've found don't seem to work. Heres the deal, I want to give players another weapon (in addition to the one they choose) when they respawn. The problem I'm having is it'll either take their weapon away from them or just not give them the new weapon. How do I script it so for example the player chooses an MG, then gets given a sniper rifle too? I want this to work every time they respawn.

Thanks in advance :)
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

Search again, scripts like this have been done numerous times and I'm positively sure they work. ;)
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
Green Beret
Major General
Posts: 746
Joined: Mon Apr 19, 2004 12:21 pm
Contact:

Post by Green Beret »

Jus sumtin from the top of my head, But Like rookie said, Theres plenty of weapon scripts laying around, Im pretty sure Elgan's Admin Pro had a weapon limiter in it :wink:

Code: Select all

add_weapon:

while(1)
{

for(local.i = 1;local.i <= $player.size;local.i++)
local.team = local.player.dmteam

if(local.team == "axis")
{

level.player[local.team] item weapons/kar98.tik

}
else
{

level.player[local.team] item weapons/kar98.tik

}

//level.player[local.team] iprint "weapon givin"

while (isAlive(level.player[local.team]) && level.player[local.team].dmteam == local.team)
waitframe

level.player[local.team] = NULL
}
}
end
Image
TriggerHappy
Private
Posts: 6
Joined: Sun May 21, 2006 9:09 pm

Post by TriggerHappy »

Thank you but I've checked loads of those scripts and neither those nor this one works with my map. Heres the deal, I'm converting M1|1 to multiplayer, and whenever I cock up the script somehow all the actors and clips appear back in the map. I'll show you where I placed that code, perhaps someone could tell me what I'm doing wrong?

Code: Select all

main: //TRIGGER WAS HERE

	//SETTING GAMETYPE
	setcvar "g_gametypestring" "{=Thilly=} Team Deathmatch"
	
    setcvar "g_obj_alliedtext1" "Allies"
    setcvar "g_obj_alliedtext2" "Storm the Fort"
    setcvar "g_obj_alliedtext3" ""

    setcvar "g_obj_axistext1" "Axis"
    setcvar "g_obj_axistext2" "Defend this position"
    setcvar "g_obj_axistext3" ""

    setcvar "g_scoreboardpic" "m1l1"
    
    //setcvar "g_fraglimit" "100"
    
    setcvar "g_gametype" "2"
    
 
    level.dmroundlimit = 15 // round time limit in minutes
    level.clockside = kills // set to axis, allies, kills, or draw

    
    if(level.roundbased)
    {
    // set the parameters for round based match
    level.dmrespawning = 1 // 1 or 0
    level.dmroundlimit = 15 // round time limit in minutes
    level.clockside = kills // set to axis, allies, kills, or draw
    }	

//AXIS SPAWN


//ALLIES SPAWN


removeclass actor

	$door notsolid
	exec global/exploder.scr
	exec global/loadout.scr "maps/m1l1.scr"
	$newtruckclip notsolid
	$temptruck1 notsolid
	$temptruck2 notsolid
	exec global/disc.scr $door_left
	exec global/disc.scr $door_right
	$hahaha notsolid
	$hahaha notsolid
	$truckclip notsolid
	$truckclip2 notsolid
	$deadtruck notsolid
	$ending_save_player notsolid


level waittill prespawn


    //*** Precache Dm Stuff
    exec global/DMprecache.scr
    exec global/exploder.scr
    exec global/loadout.scr "maps/m1l1.scr"
    level.script = "maps/m1l1.scr"
    exec global/door_locked.scr :: lock
    exec global/ambient.scr m1l1
    thread global/exploder.scr::main
    
    	$firstguy delete
	$clippy notsolid
	$hahaha delete
	$truckclip delete
	$truckclip2 delete
	$deadtruck delete
	
level waittill spawn

thread hello 

thread add_weapon //CALLS WEAPON THREAD


	level.flags[ridecomplete] = 0
	level.glueplayer = 1


	$newtruckclip hide
	$toss hide
	$toss notsolid
	$temptruck1 delete
	$temptruck2 delete
	$door solid
	$door disconnect_paths
	$player stufftext "tmstartsound/music/mus_03c_suspense.mp3"
	

level waittill roundstart

end

hello: 
wait 10
iprintln "SP Conversion Mod by {=Thilly=}TriggerHappy" 
wait 110 
thread hello
end

add_weapon: //ADDING WEAPON CODE

while(1) 
{ 

for(local.i = 1;local.i <= $player.size;local.i++) 
local.team = local.player.dmteam 

{if(local.team == "axis") 
{ 

level.player[local.team] item weapons/kar98.tik 

} 
else 
{ 

level.player[local.team] item weapons/kar98.tik 

} }

level.player[local.team] iprint "weapon givin" 

while (isAlive(level.player[local.team]) && level.player[local.team].dmteam == local.team) 
waitframe 

level.player[local.team] = NULL 
} 
} 
end



end
Am I putting it in the wrong place? Wherever I move it to it doesn't seem to work.
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

That might not be the best example. ;) It's got a couple of errors. Try this one:

Code: Select all

add_weapon: //ADDING WEAPON CODE
   while(1) {
      for(local.i = 1;local.i <= $player.size;local.i++) {
         local.player = $player[local.i]
         if (local.player.hasrifle)
            continue
         local.player.orig_team = local.player.dmteam
         if(local.player.dmteam == "axis")
            local.player item weapons/kar98.tik
         else
            local.player item weapons/m1_garand.tik
         local.player.hasrifle = 1
         local.player iprint "You have been given a rifle." 1 // 1 makes it appear in white and make a click sound
         local.player thread wait_till_dead
      }
   }
end

wait_till_dead:
   while (isAlive(self) && self.dmteam == self.orig_team)
      waitframe
   if (self) // this prevents NULL/NIL listener errors
      self.hasrifle = 0
end
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
User avatar
hogleg
General
Posts: 1577
Joined: Tue Sep 09, 2003 5:23 pm
Location: Down South Hillbilly Country

Post by hogleg »

Not sure if this is what your looking for but its a good mod
http://www.modtheater.com/forum/showthread.php?t=28399
"all the governments in the world are corrupt and in the hands of the Illuminati"
Post Reply