MODSonline
  Welcome Guest to MODSonline Home | Forums | Register | Login
Main-Menu
Home
Login
Register
Add Download
Add News
Add Tutorial *
Forums

Advertise
Affiliate Store US *
Affiliate Store UK *
Affiliate Store CA *
Angry Letter Generator
Avatar Upload
Calendar of Games
Contact
Downloads
FAQs
Forums
Member List
Member Projects
News
News Grabber *
Policy
Polls
Private Messages
Reviews
Screenshot Gallery
Search
Servers - Game
Store - Shirts *
Subscribe
Topics
Tutorials
Weblinks
Wiki *
Tutorials
CoD Mapping
CoDUO Mapping
CoD2 Mapping
CoD4 Mapping
CoDWW Mapping
CoD FAQs
HL2 Mapping
HL2 FAQs
SOF1 Mapping
Crysis Mapping
Q4 Mapping
Doom 3 Mapping
Doom 3 FAQs
UT2K3 Mapping
SOF2 Mapping
SOF2 FAQs

Lightray Modeling
General Modeling
General Modding
Adobe Photoshop
Common Mapping Errors

Readme.txt Generator
Members-Online
piznac [Downl]
IchKG [Forum]
cobbspur [Forum]
shivix [Tutor]
starkk [Today]

5 Members and 18 Guests
Chat MODSonline
0 People Now Chatting
MODSOnline TeamSpeak

download TeamSpeak

In-The-News
Monday, Dec. 1st
A message from foyleman
Sunday, Nov. 30th
MODSonair 156 Live
Friday, Nov. 28th
MODSonair Episode 155
Wednesday, Nov. 26th
MODSonair Forum Buttons
Monday, Nov. 24th
Holiday Gift Guide 2008 - PC
Latest Poll
Single or Multiplayer maps for World at War?
Single-Player 29.55%
Multiplayer 62.5%
WHAT!? The tools are out? 7.95%
Read More...
10 comments

