Page 1 of 1

script error...

Posted: September 4th, 2007, 3:13 pm
by Tehdisciple
Well, here i am again with another error...I am trying to make a vending machine so when you shoot the button it will give you the weapon that you have selected. I get a script runtime error when i use this script:

Code: Select all

main()
{
maps\mp\_load::main();
thread arena_onSpawn();
thread arena_weapon1();
}

arena_onSpawn()
{
   trig = 

getent("arena_trig","targetname");

   for(;;) 
   {
      trig waittill("trigger", other);
      other thread 

arena_onPlayerSpawned();
      wait 0.05;
   }
}

arena_onPlayerSpawned()
{
      self takeAllWeapons();
      wait 0.05;
}

arena_weapon1()
{
trig = 

getent("arena_weapon1","targetna

me");
while (1)
{
trig waittill ("damage", idamage);
if(idamage > 1)
{
self giveweapon("m1garand_mp");
}
}
}
Idk what is wrong..

Posted: September 4th, 2007, 4:02 pm
by YaNo
Try this :)

Code: Select all

main() 
{ 
maps\mp\_load::main(); 
thread arena_onSpawn(); 
thread arena_weapon1(); 
} 

arena_onSpawn() 
{ 
   trig = getent("arena_trig","targetname"); 

   while(1)
   { 
      trig waittill("trigger", user); 
      self takeAllWeapons(); 
      wait 0.5;
   } 
} 

arena_weapon1() 
{ 
trig = getent("arena_weapon1","targetname"); 
while (1) 
{ 
trig waittill ("damage", idamage); 
if(idamage > 1) 
{ 
self giveweapon("m1garand_mp"); 
} 
} 
}

Posted: September 4th, 2007, 4:15 pm
by Deadly
trig = ?

should it be

trig = getent("arena_trig","targetname");

Nope

Posted: September 4th, 2007, 4:16 pm
by Tehdisciple
no runtime error, but it didnt take the weapons or gave the weapon. =(

Posted: September 4th, 2007, 4:36 pm
by Deadly
lol for real im nto sure. try to re-do the whole script. and even undo the entities on the map and re name them something else

Posted: September 4th, 2007, 8:22 pm
by Nightmare
A couple of questions:
Is your trigger for removing the weapons a trigger/multiple?
Is your trigger for receiving the damage a trigger/damage?
How could you give damage to a trigger if your weapons are removed?
Whats the runtime error displayed? (Type in /developer 1 in console before running the map to get a detailed view of the error)

And Deadly, be nicer to others :)

NM

Posted: September 4th, 2007, 8:31 pm
by Tehdisciple
Yes it is trigger multiple for taking away weapons
Yes it is trigger damage for giving weapons.
I have pistols after spawn.
parameter 1 does no exist: (file 'maps\mp\gametypes\_lev.gsc', line 1075 self.fpshud setValue();
thats first part of error

Thx for telling deadly. =D

Posted: September 4th, 2007, 8:59 pm
by Nightmare
well that error happens with the save mod when you run developer mode, it has nothing to do with the map. When testing the map, don't save and load.
Go ahead and try again

nm

Posted: September 4th, 2007, 9:02 pm
by Tehdisciple
the runtime error didnt come up when i was saving/loading, it came up after i chose a weapon and was about to spawn

Posted: September 6th, 2007, 3:02 pm
by Drofder2004
Deadly wrote:lol. disciple doesnt care. and if you do.... i know where you live.... mu hahahahaa.
Message deleted. This is not the "CoDJumper General chat" area, if it isnt helpful, its not welcome.

Ok, lets run through the script...

Code: Select all

arena_onSpawn()
{
   trig = getent("arena_trig","targetname");

   while(1)
   {
      trig waittill("trigger", user);
      self takeAllWeapons();
      wait 0.5;
   }
}
First problem, it above.

You tell the trigger [trig] to wait until the player [user] triggers it.
You then say SELF take all weapons.

SELF refers to the entity which CALLED the thread, because you have no entity calling the event, self becomes level.

So, what your code is asking, is that the level be removed of its weapons, (obviously this will do nothing, as a level has no weapon).

Change SELF for USER.


Ok, the next problem is the second thread, its the same problem, except it gets a little more complicated.
This time you are using a damage trigger, which measures how much damage it received [idamage], so you need to make a slight adjustment to that...

Code: Select all

trig waittill ("damage", idamage, user);
and then finally, again, change SELF for USER.