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

Members Online

»
0 Active | 95 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: ZOMBIES!
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: Wednesday, Aug. 22, 2012 11:08 am
hello modsonline! this topic i want to cover EVERYTHING about zombies! woohoo!!![duh] all i ever see on these forums now are about these nooby questions on how do this for my zombie mod and how do i do that for a zombie mod. so zombies some how took this awesome course for cod2 and its now very popular i guess so let me and anyone else on modsonline help clear this all up for you from head to toe.

Question 1. how do i make virtual money!?

Answer 1. its as simple as making a variable, when the player first connects make a new thread named
Code:
self thread handleVars();
now the reason im saying make a new thread, especially named that. is because with zombies you're always making some new type of var somewhere down the road so lets keep it all neat and clean. in handleVars() its as simple as making this
Code:
handleVars()
{
	if(!isDefined(self.money)) // checks weather or not self.money is already defined. It shouldnt be... but cod can get weird sometimes so lets just make sure.
		self.money = 0; // making self.money = 0 on start because you dont want people starting off with money, IF you do then change 0 to what ever figure you want them have.
}

so technically we just made virtual money. but when you save this and go into your game you will see no difference. so now lets make it so when you get a kill your money will increment. now its as simple as doing this, go into your zom.gsc go find Callback_PlayerKilled(eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration) in this function is where EVERY death is handled. when you kill your self, code in that function plays. when you kill someone or they kill you code in that function plays. so go find somewhere in that function where it will say something like this
Code:

                                attacker.score++;
				teamscore = getTeamScore(attacker.pers["team"]);
				teamscore++;
				setTeamScore(attacker.pers["team"], teamscore);
				checkScoreLimit();

right there is where it gives the attacker a kill point, so lets edit it to say
Code:

                                attacker.score++;
				attacker.money += 200;
				teamscore = getTeamScore(attacker.pers["team"]);
				teamscore++;
				setTeamScore(attacker.pers["team"], teamscore);
				checkScoreLimit();

now the attacker is getting 200$ when he kills someone. you can change 200 to what ever you want its just a reasonable example. but now still... you go ingame your not going to see this working at all, yes it does work but because we have no huds displaying to us that it works it seems like it dosnt but it does. so lets make it pretty shall we? lets make a hud showing off it works, now for this i hate huds... i hate getting them to align just right on the screen so for this im going to take something from my own mod its pretty basic cause im a simple person and i like to get to the point. so first lets start of be precaching the string we are going to use for this hud. in your zom.gsc near the top of Callback_StartGameType() where you will see alot of things being precached that's where i like to add my custom precached strings just to be neat. so add in there this.
Code:
game["hud1_money"] = &"^1Money:";
precacheString(game["hud1_money"]);

so now time to make the hud. so lets make a thread coming from spawnplayer() in your zom.gsc lets make the name
Code:
self thread spawnHuds();
in this new thread we can add all new huds we may make in the future in that 1 new thread we have just made. okay so this is where im going to take a code i already have written and let you guys use it. you can edit the positioning to what ever you want this is just what i have from my mod that worked best for me. so now in spawnHuds() this is what your going to need to have
Code:
spawnHuds()
{
	self endon("disconnect");
	self endon("joined_spectators");
	
	if(!isDefined(self.moneyhud)) // checking if the hud is already defined, if not create this hud. its good to keep this because you dont want to be making 100's of these every time you spawn.
	{
		self.moneyhud = newClientHudElem(self);
		self.moneyhud.x = 520; 
		self.moneyhud.y = 280; 
		self.moneyhud.alignX = "left";
		self.moneyhud.alignY = "middle";
		self.moneyhud.sort = 1; 
		self.moneyhud.alpha = 1;
		self.moneyhud.fontScale = 1.2;
		self.moneyhud.archived = true;
		self.moneyhud setText(game["hud1_money"]); // this sets that text we made at the top already.
	}

	if(!isDefined(self.moneyVALUEhud)) // same as above pretty much but instead of a text we are going to be printing out the value of self.money
	{
		self.moneyVALUEhud = newClientHudElem(self);
		self.moneyVALUEhud.x = 565;
		self.moneyVALUEhud.y = 275;
	}

	while(1) // looping constantly to check the new value that self.money may be in time, there is a better way of going about this but this is what we are going to be using. like i said anyone can pitch in at any time to help with this.
	{
		wait(1.1);
		self.moneyVALUEhud setvalue(self.money); // prints out the value that self.money contains.
	}
}

