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

Members Online

»
0 Active | 12 Guests
Online:

LATEST FORUM THREADS

»
warfare
CoD4 Map + Mod Releases
Voting menu on maps
CoD+UO General
Hauling 911
CoDBO3 General

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: Prefabs and scripting
Zelzahim
General Member
Since: Dec 31, 2008
Posts: 42
Last: Sep 23, 2010
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Wednesday, Sep. 22, 2010 09:14 am
I have got a great idea for a new map, just that theres one thing that i would need your help with before i get started.

I would like to create a prefab of a simple dirt block which the player would then be able to destroy by bashing it.

I've yet created a script_brushmodel of the block named simply "block", and a trigger_damage named "trigger".

I know the script for these kind of stuff is quite simple, and i believe that i might be ale to write that part by myself. I really dont know how to attach a script to a prefab though, and i also dont know how to pack the prefab into the .iwd file.

Any help with this, fellow modders?

Share |
Zelzahim
General Member
Since: Dec 31, 2008
Posts: 42
Last: Sep 23, 2010
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Wednesday, Sep. 22, 2010 11:21 am
Bumping.
Share |
Mystic
General Member
Since: Apr 10, 2004
Posts: 6147
Last: Apr 15, 2018
[view latest posts]
Level 10
Forum Moderator
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Wednesday, Sep. 22, 2010 02:35 pm
A prefab is just a map file which can be loaded into an existing or new map. The script for any prefab would need to be added to the mapname.gsc of the map have imported the prefab too.

You don't need to package the prefab into the iwd because it is already added to the map when compiled.

If you need help with your script, post what you have here and i will be happy to help.
Share |
Zelzahim
General Member
Since: Dec 31, 2008
Posts: 42
Last: Sep 23, 2010
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Wednesday, Sep. 22, 2010 06:46 pm
Hello, and thanks alot.

The script i will be using is at the moment really simple, and goes somewhere along these lines.

Code:
main()
{

block=getent ("block","targetname");
trigger=getent ("trigger","targetname");

trigger waittill ("trigger");
wait(0.1);
trigger waittill ("trigger");
block delete();

}


This script is tested and works when i put just one block into my map, but i would like to have alot of blocks in it when it's done, and i do not yet know how to fix that.
Share |
Mystic
General Member
Since: Apr 10, 2004
Posts: 6147
Last: Apr 15, 2018
[view latest posts]
Level 10
Forum Moderator
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Wednesday, Sep. 22, 2010 06:54 pm
When you use 'getent' your script is looking for one entity 'get entity'. For more than one, you need to use 'getentarray'. Will will grab all the entities with the same targetname.

main()
{

block=getentarray ("block","targetname");
trigger=getentarray ("trigger","targetname");

trigger waittill ("trigger");

block delete();

}
Share |
Zelzahim
General Member
Since: Dec 31, 2008
Posts: 42
Last: Sep 23, 2010
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Wednesday, Sep. 22, 2010 08:01 pm
Thanks again. Your script does give me the following error tho.

Code:
******* script runtime error *******
array is not an object: (file 'maps/mp/blockdestr.gsc', line 7)
trigger waittill ("trigger");
*
called from:
(file 'maps/mp/mp_block.gsc', line 4)
maps\mp\blockdestr::main();
*
started from:
(file 'maps/mp/mp_block.gsc', line 1)
main()
*
************************************
writing to: C:\Call Of Duty 2\servercache.dat
Error during initialization:
script runtime error
(see console for details)
(file 'maps/mp/mp_block.gsc', line 1)
Share |
ivan_cro
General Member
Since: Jul 21, 2008
Posts: 463
Last: Oct 27, 2010
[view latest posts]
Level 5
Category: CoD2 Scripting
Posted: Wednesday, Sep. 22, 2010 08:19 pm
You will have to add "targetname","trigger" to your newly created trigger (trigger mutliple, use...)

ivan_cro
Share |
Zelzahim
General Member
Since: Dec 31, 2008
Posts: 42
Last: Sep 23, 2010
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Wednesday, Sep. 22, 2010 08:26 pm
Well... i have. That's strange.
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, Sep. 22, 2010 08:57 pm
although it does give that error and all u can double check to see if u have the trigger just slip this in ur script

if(!isDefined(trigger))
self iprintlnbold("you do not have a trigger");

although kinda pointless to add that sense the error is basicly telling u already that u dont have a trigger so just double check in radaint make sure ur doing it correctly if anything just delete the trigger u have now and make a new one that might help.
Share |
Zelzahim
General Member
Since: Dec 31, 2008
Posts: 42
Last: Sep 23, 2010
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Thursday, Sep. 23, 2010 04:45 am
Well. Theres a trigger there. I removed the script and tested again, and the "use" symbol appeared as i get close. [confused]
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

»