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

Members Online

»
0 Active | 69 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
Page
Next Page
subscribe
Author Topic: Shop in map
effenberg6
General Member
Since: Apr 8, 2011
Posts: 3
Last: Apr 9, 2011
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Friday, Apr. 8, 2011 03:23 pm
Hello. Can you help me? I have a script for a shop on the map. It works in a selected location where there is a trigger as you press F to buy a weapon in this case mp_launcher. You need to have 100 money.
HELP! This script has an error.

And here is the script

main ()
{
ammo thread ();
}

ammo ()
{
trig = getent ("trig_ammo", "targetname");
while (1)
{
ammocost = 100;
if (user.money> = ammocost user.pers & & ["team"] == "allies")
{
setWeaponSlotWeapon user ("primaryb", "launcher_mp");
switchToWeapon user ("launcher_mp");
iprintlnbold user ("^ 5 * ^ ^ 7Gra 9nade ^ ^ 7Lau 9ncher");
{
else if (user.pers ["team"]! = "allies")
}
iprintlnbold user ("^ 5 * ^ ^ 7th 9is 9n ^ ^ ^ 7Ca 7On 9LY ^ ^ ^ 9e ^ 7B 7Us 7B ^ ^ ^ 9ed 9Y ^ 7th ^ ^ 9e ^ 7Hunt 9ers");
{
else if (user.money }
iprintlnbold user ("^ 5 * ^ ^ 9U 7Yo 7D ^ 9o ^ ^ ^ 9t 7No 7HB ^ ^ ^ 9ve 7Eno ^ ^ 9ugh 7Mon ^ ^ 7T 9ey 9o ^ ^ ^ 7Purc 9hase ^ 7th ^ ^ 9is 7It ^ 9em");
}

}
}

PLS HELP ME!!
Share |
serthy
General Member
Since: Sep 8, 2010
Posts: 482
Last: Jun 28, 2013
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Friday, Apr. 8, 2011 05:59 pm
okay still forget the code
try search in the forum the are still like 3 or 4 money shop scripts
Share |
effenberg6
General Member
Since: Apr 8, 2011
Posts: 3
Last: Apr 9, 2011
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Friday, Apr. 8, 2011 06:13 pm
I still have the error
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Friday, Apr. 8, 2011 09:49 pm
I will go thru the errors you have 1 by 1, was surprised how you could even call this scripting.

1. use proper tabbing
Code:

main()
{
	//some code goes here
	if(something)
	{
		//other code goes here
	}
}


2.
Code:
ammo thread ();

thread is NOT a function. You want to script, use this:
Code:
thread ammo();


3.
Code:

while (1)
{
ammocost = 100;

Not really an error, but wth is this doing in the loop? get it out of the loop nao!

4.
Code:
if (user.money> = ammocost user.pers & & ["team"] == "allies")

Who do you think you are fooling?
4.a. User is not defined at this point, and thus so is user.money
4.b. ammocost user.pers && ["team"]=="allies") wtf is this crap?

5.a.
Code:

setWeaponSlotWeapon user ("primaryb", "launcher_mp");

why do you want to call the function user on the entity "setweaponslotweapon"? I would suggest swapping them... but then again, you havent even defined "user" yet.

5.b
Code:

switchToWeapon user ("launcher_mp");

again, same as 5.a. Is this some kind of trick to make us think you are really dumb?

5.c.
Code:

iprintlnbold user ("^ 5 * ^ ^ 7Gra 9nade ^ ^ 7Lau 9ncher");

same as 5.a and 5.b.

6.
This one is rly worse than all ive seen before, and believe me when i say ive seen a lot of shitty coding:
Code:

else if (user.pers ["team"]! = "allies")
}

I mean, srsly? open up an else if part of the function and directly close the above function? are you even trying to script?

7. (or 5.d.)
Code:

iprintlnbold user ("^ 5 * ^ ^ 7th 9is 9n ^ ^ ^ 7Ca 7On 9LY ^ ^ ^ 9e ^ 7B 7Us 7B ^ ^ ^ 9ed 9Y ^ 7th ^ ^ 9e ^ 7Hunt 9ers");