now go ingame and you will see everything looks just delightful and working great, you connect you start with 0$ dollars, you get a kill you get 200$.
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: Wednesday, Aug. 22, 2012 11:58 am
Question 2. how do i make those cool abilitys\functions from quickmessages!?

Answer 2. well im not going to show you how to make a nuke or the terminator by pressing "v42" sorry im not making your mod for you, but im going to give you the right steps to getting there. so first off we need to make the buttons... okay so lets start off by getting the files we need! open up iw_06.iwd open the folder ui_mp and at the bottom ull find the .menu file named wm_quickmessage.menu now drag that to your mod your desktop what ever you want just get it out of iw_06.iwd in there you will see stock buttons that you will see normally ingame okay well right under
Code:

                itemDef
		{
			name			"window"
			visible			1
			rect			16 52 0 0
			origin			ORIGIN_QUICKMESSAGEWINDOW
			forecolor		1 1 1 1
			textfont		UI_FONT_NORMAL
			textscale		.24
			textaligny		8
			text			"@QUICKMESSAGE_3_RESPONSES"
			decoration
		}
		execKey "3" { close quickmessage; open quickresponses }
lets add your own button to open your own new menu. so now we should have something like this
Code:

                itemDef
		{
			name			"window"
			visible			1
			rect			16 52 0 0
			origin			ORIGIN_QUICKMESSAGEWINDOW
			forecolor		1 1 1 1
			textfont		UI_FONT_NORMAL
			textscale		.24
			textaligny		8
			text			"@QUICKMESSAGE_3_RESPONSES"
			decoration
		}
		execKey "3" { close quickmessage; open quickresponses }

		itemDef
		{
			name			"window"
			visible			1
			rect			16 52 0 0
			origin			ORIGIN_QUICKMESSAGEWINDOW
			forecolor		1 1 1 1
			textfont		UI_FONT_NORMAL
			textscale		.24
			textaligny		8
			text			"4. Abilitys"
			decoration
		}
		execKey "4" { close quickmessage; open abilitys }
name it what ever you want, the way i named it will say ingame console unlocalized string da da da dont worry its not a big deal it will not crash your server or mess with anything maybe in the long run i dont know but personally been doing this for ever and never ran into 1 problem with it but if you are worried you can localize it the same way they do it but learn localizing properly somewhere else not here for i dont care and its kinda common sense on how to do it. now back on topic! we now need to make a new menu named abilitys now its as simple as make a copy of that wm_quickmessage.menu rename it to abilitys.menu and in the file all you need is this.
Code:
#define ORIGIN_QUICKMESSAGETAB			32 224

#define ORIGIN_QUICKMESSAGEWINDOW		32 256


