Weapon Spawning For Teams (CoD1)

Have a question about modding, modelling or skinning? Have a tutorial to post? Post here!

Moderator: Core Staff

Post Reply
User avatar
Mox09
CJ Wannabe
CJ Wannabe
Posts: 22
Joined: April 9th, 2010, 8:01 am
Location: St louis
Contact:

Weapon Spawning For Teams (CoD1)

Post by Mox09 » December 9th, 2010, 10:42 am

Hey guys I need some help with my script. What i have so far is Both Weapons work when the player spawns but when you die and the round restarts it only give you "Primary"and not "PrimaryB" but if i do map_restart i do get both of them again. I'm going put the code under this.

If there is any easy way to make this work id love the help. :) Also this code does "WORK" and there is no crash but like i said above there something missing and all help would be appreciated.

Also where has nightmare been? i miss him :D

Code: Select all

spawnPlayer()
{
	self notify("spawned");
	   
	players = getentarray("player", "classname");
     for(i = 0; i < players.size; i++)

    if(players[i].pers["team"]=="axis")
	{
      players[i] thread German();
	}		
	else if(players[i].pers["team"]=="allies") 
	{
		players[i] thread American();
	}
	if(getcvar("scr_mxro_welcome0") != "")
	{  
	  self thread maps\mp\gametypes\_mxro::showWelcomeMessages();
	}  
	resettimeout();

	self.sessionteam = self.pers["team"];
	self.spectatorclient = -1;
	self.archivetime = 0;
	self.friendlydamage = undefined;

	if(isDefined(self.spawned))
		return;

	self.sessionstate = "playing";
		
	if(self.pers["team"] == "allies")
		spawnpointname = "mp_searchanddestroy_spawn_allied";
	else
		spawnpointname = "mp_searchanddestroy_spawn_axis";

	spawnpoints = getentarray(spawnpointname, "classname");
	spawnpoint = maps\mp\gametypes\_spawnlogic::getSpawnpoint_Random(spawnpoints);

	if(isDefined(spawnpoint))
		self spawn(spawnpoint.origin, spawnpoint.angles);
	else
		maps\mp\_utility::error("NO " + spawnpointname + " SPAWNPOINTS IN MAP");
	
	self.spawned = true;
	self.statusicon = "";
	self.maxhealth = 100;
	self.health = self.maxhealth;
	
	updateTeamStatus();
	
	if(!isDefined(self.pers["score"]))
		self.pers["score"] = 0;
	self.score = self.pers["score"];
	
	if(!isDefined(self.pers["deaths"]))
		self.pers["deaths"] = 0;
	self.deaths = self.pers["deaths"];
	
	if(!isDefined(self.pers["savedmodel"]))
		maps\mp\gametypes\_teams::model();
	else
		maps\mp\_utility::loadModel(self.pers["savedmodel"]);
	
	if(isDefined(self.pers["weapon1"]) && isDefined(self.pers["weapon2"]))
	{
	 	self setWeaponSlotWeapon("primary", self.pers["weapon1"]);
		self setWeaponSlotAmmo("primary", 999);
		self setWeaponSlotClipAmmo("primary", 999);

	 	self setWeaponSlotWeapon("primaryb", self.pers["weapon2"]);
		self setWeaponSlotAmmo("primaryb", 999);
		self setWeaponSlotClipAmmo("primaryb", 999);

		self setSpawnWeapon(self.pers["spawnweapon"]);
	}
	else
	{
		self setWeaponSlotWeapon("primary", self.pers["weapon"]);
		self setWeaponSlotAmmo("primary", 999);
		self setWeaponSlotClipAmmo("primary", 999);

		self setSpawnWeapon(self.pers["weapon"]);
	}

//	maps\mp\gametypes\_teams::givePistol();
//	maps\mp\gametypes\_teams::giveGrenades(self.pers["selectedweapon"]);
	
	if(self.pers["team"] == game["attackers"])
		self setClientCvar("cg_objectiveText", &"SD_OBJ_ATTACKERS");
	else if(self.pers["team"] == game["defenders"])
		self setClientCvar("cg_objectiveText", &"SD_OBJ_DEFENDERS");
		
	if(level.drawfriend)
	{
		if(self.pers["team"] == "allies")
		{
			self.headicon = game["headicon_allies"];
			self.headiconteam = "allies";
		}
		else
		{
			self.headicon = game["headicon_axis"];
			self.headiconteam = "axis";
		}
	}
}

American()
{
	self setWeaponSlotWeapon("primary", "mosin_nagant_mp");
	wait 0.01;
    self setWeaponSlotWeapon("primaryb", "kar98k_mp");
	self switchToWeapon(weapon);
	self giveMaxAmmo(weapon);
	wait 0.05;
	self setWeaponSlotAmmo("primary", 150);
	self setWeaponSlotClipAmmo("primary", 150);
	self setWeaponSlotAmmo("primaryb", 150);
	self setWeaponSlotClipAmmo("primaryb", 150);
	self.spawned = true;
	self.statusicon = "";
	self.maxhealth = 100;
	self.health = self.maxhealth;
//  self maps\mp\gametypes\_teams::givePistol();
//  self maps\mp\gametypes\_teams::giveGrenades(self.pers["selectedweapon"]);
}

German()
{
	self setWeaponSlotWeapon("primary", "kar98k_mp");
	wait 0.01;
	self setWeaponSlotWeapon("primaryb", "mosin_nagant_mp");
	self switchToWeapon(weapon);
    self giveMaxAmmo(weapon);
	wait 0.05;
	self setWeaponSlotAmmo("primary", 150);
	self setWeaponSlotClipAmmo("primary", 150);
	self setWeaponSlotAmmo("primaryb", 150);
	self setWeaponSlotClipAmmo("primaryb", 150);
	self.spawned = true;
	self.statusicon = "";
	self.maxhealth = 100;
	self.health = self.maxhealth;
//  self maps\mp\gametypes\_teams::givePistol();
//  self maps\mp\gametypes\_teams::giveGrenades(self.pers["selectedweapon"]);
}

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Weapon Spawning For Teams (CoD1)

Post by Drofder2004 » December 9th, 2010, 9:27 pm

What section of code defines "self.pers["weapon2"]"
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: No registered users and 37 guests