same as 5.a, 5.b, 5.c
8.
Code:

else if (user.money }

THIS STUFF IS FUCKED UP.

8.a USER IS NOT DEFINED!

8.b i think you want user.money to be an integer, not a boolean

8.c CLOSE A ( with a }? im not trying to saw something with a screwdriver either am i?

9. (or 5.e.)
Code:

iprintlnbold user ("^ 5 * ^ ^ 9U 7Yo 7D ^ 9o ^ ^ ^ 9t 7No 7HB ^ ^ ^ 9ve 7Eno ^ ^ 9ugh 7Mon ^ ^ 7T 9ey 9o ^ ^ ^ 7Purc 9hase ^ 7th ^ ^ 9is 7It ^ 9em");


Fancy colors, not good scripting. see 5.a,5.b,5.c and 5.d


10.
The while() loop doesnt have any waits in it. Even if the rest of the code would work, the thread would get killed immediately by cod cause of an infinite loop!

PS im not even trying to be polite. You havent even heard of developer 1 i guess?

PPS found one line that was ok in the total of 28 lines:
Code:
trig = getent ("trig_ammo", "targetname");


I hope you have some other hobbys to attend to
Share |
serthy
General Member
Since: Sep 8, 2010
Posts: 482
Last: Jun 28, 2013
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Friday, Apr. 8, 2011 10:27 pm
again, same as 5.a. Is this some kind of trick to make us think you are really dumb? 5.c.

AMEN

>>here litc64 gives some good ideas of the way doing this
http://modsonline.com/Forums-top-139026-0.html%23734377

here is a code out of a forum
Code:

main()
{
thread players();
}

players()
{
	while(1)
	{
		players = getentarray("player","classname");
		for(i = 0; i < players.size; i++)
		{
			if(!isdefined(players[i].spent))
			{
			players[i].spent = 0;
			}
			players[i].kills = players[i].score * 100;
			players[i].money = players[i].kills - players[i].spent;
			players[i] thread hud();
			}
		wait(1);
	}
}

hud()
{
hud = newClientHudElem(self);
hud.x = 320;
hud.y = 440;
while(1)
{
wait(.1);
	hud setvalue(self.money);
}
}




i think it was from afterlife forum
this script will show you your money u have on screen
for every kill u earn 100






@ iznogod
what is pps?
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Friday, Apr. 8, 2011 10:32 pm
pps=ps, only one layer deeper xD

and hurray for epic quotez:
effenberg6 writes...
Quote:
HELP! This script has an error.
Share |
*UWS*ThisGuy
General Member
Since: Jul 31, 2008
Posts: 215
Last: Jan 8, 2012
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Saturday, Apr. 9, 2011 05:11 am
@IzNoGod

You show awesome scripting knowledge however you fail on the ability to show class.

People come here for help, not to be berated and cussed at...just sayin [thumbs_up]
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Saturday, Apr. 9, 2011 08:54 am
Well, most of this aint even cod2 scripting knowledge. Its basic programming skill.

Then again, i often help people with errors, but this guy seems to have no idea what he is doing, and hasnt read any scripts from other people yet.
Worse, he doesnt know how to either use "developer 1", doesnt know it exists or doenst know how to interpret errors.
Share |
serthy
General Member
Since: Sep 8, 2010
Posts: 482
Last: Jun 28, 2013
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Saturday, Apr. 9, 2011 10:56 am
btw i failed on config settings
how do i bind a key to set developer on 1?
like
bind F5 set developer 1

i tried:
bind F5 "set developer 1"
bind F5 set developer "1"
bind F5 set "developer 1"
bind F5 set developer 1

noone of them seens to work

okay master iznogod :p

2nd try

how to create ur own mod:

create 3 new folders:
-maps
-mp
-gametypes

put the folders into 1 (gametypes in mp, mp in maps)
now u have
maps/mp/gametypes

create a new textdocument and call it what you want + .gsc
(windows asks you to confirm)
in my example it is _money.gsc

open this gsc file and copy&paste the code i post before
save it and move it to the maps/mp/gametypes folder

now u open activision/cod2/maps folder where u can find some iwd's files