{
	menuDef
	{
		name			"abilitys"
		visible			0
		fullscreen		0
		rect			0 0 640 480
		focuscolor		1 1 1 1
		disablecolor		0 0 0 0
 		style			WINDOW_STYLE_EMPTY

		onOpen
		{
			setDvar cl_bypassMouseInput "1"
		}
		onClose
		{
			setDvar cl_bypassMouseInput "0"
		}

// WINDOW BACKGROUND
		itemDef
		{
			name			"window_background"
			visible			1
			rect			0 0 224 192
			origin			ORIGIN_QUICKMESSAGEWINDOW
			style			WINDOW_STYLE_FILLED
			forecolor		1 1 1 1
			backcolor		0 0 0 0.7975
			decoration
		}
	
// WINDOW LINES
		itemDef
		{
			name			"window_lines"
			visible			1
			rect			3 0 2 187
			origin			ORIGIN_QUICKMESSAGEWINDOW
			style			WINDOW_STYLE_FILLED
			backcolor		1 1 1 .125
			decoration
		}
		itemDef
		{
			name			"window_lines"
			visible			1
			rect			219 0 2 187
			origin			ORIGIN_QUICKMESSAGEWINDOW
			style			WINDOW_STYLE_FILLED
			backcolor		1 1 1 .125
			decoration
		}
		itemDef
		{
			name			"window_lines"
			visible			1
			rect			5 0 214 2
			origin			ORIGIN_QUICKMESSAGEWINDOW
			style			WINDOW_STYLE_FILLED
			backcolor		1 1 1 .125
			decoration
		}
		itemDef
		{
			name			"window_lines"
			visible			1
			rect			3 187 218 2
			origin			ORIGIN_QUICKMESSAGEWINDOW
			style			WINDOW_STYLE_FILLED
			backcolor		1 1 1 .125
			decoration
		}

// TITLE
		itemDef
		{
			name			"title"
			visible			1
			rect			0 0 224 32
			origin			ORIGIN_QUICKMESSAGETAB
			style			WINDOW_STYLE_FILLED
			forecolor		1 1 1 1
			backcolor		0 0 0 0.7975
			type			ITEM_TYPE_TEXT
			text			"@QUICKMESSAGE_QUICK_MESSAGE"
			textfont		UI_FONT_NORMAL
			textscale		.24
			textalignx		112
			textaligny		24
			textalign		ITEM_ALIGN_CENTER
			decoration
		}
		itemDef
		{
			name			"title_quickmessage_gray"
			visible			1
			rect			3 3 218 29
			origin			ORIGIN_QUICKMESSAGETAB
			style			WINDOW_STYLE_FILLED
			backcolor		1 1 1 .125
			decoration
		}

		itemDef
		{
			name			"window"
			visible			1
			rect			16 20 0 0
			origin			ORIGIN_QUICKMESSAGEWINDOW
			forecolor		1 1 1 1
			textfont		UI_FONT_NORMAL
			textscale		.24
			textaligny		8
			text			"1. Custom Command!"
			decoration
		}
		execKey "1" { scriptMenuResponse "customcommand1"; close abilitys; }
	

		itemDef
		{
			name			"window"
			visible			1
			rect			16 68 0 0
			origin			ORIGIN_QUICKMESSAGEWINDOW
			forecolor		1 1 1 1
			textfont		UI_FONT_NORMAL
			textscale		.24
			textaligny		8
			text			"@QUICKMESSAGE_ESC_EXIT"
			decoration
		}
	}
}
notice i only dummed it down to 1 command and i added scriptMenuResponse instead of opening a new menu? you dont need to have 1 custom command have as many as u want and can fit but for this example im just showing 1. so now lets put some functionality behind this button and precache the new menu you just made! open iw_07.iwd go to maps\mp\gametypes and grab the _menus.gsc out to your mod or desktop like before just take it out of the iw_07.iwd. in _menus.gsc is where just about every stock menu is handled. so right off the bat when you open up _menus.gsc you will see on line 3 to 11 they're already precaching some stock menus. because im a neat fella lets add our custom menu there. also have you ever experienced the problem where you made this awesome menu but ingame you go to open the menu and you just get a blank screen??? thats caused by 1 to 2 problems. 1 you didnt precache your menu. 2 you might have a small error in your .menu file. you can find the second error in console most the time. back to the topic! now lets precache you should have something like this
Code:
game["menu_ingame"] = "ingame";
	game["menu_abilitys"] = "abilitys";
	game["menu_team"] = "team_" + game["allies"] + game["axis"];
	game["menu_weapon_allies"] = "weapon_" + game["allies"];
	game["menu_weapon_axis"] = "weapon_" + game["axis"];

	precacheMenu(game["menu_ingame"]);
	precacheMenu(game["menu_abilitys"]);
	precacheMenu(game["menu_team"]);
	precacheMenu(game["menu_weapon_allies"]);
	precacheMenu(game["menu_weapon_axis"]);
