Script problems

Have questions about CoD4 mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

ExPie
CJ Wannabe
CJ Wannabe
Posts: 28
Joined: January 20th, 2013, 10:56 pm

Script problems

Post by ExPie » January 27th, 2013, 10:33 pm

Code: Select all

main()
{
        maps\mp\_load::main();
//      maps\mp\mp_strudl_script::main();               
 
        ambientPlay("ambient_backlot_ext");
 
        game["allies"] = "marines";
        game["axis"] = "opfor";
        game["attackers"] = "axis";
        game["defenders"] = "allies";
        game["allies_soldiertype"] = "desert";
        game["axis_soldiertype"] = "desert";
 
        setdvar( "r_specularcolorscale", "1" );
 
        setdvar("r_glowbloomintensity0",".25");
        setdvar("r_glowbloomintensity1",".25");
        setdvar("r_glowskybleedintensity0",".3");
        setdvar("compassmaxrange","1800");
        
        script();
 
}
 
script()        {
        level.strudl = getent("strudl", "targetname");          
        level.button = getent("button", "targetname");
        level.trig = getent("strudl_trig", "targetname");
        start();
}
 
 
start() {
        player = getentarray("player", "classname");
        level.trig waittill("trigger", player);
        level.button playsound("spin");
        player iprintlnbold("You spin right round, baby right round!");
        player iprintlnbold("Like a record, baby right round!");
        thread button();
        thread strudl();
}
 
 
strudl()        {
        for(i=0; i<5; i++)      {
                level.strudl movez (-300, 1.5);
                level.strudl rotateyaw ( 360, 3);
                level.strudl waittill("movedone");
                level.strudl movez (300, 1.5);
                level.strudl waittill("rotatedone");
        }
        start();
}
 
button()        {
        level.button movez (-1, 0.5);
        level.button waittill ("movedone");
        level.button movez (1, 0.5);
}
 
Thats my scrpit.
First of all I have it all in one gsc, cos if i call 4th line it doesnt find the script for some reason.

Then the error is "level.trig waittill("trigger", player);" undefined(line 36)?


Plz help. Thx.

F |Madness| U
CJ G0D!
CJ G0D!
Posts: 1575
Joined: June 3rd, 2009, 9:02 pm
Location: Cardiff University, UK

Re: Script problems

Post by F |Madness| U » January 27th, 2013, 11:21 pm

The problem is that your variable `player` is an array (you used getentarray to get the array of all players) and level.trig cannot wait for the whole array of the variable player, only a single entity from the erray.

Edit: Actually, I'm not sure if that matters. However you don't need to get the array of players so delete that line. If it still doesn't work, then the object that you called level.trig may have a different targetname in radiant.
-

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: Script problems

Post by Rezil » January 28th, 2013, 12:30 am

Please post the exact error you get, a lot of things can be undefined in codscript.

I suspect either that level.trig doesn't point to a corrent entity in your map or that you can't use an already defined entity in your waittill(in your case, you define 'players' and then try to overwrite it with the player that triggered your trigger).
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Script problems

Post by Drofder2004 » January 28th, 2013, 2:13 am

The error is the fact you have asked the game to get a list of players in the server, but this happens WHILE you are connecting and no entities are found. Therefore the 'player' array is undefined (empty).

However,

Code: Select all

player = getentarray("player", "classname");
As mentioned above, this line is not required. This is causing [or will cause] (as Rezil said) an "already defined" error. You cannot overwrite an array/entity in this way.

You only need to get the array of players if you intend to interact with all of them directly. In your example, you are only interacting with the player who touches the array.

2 options (you can do both, but I recommend doing '1' at the very least):
1. Delete the line "getentarray players".
2. Change the entity name in the "waittill("trigger", ent);"

Remember, you do NOT need to use the word 'player' just to because it is a player, it is just as valid to do:

Code: Select all

