Page 1 of 2
Script problems
Posted: January 27th, 2013, 10:33 pm
by ExPie
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.
Re: Script problems
Posted: January 27th, 2013, 11:21 pm
by F |Madness| U
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.
Re: Script problems
Posted: January 28th, 2013, 12:30 am
by Rezil
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).
Re: Script problems
Posted: January 28th, 2013, 2:13 am
by Drofder2004
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";
Re: Script problems
Posted: January 28th, 2013, 6:13 am
by ExPie
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)?
Re: Script problems
Posted: January 28th, 2013, 9:19 am
by F |Madness| U
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.
Re: Script problems
Posted: January 28th, 2013, 11:52 am
by Drofder2004
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.
Re: Script problems
Posted: January 28th, 2013, 3:58 pm
by ExPie
How do I place a script in CSV. And mp_strike_fx can be loaded. Why can't be my script?
Re: Script problems
Posted: January 28th, 2013, 5:10 pm
by ExPie
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?
Re: Script problems
Posted: January 28th, 2013, 5:31 pm
by ExPie
Problem might be in how are the global ents defined? In CoD1 its level.ent, I'm not sure how it works in CoD4.
Re: Script problems
Posted: January 28th, 2013, 5:43 pm
by ExPie
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);
}
Â
Re: Script problems
Posted: January 28th, 2013, 7:56 pm
by ExPie
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?
Re: Script problems
Posted: January 28th, 2013, 8:32 pm
by ExPie
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?
Re: Script problems
Posted: January 28th, 2013, 10:25 pm
by ExPie
Heh nvm. How stupid of me. I thought .ff files were placed into usermaps xD they are in zone english

Thx for ur help!!!
Re: Script problems
Posted: January 29th, 2013, 1:53 am
by Drofder2004
So, are you at a solved state at the moment, because I am lost...