okay so now that you have that out of your way lets make some functionality! so now if you scroll down to around line 84 you will see something that should be saying this
Code:
if(response == "endgame")
		{
			if(level.splitscreen)
				level thread [[level.endgameconfirmed]]();
				
			continue;
		}
okay now were doing something similar only we are going to look for the response named "customcommand1" so right under that we can have something like this
Code:
if(response == "endgame")
		{
			if(level.splitscreen)
				level thread [[level.endgameconfirmed]]();
				
			continue;
		}
		
		if(response == "customcommand1")
		{
			iprintlnbold("THAT TICKLES!");
		}
now you have just made a button that will open up a new menu by pressing v4, and inside that new menu you made a button that will have functionality behind it to print on your screen saying "THAT TICKLES!" [thumbs_up]

NOW TIME FOR A BONUS!!![eek][eek]

i know, shocking what could this bonus possibly be!?[rocking] well now lets take a look into _menus.gsc again and lets pretend we did the preaching but we didnt add that functionality for that button just yet. if you scroll down to the bottom of _menus.gsc you will see something like this
Code:
else if(!level.xenon)
		{
			if(menu == game["menu_quickcommands"])
				maps\mp\gametypes\_quickmessages::quickcommands(response);
			else if(menu == game["menu_quickstatements"])
				maps\mp\gametypes\_quickmessages::quickstatements(response);
			else if(menu == game["menu_quickresponses"])
				maps\mp\gametypes\_quickmessages::quickresponses(response);
		}
in there you can add something of your own. now this isnt to important infact you dont even need to do this but... come on lets be neat and keep our codes organized together and easy to find. so instead of adding that functionality inside _menus.gsc we can have our own little block of functionality inside the file named _quickmessages.gsc this way our functions are organized when we add more and easyer to find everything. okay so lets start off by adding our own thread in that little block of code something like this
Code:
else if(!level.xenon)
		{
			if(menu == game["menu_quickcommands"])
				maps\mp\gametypes\_quickmessages::quickcommands(response);
			else if(menu == game["menu_quickstatements"])
				maps\mp\gametypes\_quickmessages::quickstatements(response);
			else if(menu == game["menu_quickresponses"])
				maps\mp\gametypes\_quickmessages::quickresponses(response);
			else if(menu == game["menu_abilitys"])
				maps\mp\gametypes\_quickmessages::abilitys(response);
		}
okay now we got that now open that iw_07.iwd again if you dont have it opened already and go to maps\mp\gametypes and get that _quickmessages.gsc out of there! open it up and for me i like to start at the bottom when ever im adding something new to a stock .gsc but thats just me. so now when your scrolling down to that dreadful bottom of the
Code:
_quickmessages.gsc
you may see these things on cases. its just like saying if(response == "rawr") but its more organized and just... better if anyone else can elaborate more on that that would be much appreciated. so were at the bottom lets add our own little casing.
Code:
abilitys(response)
{
	switch(response)		
	{
    case "customcommand1":
		iprintlnbold("THAT TICKLES!");
         	break;
				
    default: // not really needed... but im a very better safe then sorry kind of guy
		break;   
	}
}
woohoo! thats all done i just also would like to add that if your button is going to be more then saying "THAT TICKLES" and have a few more lines of code it would be easyer if you make a new thread instead of having it all under case "customcommand1" that way everythings more neat like im always about and just... yeah. that wraps up that question thank you[wave]

------------------------
i will be answering more questions later today iv just been awake since 4am and im going out for some dunkin donuts to keep my self awake and i just remembered CSGO should be on the xbox right this sec and im an xbox fan so i must get that [pimp]
edited on Aug. 22, 2012 05:01 am by liltc64
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Wednesday, Aug. 22, 2012 12:08 pm
Howto: have one item in your quickmessage menu for both the zom and huntershop.

First off, we need a dummy-menu file. Put this into it:

Code:

#include "ui_mp/menudef.h"
{
	menuDef
	{
		name			"zomshop_open"
		rect			0 0 640 480
		focuscolor		GLOBAL_FOCUSED_COLOR
		style			WINDOW_STYLE_EMPTY
		blurWorld		5.0
		onOpen 
		{
			uiScript openMenuOnDvar ui_zomshop_team allies zomshop_allies;
			uiScript openMenuOnDvar ui_zomshop_team axis zomshop_axis;
			close zomshop_open;
		}
	}
}

