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

Members Online

»
0 Active | 92 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: problem with subtraction
BrockCZE
General Member
Since: Aug 8, 2009
Posts: 26
Last: Dec 8, 2009
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Friday, Oct. 2, 2009 03:06 pm
Hi, i have problem with subtraction in this line: carrier.pers["money"]-20; when i put instead -20 only -- it works, but i dont want to subtract only 1 but i want 20. Pls can you someone help me with it? (i have defined "money") here is whole script:
Code:

main()
{
init_TNT();
thread TNTAmmo();
}


init_TNT(){
	players = getentarray("player", "classname");
	for(i=0; i<players.size; i++){
		players[i].pers["tntammo"] = 0;
	}
}

TNTAmmo(){
	TNT_ammo_trig = getent("buy_tnt", "targetname");
	while(1){
		TNT_ammo_trig waittill("trigger", carrier);
		give = 1 - carrier.pers["tntammo"];


		if(carrier.pers["money"]<7)
			{
			carrier iprintln("^2NOTICE: ^7You don't have enough money.");
			}
		else{
			carrier.pers["money"]-20;
			carrier iprintln("^2NOTICE: ^7Your money is now: ^2"+carrier.pers["money"]+".");


			carrier.pers["tntammo"] ++;
			carrier iprintln("^2NOTICE: ^7Count of your TNT: ^2"+carrier.pers["tntammo"]+"^7.");
		}
		wait 1;
	}
}


Share |
COD4GRC
General Member
Since: Aug 12, 2007
Posts: 44
Last: Jan 30, 2010
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Friday, Oct. 2, 2009 04:09 pm
instead of
Code:
carrier.pers["money"]-20;


you should use:
Code:
carrier.pers["money"] = carrier.pers["money"] - 20;
Share |
BrockCZE
General Member
Since: Aug 8, 2009
Posts: 26
Last: Dec 8, 2009
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Friday, Oct. 2, 2009 04:20 pm
works, thx.... i could get this idea :D
Share |
.KiLL3R.
General Member
Since: Oct 26, 2006
Posts: 1437
Last: Jul 3, 2017
[view latest posts]
Level 8
Category: CoD2 Scripting
Posted: Friday, Oct. 2, 2009 05:31 pm
or

Code:

carrier.pers["money"] -= 20;
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

»