Newsletter
Name:
Email:
Newsletter Archives
Your Membership
User Name:
Password:
Register.
In The Forums
Arched window?
CoD:WW Level Des.. Posts: (9) Views: (87) by shivix
nazi_zombie problem with map : (
CoD:WW Level Des.. Posts: (4) Views: (51) by Papik
Appreciation
MODSonline.. Posts: (5) Views: (42) by Rasta
if your map switches to airfield read this !
CoD:WW Level Des.. Posts: (2) Views: (20) by darkcod5
Art of War Central Quake 4 Mods for Dummies
CoDWW Download
Forums
MODSonline.com 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 4
Category: CoD 4 Scripting
Scripting and coding with Call of Duty 4.
Moderators: foyleman, rEdrUmMDK, Foxhound, Rasta, StrYdeR, The_Caretaker, batistablr, playername, Welshy
Latest Posts
Subscribed Posts
Search
Restricted Access Restricted Access
Page
Next Page
subscribe
Author Topic: unrecognized variable sidearm
DaveR
General Member
Since: Dec 5, 2006
Posts: 308
Last: Nov 23, 2008
[view latest posts]
Level 5
Category: CoD 4 Scripting
Posted: Wednesday, Sep. 17, 2008 01:05 pm
Hello,

I'm trying to remove the ammo from both teams by scripting. I've edited the war.gsc document to do this; I added this to the bottom:


Code:


and I added this under main():


Code:


When I test this it says 'unrecognized variable 'sidearm''. Does someone know what is going wrong and how I fix it?

Thx.
Sevenz
General Member
Since: Apr 24, 2006
Posts: 1133
Last: Nov 28, 2008
[view latest posts]
Level 8
Category: CoD 4 Scripting
Posted: Wednesday, Sep. 17, 2008 01:52 pm

Code:



Code:


edited on Sep. 17, 2008 01:53 pm by Sevenz
DaveR
General Member
Since: Dec 5, 2006
Posts: 308
Last: Nov 23, 2008
[view latest posts]
Level 5
Category: CoD 4 Scripting
Posted: Wednesday, Sep. 17, 2008 03:26 pm
thx

I've made it like this:


Code:


Then it says 'unilitialized variable 'players''.

:/
Sevenz
General Member
Since: Apr 24, 2006
Posts: 1133
Last: Nov 28, 2008
[view latest posts]
Level 8
Category: CoD 4 Scripting
Posted: Wednesday, Sep. 17, 2008 03:42 pm
do you understand your own code? i think you don't...


Quote:
for(i = 0; i < players.size; i++)

--> player.size


Quote:
// self SetWeaponAmmoClip( grenadeTypePrimary, grenadeCount );

--> why did you comment it out? and did you define both variables you use in the call?
Tally
General Member
Since: Apr 21, 2005
Posts: 199
Last: Dec 2, 2008
[view latest posts]
Level 4
Category: CoD 4 Scripting
Posted: Wednesday, Sep. 17, 2008 11:52 pm
Everything in a script has to be defined, unless it is preceeded with level.whatever (permanently defined until a round reset), or game["whatever"] (permanently defined even after a round reset).

Example:

level.players is defined in _globallogi.gsc and doesnt need defining again, hence you dont need to assign to player ent array:


Code:


or simply:


Code:


However, grenadeTypePrimary and grenadeCount are not level definitions, hence they would return as undefined. So, you need to define them.

To remove ammo from a weapon, you need to tell the game what weapon. Otherwise, it will return as undefined.

Hence you would need to either construct an array where every weapon in the game is found and checked against what the player actually has. Or, use some stock game functions and list each weapon one by one (tedius and clumsy).

The game has some stock functions which can be used to check a players weapon:

self hasweapon()
self getCurrentWeapon()

Try to use those to search for a players weapon and check it against an array of weapons. _weapons.gsc has some useful stuff in it, so start there.


edited on Sep. 18, 2008 12:06 am by Tally
DaveR
General Member
Since: Dec 5, 2006
Posts: 308
Last: Nov 23, 2008
[view latest posts]
Level 5
Category: CoD 4 Scripting
Posted: Thursday, Sep. 18, 2008 10:21 am
Wow, this is kinda hard to understand for me, I'm new to scripting and I'm still learning all the stuff.

I've found this in _weapons.gsc:


Code:


I guess this are some weapon names?

I'm trying to follow what you are saying, but probably I won't understand it completely. I put this under main() in war.gsc:


Code:


And then I put this at the bottom of war.gsc:


Code:


And then I add all the other weapons too it?

Probably this sounds very stupid, but I'm still learning this.

.KiLL3R.
General Member
Since: Oct 26, 2006
Posts: 1090
Last: Dec 2, 2008
[view latest posts]
Level 8
Category: CoD 4 Scripting
Posted: Thursday, Sep. 18, 2008 10:46 am
Heres some quick examples -

This code will get the uninitialized variable error

Code:


But this wont

Code:


this one wont

Code:


and this one wont, but will will give an error saying myweapon is undefined

Code:


In the 1st example, you will see that 'myweapon' hasnt been initialized before being used, but the other 3 have it initialized somewhere before its used.



myweapon = "m4_mp";

Will initialize 'myweapon' as "m4_mp".



giveweapon(myweapon)

Can be called up as
self thread giveweapon("m4_mp");
If there isnt anything in the ( and ) then 'myweapon' becomes undefined



myweapon = undefined;

Will initialize 'myweapon' as undefined.




Stuff like [entity].myweapon and game["myweapon"] are always undefined unless you defined them somewhere (dont need to be initialized)
DaveR
General Member
Since: Dec 5, 2006
Posts: 308
Last: Nov 23, 2008
[view latest posts]
Level 5
Category: CoD 4 Scripting
Posted: Thursday, Sep. 18, 2008 12:37 pm
Thanks for your reply killer, that really helped me. I've edited the script to this:


Code:


Now it should remove the ammunition for the m4 I guess, so I test it ingame, but it still gives me the 'uninitialized variable 'players'' error. :/

edited on Sep. 18, 2008 12:38 pm by DaveR
.KiLL3R.
General Member
Since: Oct 26, 2006
Posts: 1090
Last: Dec 2, 2008
[view latest posts]
Level 8
Category: CoD 4 Scripting
Posted: Thursday, Sep. 18, 2008 12:49 pm
The variable 'player' hasnt initialized been in


Code:
DaveR
General Member
Since: Dec 5, 2006
Posts: 308
Last: Nov 23, 2008
[view latest posts]
Level 5
Category: CoD 4 Scripting
Posted: Thursday, Sep. 18, 2008 01:10 pm
So I have to make something like:


Code:


or something like that?

edited on Sep. 18, 2008 01:10 pm by DaveR
Restricted Access Restricted Access
Page
Next Page
subscribe
MODSonline.com Forums : Call of Duty 4 : CoD 4 Scripting
All logos and trademarks and information in this site are property of MODSonline LLC © 2008.
The comments are property of their posters.
RSS news feeds for MODSonline can be found News.php.
Intergi
Partners
Battle for Europe COD2
CODAddicts - Call of Duty News & Downloads
XoXide
modbase.be
Call of Duty Headquarters
The Firing Box
Frag Universe
Ask About
Advertising
Friends
Great Gamer
After Life Gaming
CoD 4 Base
Ask About
Advertising
Link to Us
MODSonair
View in iTunes
Please help us to raise in the ranks of podcasting and subscribe to our itunes feed using the link above.
MODSonair Releases
MODSonair Episode 155
MODSonair Episode 154
MODSonair Episode 153
MODSonair Episode 152
MODSonair Episode 151
Next Show
The next MODSonair show will air LIVE on:
12/07/2008 12:00 EST

Time remaining:
Copyright © 2008 MODSonline
Tresware Content Management System Copyright © 2008 Tresware
Website Designed and Hosted   Tresware