trig waittill("trigger", e);
e iprintln("You touched the trigger";
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

ExPie
CJ Wannabe
CJ Wannabe
Posts: 28
Joined: January 20th, 2013, 10:56 pm

Re: Script problems

Post by ExPie » January 28th, 2013, 6:13 am

Still the same error. Why doesn't it find strudl_script if I call it in line 4(ad yes, I have it in raw/maps/mp)?

F |Madness| U
CJ G0D!
CJ G0D!
Posts: 1575
Joined: June 3rd, 2009, 9:02 pm
Location: Cardiff University, UK

Re: Script problems

Post by F |Madness| U » January 28th, 2013, 9:19 am

ExPie wrote:Still the same error. Why doesn't it find strudl_script if I call it in line 4(ad yes, I have it in raw/maps/mp)?
Is it all spelled correctly and does it have the function main()? Also I think you may have to add a line into your csv file but I'm not too sure on this.
-

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Script problems

Post by Drofder2004 » January 28th, 2013, 11:52 am

F |Madness| U wrote:
ExPie wrote:Still the same error. Why doesn't it find strudl_script if I call it in line 4(ad yes, I have it in raw/maps/mp)?
Is it all spelled correctly and does it have the function main()? Also I think you may have to add a line into your csv file but I'm not too sure on this.
All scripts should be placed in the CSV.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

ExPie
CJ Wannabe
CJ Wannabe
Posts: 28
Joined: January 20th, 2013, 10:56 pm

Re: Script problems

Post by ExPie » January 28th, 2013, 3:58 pm

How do I place a script in CSV. And mp_strike_fx can be loaded. Why can't be my script?

ExPie
CJ Wannabe
CJ Wannabe
Posts: 28
Joined: January 20th, 2013, 10:56 pm

Re: Script problems

Post by ExPie » January 28th, 2013, 5:10 pm

Ok I maneged to find how to put it into CSV (rawfile,maps/mp/mp_mymapname_rotate.gsc).

Now how do I make that trigger defined?

ExPie
CJ Wannabe
CJ Wannabe
Posts: 28
Joined: January 20th, 2013, 10:56 pm

Re: Script problems

Post by ExPie » January 28th, 2013, 5:31 pm

Problem might be in how are the global ents defined? In CoD1 its level.ent, I'm not sure how it works in CoD4.

ExPie
CJ Wannabe
CJ Wannabe
Posts: 28
Joined: January 20th, 2013, 10:56 pm

Re: Script problems

Post by ExPie » January 28th, 2013, 5:43 pm

This is the code:

Code: Select all

main()  {
        level.strudl = getent("strudl", "targetname");          
        level.button = getent("button", "targetname");
        level.trig = getent("strudl_trig", "targetname");
        start();
}
 
 
start() {
        level.trig waittill("trigger", player);
        level.button playsound("spin");
        player iprintlnbold("You spin right round, baby right round!");
        player iprintlnbold("Like a record, baby right round!");
        thread button();
        thread strudl();
}
 
 
strudl()        {
        for(i=0; i<5; i++)      {
                level.strudl movez (-300, 1.5);
                level.strudl rotateyaw ( 360, 3);
                level.strudl waittill("movedone");
                level.strudl movez (300, 1.5);
                level.strudl waittill("rotatedone");
        }
        start();
}
 
button()        {
        level.button movez (-1, 0.5);
        level.button waittill ("movedone");
        level.button movez (1, 0.5);
}
 

ExPie
CJ Wannabe
CJ Wannabe
Posts: 28
Joined: January 20th, 2013, 10:56 pm

Re: Script problems

Post by ExPie » January 28th, 2013, 7:56 pm

LoL! It works, all I did was connect the triger to the ent. Can I ask where do you put your sound files and where the soundaliases map with a sound csv file?

ExPie
CJ Wannabe
CJ Wannabe
Posts: 28
Joined: January 20th, 2013, 10:56 pm

Re: Script problems

Post by ExPie » January 28th, 2013, 8:32 pm

I have found another problem. I have sound in my map(obv), and if I transfer both .ff files on anoter computer in cod4/usermaps/mp_strudl. It switches to backlot. Why?

ExPie
CJ Wannabe
CJ Wannabe
Posts: 28
Joined: January 20th, 2013, 10:56 pm

Re: Script problems

Post by ExPie » January 28th, 2013, 10:25 pm

Heh nvm. How stupid of me. I thought .ff files were placed into usermaps xD they are in zone english :D Thx for ur help!!!

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Script problems

Post by Drofder2004 » January 29th, 2013, 1:53 am

So, are you at a solved state at the moment, because I am lost... :P
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: No registered users and 32 guests