If we now open this menu file, it will open another menu depending on a certain cvar. So, now we gotto add the zomshop-opener to the quickmessage menu:
Code:


		itemDef
		{
			name			"window"
			visible			1
			rect			16 68 0 0
			origin			ORIGIN_QUICKMESSAGEWINDOW
			forecolor		1 1 1 1
			textfont		UI_FONT_NORMAL
			textscale		.24
			textaligny		8
			text			"4. Shop"
			decoration
		}

		execKey "4" { close quickmessage; open zomshop_open}


And set the cvar on spawn:
Code:

self setclientcvar("ui_zomshop_team",self.pers["team"]);


Thats all.

Of course, people can change their own cvars. Thats why we'd need a check when people buy stuff too. I wont explain that, but its pretty straightforward.
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: Wednesday, Aug. 22, 2012 02:33 pm
before i start on a new question i would like to build off what iznogod is saying. you ever go into those zombie servers and you want to use those cool abilitys when your a hunter so you hit V to open that quickmessage menu. well... most servers you will see they still have it showing lets say "5. Zombie Abilitys" and your a hunter you press v5 it tells you "sorry thats only for zombies" well thats stupid... why not just hide that and get that out of the way and make it more useful and less spam for the hunters[banghead]. so yes you can do what iznogod just posted but personally thats not the way i go about it. so this right here will kind of build off Question 2.

so lets say you followed along on that last post i put that talked about cool abilitys and functions for quickmessages. if you open your wm_quickmessage.menu again and go back to this
Code:
itemDef
		{
			name			"window"
			visible			1
			rect			16 52 0 0
			origin			ORIGIN_QUICKMESSAGEWINDOW
			forecolor		1 1 1 1
			textfont		UI_FONT_NORMAL
			textscale		.24
			textaligny		8
			text			"@QUICKMESSAGE_3_RESPONSES"
			decoration
		}
		execKey "3" { close quickmessage; open quickresponses }

		itemDef
		{
			name			"window"
			visible			1
			rect			16 52 0 0
			origin			ORIGIN_QUICKMESSAGEWINDOW
			forecolor		1 1 1 1
			textfont		UI_FONT_NORMAL
			textscale		.24
			textaligny		8
			text			"4. Abilitys"
			decoration
		}
		execKey "4" { close quickmessage; open abilitys }
well to make this now lets say were only going to make this appear for the hunters. so what we change is text to dvar.
Code:
itemDef
		{
			name			"window"
			visible			1
			rect			16 52 0 0
			origin			ORIGIN_QUICKMESSAGEWINDOW
			forecolor		1 1 1 1
			textfont		UI_FONT_NORMAL
			textscale		.24
			textaligny		8
			text			"@QUICKMESSAGE_3_RESPONSES"
			decoration
		}
		execKey "3" { close quickmessage; open quickresponses }

		itemDef
		{
			name			"window"
			visible			1
			rect			16 52 0 0
			origin			ORIGIN_QUICKMESSAGEWINDOW
			forecolor		1 1 1 1
			textfont		UI_FONT_NORMAL
			textscale		.24
			textaligny		8
			dvar			"abilitys"
			decoration
		}
		execKey "4" { close quickmessage; open abilitys }
see that difference? so as of right now if you saved this went ingame you wouldnt even see the text "4. Abilitys" cause as of now its a cvar waiting to be filled in but you can still press v4 and it would open. so open up your zom.gsc go to the function spawnplayer and to me for this would work best right under where it says
Code:
self giveWeapon(self.pers["weapon"]);
	self giveMaxAmmo(self.pers["weapon"]);
	self setSpawnWeapon(self.pers["weapon"]);