do NEVER modify them!

open the iw_07.iwd file and go to maps/mp/gametypes where u can find some other gsc-files

copy the dm.gsc into your own gametypes folder

close iw_07.iwd

open the dm.gsc and search this place (its on top):
Code:

	if(!isdefined(game["state"]))
		game["state"] = "playing";

	level.QuickMessageToAll = true;
	level.mapended = false;

	thread startGame();
	thread updateGametypeCvars();
	//thread maps\mp\gametypes\_teams::addTestClients();

//________________________put it in here____________________
thread maps\mp\\gametypes\_money::main(); //this calls your script
//______________________________________________________
}

dummy()
{
	waittillframeend;

	if(isdefined(self))
		level notify("connecting", self);
}

Callback_PlayerConnect()
{
	thread dummy();


paste this line on the right place like shown above
Code:

thread maps\mp\gametypes\_money::main();


save it

create a new zip file (zip or rar ending, but only 1 will work!)
move your maps/mp/gametypes folder with _money.gsc and dm.gsc file in it into your zip file

rename your zipfile to .iwd (windows will ask you to confirm)

paste this iwd file into your activision/cod2/main folder

congrats ur done


here some advice:
-type before starting your mod in console developer 1 to locate the possible error
-when it is iwd sumname mismatch error, delete all custom iwds out of your main folder

this may contains some mistakes
Share |
IzNoGoD
General Member
Since: Nov 29, 2008
Posts: 694
Last: Nov 10, 2012
[view latest posts]
Level 6
Category: CoD2 Scripting
Posted: Saturday, Apr. 9, 2011 11:07 am
serthy writes...
Quote:
btw i failed on config settings
how do i bind a key to set developer on 1?
like
bind F5 set developer 1

i tried:
bind F5 "set developer 1"
bind F5 set developer "1"
bind F5 set "developer 1"
bind F5 set developer 1

noone of them seens to work

to effenberg6:
you know how to mod?
okay if not do this:
COPY!!! out of your main folder a .iwd file to you desktop
then create a new folder called: main and another one called: mp
move the mp folder into the main folder and the main one into the .iwd file
then delete everything except of your new main folder
after that you have to open e new dokument file and rename it to
.gsc (windows asks you to confirm)
into this textdocument copy&paste the code i gave to ya
this .gsc file u have to move in your iwd and in the main/mp folder
finally done
your script is now in your mod
now you have to call the function (otherwise the game does not know that this script exist, also cant call it and its useless)
open in your activision/cod2/main the iw_07.iwd file and go to maps/mp/gametypes
there should be some other gsc scriptfiles
one called dm.gsc
move this file to your desktop and close iw7.iwd (do NEVER modify this stock iwd's!!)
after that u open the dm.gsc
search for this (its on top)
and call your script this way:
thread maps\mp\::main();



Code:

	if(!isdefined(game["state"]))
		game["state"] = "playing";

	level.QuickMessageToAll = true;
	level.mapended = false;

	thread startGame();
	thread updateGametypeCvars();
	//thread maps\mp\gametypes\_teams::addTestClients();

//________________________put it in here____________________
thread maps\mp\<nameofyouGSCfile>::main(); //this calls your script
//______________________________________________________
}

dummy()
{
	waittillframeend;

	if(isdefined(self))
		level notify("connecting", self);
}

Callback_PlayerConnect()
{
	thread dummy();



now save the dm.gsc and create a new folder called gametypes
in this folder is now your dm.gsc
put the gametypes folder in your new main/mp folder into your .iwd modfile

and now your mod is done
u only have to move the .iwd mod into your activision cod2 main folder

start cod2 and test it

when you start cod2 toggle console and type in : developer 1
when you have recieved an error message and your new server does not start, press [Shift] + [^]
now your exact error message appers and u can see where exactly your problem is


this is a manual made by me, im not perfect and dthis manual also is NOT!
there might be some mistakes but i hope it helps some ppl

good luck


You might wanna rewrite the story, cause it seems kinda chaotic to me. some tl;dr i guess.
Share |
Restricted Access Topic is Locked
Page
Next Page
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

»