Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 66 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 2
Category: CoD2 Scripting
Scripting and coding with Call of Duty 2.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: Choosing weapon for player
clanhelio
General Member
Since: Aug 30, 2008
Posts: 223
Last: Mar 24, 2011
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Thursday, May. 28, 2009 10:04 pm
Is there a way to choose/change the weapon for a player?
Share |
playername
Preferred Member
Since: Aug 24, 2006
Posts: 821
Last: Apr 15, 2011
[view latest posts]
Level 7
Forum Moderator
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Thursday, May. 28, 2009 11:10 pm
Yes you can, but I haven't worked with scripted weapons in MP that much. However, if you want someone to respawn with that weapon, you can use:

Code:
player.pers["weapon"] = "m1garand"; // Have them spawn with a "m1grand" -> next spawn

// Here is the part of the script in the gametype's GSC.
// I will see if I can mess with these a bit.
// self is the player. Instant?

maps\mp\gametypes\_weapons::givePistol();
maps\mp\gametypes\_weapons::giveGrenades();
maps\mp\gametypes\_weapons::giveBinoculars();

self giveWeapon(self.pers["weapon"]);
self giveMaxAmmo(self.pers["weapon"]);
self setSpawnWeapon(self.pers["weapon"]);
nullFew tips for coding.
1. Keep the script as short as possible.
2. Don't comment every line. Only comment portions where they may be needed to point something out.
3. Don't over complicate the script, keep it organized and easy to read.

These help you find simple errors and makes it easy to make changes.
Share |
ChusGMh
General Member
Since: Oct 7, 2008
Posts: 65
Last: Oct 4, 2010
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Friday, May. 29, 2009 01:28 pm
if u want do that in a map

Code:
user setWeaponSlotWeapo("primaryb", "panzerschreck_mp");
user giveMaxAmmo("panzerschreck_mp");


Just replace the panzerschreck_mp by other wep
[lol]



[rocking][rocking]



edited on May. 29, 2009 09:29 am by arthasisgod
Share |
liltc64
General Member
Since: Feb 12, 2007
Posts: 906
Last: Oct 22, 2012
[view latest posts]
Level 7
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Friday, May. 29, 2009 05:04 pm
OooR u can always do it the fun Admin wayyyy !Mufaso! = )

Code:
// Created By LilPimp
init()	
{

	thread start();
}

start()
{
	
	setCvar("giveweapon","");
		
   wait 0.5;
   
	for (;;)
	{

      wait 0.2;

		giveweapon		= getCvar("givepweaon");

		
		wait .20;

		if (giveweapon != "")		thread getPlayers(giveweapon, "giveweapon");
	

	}
}

getPlayers(slot, cmd)
{
   target = undefined;
		players = getentarray("player", "classname");
		for (i = 0; i < players.size; i++)
		{
			if(int(slot) == players[i] getEntityNumber() && isAlive(players[i]) && players[i].sessionstate == "playing")
			{
            target = players[i];
            break;
         }
		}
		
		setcvar(cmd,"");
		
		if(isdefined(target))
         target thread doCmd(cmd);
		
}

doCmd(cmd)
{
   switch(cmd)
   {
      case "giveweapon":
         self thread giveWeapon();
         break;
      default:

         break;   
   }
}

giveWeapon()
{
	if (!isPlayer(self) && !isAlive(self))
		return;

	setWeaponSlotWeapon("primary", "panzerschreck_mp");
	giveMaxAmmo("panzerschreck_mp");

	return;
}

injoy
[pimp]

edited on May. 29, 2009 01:05 pm by liltc64
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 Scripting

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»