Page 1 of 1

Script problem

Posted: September 17th, 2006, 2:34 pm
by All-Killer
I tried to make a script for a Singleplayer map but it doenst work. It is supossed that you will be drop down by a parachute in youre map.

This is the tutorial: http://www.modsonline.com/Tutorials-read-266.html

This is the script that i use.

Code: Select all

main()
{
setCullFog (0, 8000, 0.8, 0.8, 0.8, 0);
ambientPlay("amb_burnville");	
	
	maps\mp\_load::main();
	maps\mp\_load::parachute();
level._effect["fire"] = loadfx ("fx/fire/tinybon.efx");
maps\mp\_fx::loopfx("fire", (-157, 435, 30), 0.6);
level._effect["smoke"] = loadfx ("fx/smoke/ash_smoke.efx");
maps\mp\_fx::loopfx("smoke", (-157, 435, 85), 0.7);

game["allies"] = "american";
game["axis"] = "german";

game["american_soldiertype"] = "airborne";
game["american_soldiervariation"] = "normal";
game["german_soldiertype"] = "fallschirmjagercamo";
game["german_soldiervariation"] = "normal";

game["attackers"] = "allies";
game["defenders"] = "axis";
}

Code: Select all

parachute()
{
level.player allowProne (false);
level.player allowCrouch (false);

start = level.player.origin;

startheight = start[2];

level.player.origin = level.player.origin + (0,0,0);

parachute = spawn ("script_model",(0,0,0));
parachute setmodel ("xmodel/parachute_animrig");

parachute.origin = level.player.origin;

level.player linkto (parachute,"TAG_player",(0,0,0),(0,0,0));

while (1)
{
wait 0.05;

direction = (0,0,-9);
parachute.origin=parachute.origin+direction;

start = level.player.origin;
end = start + (0,0,-64);

hitcharacters = 1;
results=[];results=bulletTrace(start,end,hitcharacters,level.player);

if (results["fraction"]!=1)
{
level.player.origin = results["position"];
level.player unlink();

level.player allowProne (true);
level.player allowCrouch (true);

break;
}
}
parachute hide();
}
I dont get any script errors, but the parachute just dont work.

Hope some one can see the problem.

Posted: September 18th, 2006, 12:53 pm
by Drofder2004
atm, I have to shoot out, so I cannot fully examine the script, but I can see things that don't quite add up...

i.e
level.player.origin = level.player.origin + (0,0,0);

That line above is pointless.

You are basically saying

1 = 1 + 0
Or
(1,1,1) = (1,1,1) + (0,0,0)

I am guessing what you need in that position is something like

level.player.origin = level.player.origin + (0,0,300);

That will move the player 300 units above the spawn point...

I will look into this further when I get home.

Posted: September 18th, 2006, 2:31 pm
by All-Killer
to quote from the tut:
the BLUE line tells you where you'll spawn, but as we have already placed our spawn point high in the sky, we leave the coordinates (0,0,0)

Posted: September 18th, 2006, 7:28 pm
by Drofder2004
This is why I needed some time to look over it. There are obvious mistakes ;)

Code: Select all

main()
{
setCullFog (0, 8000, 0.8, 0.8, 0.8, 0);
ambientPlay("amb_burnville");   

////////////////////////////////////////
maps\mp\_load::main();
maps\mp\_load::parachute();
////////////////////////////////////////

level._effect["fire"] = loadfx ("fx/fire/tinybon.efx");
maps\mp\_fx::loopfx("fire", (-157, 435, 30), 0.6);
level._effect["smoke"] = loadfx ("fx/smoke/ash_smoke.efx");
maps\mp\_fx::loopfx("smoke", (-157, 435, 85), 0.7);

game["allies"] = "american";
game["axis"] = "german";

game["american_soldiertype"] = "airborne";
game["american_soldiervariation"] = "normal";
game["german_soldiertype"] = "fallschirmjagercamo";
game["german_soldiervariation"] = "normal";

game["attackers"] = "allies";
game["defenders"] = "axis";
}
I have put /'s around the error.

Firstly.
maps\mp\_load::main();

As you can see, you are using "mp". For SP you need
maps\_load::main();

Secondly.
maps\mp\_load::parachute();

You don't need this line at all. Parachute does not exist inside _load.gsc
thread parachute();

You also do not need any of the attackers or defenders referenced.

Code: Select all

main()
{
maps\_load::main();

setCullFog (0, 8000, 0.8, 0.8, 0.8, 0);
ambientPlay("amb_burnville");

thread parachute(); 

level._effect["fire"] = loadfx ("fx/fire/tinybon.efx");
level._effect["smoke"] = loadfx ("fx/smoke/ash_smoke.efx");

maps\_fx::loopfx("fire", (-157, 435, 30), 0.6);
maps\_fx::loopfx("smoke", (-157, 435, 85), 0.7); 
}

parachute()
{
level.player allowProne (false);
level.player allowCrouch (false);

start = level.player.origin;
startheight = start[2];

parachute = spawn ("script_model",(0,0,0));
parachute setmodel ("xmodel/parachute_animrig");

parachute.origin = level.player.origin;

level.player linkto (parachute,"TAG_player",(0,0,0),(0,0,0));

while (1)
{
wait 0.05;

parachute.origin = parachute.origin + (0,0,-9);

start = level.player.origin;
end = start + (0,0,-64);

hitcharacters = 1;
results = [];
results = bulletTrace(start, end, hitcharacters, level.player);

if (results["fraction"] != 1)
{
level.player.origin = results["position"];
level.player unlink();

level.player allowProne (true);
level.player allowCrouch (true);

break;
}
}
parachute hide();
}
If the above works fine, I would recommend you change the last line of
"parachute hide();"
to
"parachute delete();"
and test that. Hiding something is not as effective as getting rid of it completely.

Posted: September 19th, 2006, 1:37 pm
by All-Killer
Oke i test it tonight, thanks for youre help im not the bigest star is scripting and it is my first SP map. Tell you tonight if it works

Posted: September 19th, 2006, 6:45 pm
by All-Killer
Oke i tested it but still i doenst work. I also noticed that the fire and smoke FX also dont work.

Posted: September 19th, 2006, 7:55 pm
by creator
killer send me on xfire or msn i got time to test now [ did not had time in the passed ]

Posted: September 19th, 2006, 8:31 pm
by All-Killer
I look back into my pk3 and saw there was a .arena file. Do i need that for a singleplayer map, and if i need it what do i need to put in it.

Posted: September 19th, 2006, 8:41 pm
by creator
ok i fixed it, it was no script problem, i send u tomorrow on xfire/msn + how i fixed