put what iznogod said in his post but put it like this instead.
Code:
if(self.pers["team"] == "allies") // only allies/hunter players will be able to see this text. you can change it to "axis" if you want axis/zombies to see the text
		self setclientcvar("abilitys", "4. Abilitys);
now where almost done. now you see we made it so only hunters can see the text but still even though zombies cant see the text they can still access the menu and thats not good so lets block them out of that. so lets say you didnt follow the bonus i put and you took the easy route out well then open up _menus.gsc again and you should have
Code:
if(response == "customcommand1")
		{
			iprintlnbold("THAT TICKLES!");
		}

well its as simple as doing this
Code:
if(response == "customcommand1")
	{
        if(self.pers["team"] == "axis")
			return;
			
		iprintlnbold("THAT TICKLES!");
	}

and that will do it! blocks axis from seeing the text and blocks them from gaining access to the menu. and i am sorry if the tabbing seems off on the website i use notepad++ and it looks fine in there. always be neat with your codes and tab correctly!

almost forgot to add, if you did follow along with the bonus! sorry almost forgot about you guys! so anyways its pretty much the same just put this
Code:
abilitys(response)
	{
		if(self.pers["team"] == "axis")
			return;
			
		switch(response)		
		{
		case "customcommand1":
			iprintlnbold("THAT TICKLES!");
				break;
					
		default: // not really needed... but im a very better safe then sorry kind of guy
			break;   
		}
	}
[thumbs_up]
edited on Aug. 22, 2012 07:33 am by liltc64

yes another edit. i just spotted something that can go wrong. if you are using this code here READ!
Code:
if(response == "customcommand1")
	{
        if(self.pers["team"] == "axis")
			return;
			
		iprintlnbold("THAT TICKLES!");
	}
do not use it that way. the bonus code is correct you can do that. but for this, that return will kill alot of the other functions that are waiting to be used. so i would simply just fix it to this
Code:
if(response == "customcommand1")
	{
        if(self.pers["team"] == "allies")
			iprintlnbold("THAT TICKLES!");
	}
that way it will only print out "THAT TICKLES" for allies players. so it works basically the same but better since this way it wont kill off the other functions and if axis were to try to use the code they still couldnt.
edited on Aug. 22, 2012 07:40 am by liltc64
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: Thursday, Aug. 23, 2012 03:22 pm
okay so far we have covered how do you make virtual money and how to make functions work from quickmessages and how to make it only work for hunters/zombies. lets get started on something else i see once a while.

Question 3. how do i buy weapons in my custom map???

Answer 3. its as simple as this, if you have been following along you should have virtual money already setup in your mod so that part is done and good. now in your map place a Trigger_Use_touch where you want to buy the weapon from and have it selected still and press N now right here you can make the value anything you want what im doing is just an example. so for Key put targetname for Value put buyweap. now save your map compile it and im assuming you already know how to make your maps .gscs and all that. so when you do compile put that compiled version in your .iwd and open up your maps .gsc. so open that up and from main() id like you to add thread buyweap(); make a new thread now named buyweap() and in there you want to be looking for, has the buyweap been triggered??? if so see if they have enough money for the weapon and give him the weapon if so. if not tell him not enough money and give him nothing. or does he have the weapon already??? then just give him ammo. so this is what i came up with in buyweap()
Code:
buyweap()
{
	buyweap = getent("buyweap", "targetname");
	
	while(1) // looping to check if the player is pressing trigger or not
	{
		buyweap waittill("trigger", shopper); // if the player has activated the trigger
		
		item = "kar98k_mp"; // assuming they want to buy a kar98k

		wepcurrent = shopper getcurrentweapon(); // checks what weapon you currently have in your hands
		weapon1 = shopper getweaponslotweapon("primary"); // checks whats in your primary slot
		weapon2 = shopper getweaponslotweapon("primaryb"); // checks whats in your secondary slot
		notwep = !(shopper hasweapon("kar98k_mp")); // checks if the player dosnt have that weapon

		if(shopper.money >= 500 && wepcurrent == item && shopper.pers["team"] == "allies") // checks does the player have 500$ to buy the weapon? checks if the players current weapon is the same as the one on the wall and checks if they are a hunter
		{
			if(wepcurrent == weapon1)
			{
				currentslot = "primary";
			}
			else
			{
				currentslot = "primaryb";
			}
				
			wepammo = shopper getweaponslotammo(currentslot);
				
			shopper.money-=500;
			shopper givemaxammo(wepcurrent);
		}
		else if(shopper.pers["team"] != "allies") // checks if your not a hunter
		{
			shopper iprintln("^1This Can Only Be Used By The Hunters"); // and if not then print a msg telling them to so
		}
		else if(shopper.money < 500 && shopper.pers["team"] == "allies") // checks if your a hunter and you dont have enough money
		{
			shopper iprintln("^1You Do Not Have Enough Money To Purchase This Item");
		}
		else if(notwep && shopper.pers["team"] == "allies" && shopper.money >= 500) // checks if the player dosnt have the weapon on the wall and if hes a hunter and if he has enough money to buy the weapon
		{
			if(wepcurrent == weapon1)
			{
				currentslot = "primary";
			}
			else
			{
				currentslot = "primaryb";
			}

			shopper.money-=500;
			shopper setweaponslotweapon(currentslot, item);
			shopper SwitchToWeapon("kar98k_mp");
		}
	}
}
so that should wrap that up thank you [wave]
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, Aug. 24, 2012 02:05 pm
Question 4. how do i make a secret passage way for only hunters??

Answer 4. honestly their are many ways to going about this. lets say you have a secret door infront of you and your a hunter and you want to go threw it. well you could put a Trigger_Multiple infront of the door and have it check has a hunter touched it? if so make the door open or make it notsolid. but there are problems. what if a zombie comes walking in behind you??? what if you do the notsolid way well still a zombie can come behind you or even worse when you have to make that wall or door solid again you could get stuck in the wall or door. so im going to tell you guys how to do this the best way possible. which is a simple teleport.

so lets begin. in your map you want to put a Script_Origin where you want the player to teleport to. now you want to have a trigger somewhere where you want the hunter to activate to get to this secret room. so it really dosnt matter what kind of trigger you actually use so just use the one that best suits your map. now you have those down in your map select the Script_Origin and press N and for the Key put targetname and for the Value put secretorg. now remember you can put that Value what ever name you want. this is just what im putting it as. and now select the trigger and press N and for the Key put targetname and for the Value put trigsecret. now save and compile put the compiled version in your .iwd and open up your maps main .gsc. when thats opened you should have main() inside there make a new thread, lets name it thread secretRoom();. now this is what i put for secretRoom()
Code:
secretRoom()
{
	org = getent("secretorg","targetname");	// makes org = to the entity secretorg which is the script_origin inside the map
	trig = getent("trigsecret","targetname"); // makes trig = to the entity trigsecret which is the trigger inside the map
	
	while(true)
	{
		trig waittill("trigger", player); // waits till the trigger is activated
		if(player.pers["team"] == "allies") // checks if the player is a hunter
		{
			player setorigin(org.origin); // teleports the player into the secret room
			player iprintln("TADA!"); // TADA!
		}
	}
}
now if you didnt want it just set for hunters you can change "allies" to "axis" and it will make it for zombies. or if u wanted it for everyone its as simple as getting rid of that line of code along with its brackets. and that will do it for Question 4. Thank you[thumbs_up]
Share |
antocro
General Member
Since: Aug 5, 2012
Posts: 10
Last: Mar 24, 2014
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Monday, Oct. 22, 2012 11:34 pm
Please Download link for zombie mod!
Share |
Mitch*
General Member
Since: Jan 23, 2007
Posts: 24
Last: Nov 10, 2012
[view latest posts]
Level 1
Category: CoD2 Scripting
Posted: Tuesday, Oct. 23, 2012 07:54 am
antocro writes...
Quote:
Please Download link for zombie mod!


http://callofduty.filefront.com/file/Zombies_Gametype_for_CoD2;53241

http://callofduty.filefront.com/file/Zombies_gametype_by_Ls;89843

http://callofduty.filefront.com/file/Zombies_Gametype_by_pijamaninjas;93014

(you might even find one at the downloads here)
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

»