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

Members Online

»
0 Active | 29 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: how to added weapons in shop?
virus972
General Member
Since: Jan 15, 2014
Posts: 5
Last: Jan 26, 2014
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Wednesday, Jan. 15, 2014 04:51 pm
hello i need help for my shop weapons. i have not the good scripts in order to added some weapons in my shop.
i have to try many code but it s not working.
i am using killer pro shop + shop max ammo it s working very well .


shop(response)
{
switch(response)
{
case "1":

wepcurrent = self getcurrentweapon();


if(self.money >= 50)
{
self.money-=50;
self givemaxammo(wepcurrent);
self iprintlnbold("^1-50");

self iprintlnbold("-=^1Max ammO^7=-");
}

else if(self.money < 50)
{
self iprintlnbold("-=^1Not enough moneY^7=-");
}

break;
/////////////////////////////////////////////////////////////////////////////////////////////////////

this part does not work but take the money. the cas 1 work perfectly
/////////////////////////////////////////////////////////////////////////////////////////////////////
case "2":

wepcurrent = self getcurrentweapon();


if(self.money >= 50)
{
self.money-=50;
self takeweapons(mp_44_mp);
self giveweapons(mp_44_mp)
self givemaxammo(wepcurrent);
self iprintlnbold("^1-100");
self iprintlnbold("-=^1Mp44^7=-");
}

else if(self.money < 50)
{
self iprintlnbold("-=^1Not enough moneY^7=-");
}

break;

}
}
Share |
qrery
General Member
Since: Dec 8, 2013
Posts: 4
Last: Jan 17, 2014
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Wednesday, Jan. 15, 2014 06:31 pm
I should first say, I've barely written any CoD-script, so my points may not be quite valid. I do spot a few possible flaws in this code though.

Firstly, what's probably failing it, is the lack of a semi-colon (";") after "self giveweapons(mp_44_mp)"? (Didn't test the code myself, but if CoD-script parsing is as strict as for common compilers and it's not just a typo in the post here, I'd expect this to be the cause.)

I expect the "giveweapons" and "takeweapons" custom functions to be properly defined in other parts of the script and the variable "mp_44_mp" to be defined in the context as a valid input for these functions (or perhaps the "mp_44_mp" is intended to be a string instead of a variable name in which case it's lacking the quotes).

In other, non-critical, notes; for some reason it appears to output "-100" to the screen while it only reduces "self.money" by 50 in the code seen here, however I suppose this could be further handled in the custom functions (the take/give). I'm also uncertain about the pointfulness of the "else if(self.money<50)" as it could be just "else" since the only preceding "if" already checks for all other cases ("if(self.money >= 50)").
Share |
virus972
General Member
Since: Jan 15, 2014
Posts: 5
Last: Jan 26, 2014
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Wednesday, Jan. 15, 2014 06:44 pm
yes i forgot the (;;) but it s still not working with the code i will update all the code
Share |
virus972
General Member
Since: Jan 15, 2014
Posts: 5
Last: Jan 26, 2014
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Wednesday, Jan. 15, 2014 07:03 pm
code:
case "2":

wepcurrent = self getcurrentweapon();


if(self.money >= 100)
{
self.money-=100;
self giveWeapon(self.pers["mp44_mp"]);
self giveMaxAmmo(self.pers["mp44_mp"]);
self setSpawnWeapon(self.pers["mp44_mp"]);
self iprintlnbold("^1-100");
self iprintlnbold("-=^1Mp44^7=-");
}

else if(self.money < 100)
{
self iprintlnbold("-=^1Not enough moneY^7=-");
}

break;

}

}
Share |
qrery
General Member
Since: Dec 8, 2013
Posts: 4
Last: Jan 17, 2014
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Thursday, Jan. 16, 2014 08:41 am
If I'm getting the concept of "self.pers" right (didn't find actual documentation with the short google-lookup I made), you may be using them out of place - how about just "mp44_mp" instead of self.pers["mp44_mp"] in all of those, unless you know it to have critical importance.

Also in case you want to also remove the current weapon (and if it works as I expect it to), you may need to also call self takeWeapon(wepcurrent); before the giveWeapon or if not then in that particular code as seen now you don't seem to need the wepcurrent = self getcurrentweapon(); part.
Share |
virus972
General Member
Since: Jan 15, 2014
Posts: 5
Last: Jan 26, 2014
[view latest posts]
Level 0
Category: CoD2 Scripting
Posted: Thursday, Jan. 16, 2014 10:29 am
THX for your help after to read again all my code and try another way i have to find this on but i countinous to work on it.

shop(response)
{
switch(response)
{
case "1":
if(self.money >= 50)
{
wepcurrent = self getcurrentweapon(); // checks what weapon you currently have in your hands
weapon1 = self getweaponslotweapon("primary"); // checks whats in your primary slot
weapon2 = self getweaponslotweapon("primaryb"); // checks whats in your secondary slot

if(wepcurrent == weapon1)
{
currentslot = "primary";
}
else
{
currentslot = "primaryb";
}

self.money-=50;
weapon = "mosin_nagant_mp";
sweapon = self getweaponslotweapon("primary");
self takeWeapon(sweapon);
self setWeaponSlotWeapon("primary", weapon);
self setSpawnWeapon(weapon);

self iprintlnbold("^1-50$");
self iprintlnbold("-=^2Mosin nagant ^7=-");
}
else if(self.money < 50)
{
self iprintlnbold("^1You do not have enough money");
}
break;

and i see i get the weapons without to respaw. for me it s ok

edited on Jan. 16, 2014 03:30 am by virus972

edited on Jan. 16, 2014 03:32 am by virus972
Share |
robert119966
General Member
Since: Feb 12, 2012
Posts: 19
Last: Feb 7, 2014
[view latest posts]
Level 1
Category: CoD2 Scripting
Posted: Thursday, Jan. 16, 2014 01:05 pm
need help ?
xf ; czolk
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

»