annoying error

Post your scripting questions / solutions here

Moderator: Moderators

User avatar
dude77
Corporal
Posts: 49
Joined: Tue Sep 01, 2009 8:37 pm

annoying error

Post by dude77 »

i made a small map and got 1 allied soldier to follow me, when i go into a room with a german in it it freezes and quits me out from the game and on the console it says this:

~~script error: cannot cast 'NIL' to float
wait self.waittime (global/friendly.scr, 1172)

~~script error: cannot cast 'NIL' to float
while (isalive self) (global/friendly.scr, 228)

***********************************
ERROR: Command Overflow. Possible infinite loop in thread.
***********************************
----- server shutdown -----
==== shutdown game ====

-----------------------------------



any help :(
Aprop
Major
Posts: 291
Joined: Mon Nov 17, 2008 3:40 pm

Post by Aprop »

Can you post your map scripts?
Do you have any infinite loops in scr, like

Code: Select all

while(1)
{
      ......
}
without 'wait' cmds inside?
...or try setting waittime to float, on initialization, eg:
$myaliedsoldier.waittime = 5 //see m3l2.scr for correct value
User avatar
dude77
Corporal
Posts: 49
Joined: Tue Sep 01, 2009 8:37 pm

Post by dude77 »

xec global/auto.scr

level waittill prespawn
level waittill spawn

//---------------------------------------------------------------------------
main:
//---------------------------------------------------------------------------

waitthread InitPlayer
end


level.friendly1.targetname = friend1
level.friendly2.targetname = friend2
level.friendly3.targetname = friend3

thread FriendWait

end

$friend1.destination = $player
$friend2.destination = $player
$friend3.destination = $player

// Sets the type of friendly soldier
$friend1.friendtype = 1
$friend2.friendtype = 1
$friend3.friendtype = 1

// stagger how far away they keep from their destinations
$friend1.distance = 175
$friend2.distance = 225
$friend3.distance = 250

// setup the friendlies to follow the player...
$friend1 thread global/friendly.scr::friendlythink
$friend2 thread global/friendly.scr::friendlythink
$friend3 thread global/friendly.scr::friendlythink

end


----------------------------------------------------

there dosent appear to be any loops but the computer dosent seem to like the last part of the script, apparently that loops, u know more about this than me.

write back asap
Smithy
Corporal
Posts: 46
Joined: Fri Aug 18, 2006 8:54 pm
Location: United Kingdom

Post by Smithy »

exec global/auto.scr

level waittill prespawn
level waittill spawn

//---------------------------------------------------------------------------
main:
//---------------------------------------------------------------------------

waitthread InitPlayer //You have no "InitPlayer" thread in your script, me thinks you copied this from a stock map or test_ai?
end

level.friendly1.targetname = friend1
level.friendly2.targetname = friend2
level.friendly3.targetname = friend3

thread FriendWait //You have no "FriendWait" thread in your script

end

$friend1.destination = $player
$friend2.destination = $player
$friend3.destination = $player

// Sets the type of friendly soldier
$friend1.friendtype = 1
$friend2.friendtype = 1
$friend3.friendtype = 1

// stagger how far away they keep from their destinations
$friend1.distance = 175
$friend2.distance = 225
$friend3.distance = 250

// setup the friendlies to follow the player...
$friend1 thread global/friendly.scr::friendlythink
$friend2 thread global/friendly.scr::friendlythink
$friend3 thread global/friendly.scr::friendlythink

end
exec global/auto.scr

level waittill prespawn
level waittill spawn

//----------------------------------------------------------------------------
main:
//----------------------------------------------------------------------------

thread FriendInit //or waitthread FriendInit

end

//----------------------------------------------------------------------------
FriendInit:
//----------------------------------------------------------------------------


level.friendly1.targetname = friend1
level.friendly2.targetname = friend2
level.friendly3.targetname = friend3


$friend1.destination = $player
$friend2.destination = $player
$friend3.destination = $player

// Sets the type of friendly soldier

$friend1.friendtype = 1
$friend2.friendtype = 1
$friend3.friendtype = 1

// stagger how far away they keep from their destinations

$friend1.distance = 175
$friend2.distance = 225
$friend3.distance = 250

// setup the friendlies to follow the player...

$friend1 thread global/friendly.scr::friendlythink
$friend2 thread global/friendly.scr::friendlythink
$friend3 thread global/friendly.scr::friendlythink

end
I think that would be better?
User avatar
dude77
Corporal
Posts: 49
Joined: Tue Sep 01, 2009 8:37 pm

Post by dude77 »

didnt seem to help, as soon as my ally encounters the german it freezes up and exits the game :evil:
Aprop
Major
Posts: 291
Joined: Mon Nov 17, 2008 3:40 pm

Post by Aprop »

Do you have any triggers near that room?
Remove'em...
and replace exec global/auto.scr with exec global/friendly.scr
User avatar
dude77
Corporal
Posts: 49
Joined: Tue Sep 01, 2009 8:37 pm

Post by dude77 »

i dont have any triggers
i'll change that and see how it goes
thanks
User avatar
dude77
Corporal
Posts: 49
Joined: Tue Sep 01, 2009 8:37 pm

Post by dude77 »

Aprop wrote:Do you have any triggers near that room?
Remove'em...
and replace exec global/auto.scr with exec global/friendly.scr

i done that but now the music wont play and he wont follow me, but the error dosent come up?
thanks
any other ideas?
User avatar
dude77
Corporal
Posts: 49
Joined: Tue Sep 01, 2009 8:37 pm

Post by dude77 »

please people i really want to know how to get this working!!! if u manage to get allied soldiers to follow you AND attack enemy soliders in a single game tell me how you did it, i wont need an error solution if u can tell me!!
:D
Smithy
Corporal
Posts: 46
Joined: Fri Aug 18, 2006 8:54 pm
Location: United Kingdom

Post by Smithy »

dude77 wrote:please people i really want to know how to get this working!!! if u manage to get allied soldiers to follow you AND attack enemy soliders in a single game tell me how you did it, i wont need an error solution if u can tell me!!
:D
Just realised, at the top you said you have 1 ally, this script is for 3 allies lol. Thus "friendly1 2 3" etc...

You need to have 3 and give each ally a targetname of friendly.

I.E.

Key: $targetname

Value: friendly

Then you need to set their #fnum, you can also set their #friendtype.

I.E.

Key: #fnum

Value: 1

Key: #fnum

Value: 2

Key: #fnum

Value: 3


Otherwise you'll have to edit the script again for just one ally.

exec global/auto.scr

level waittill prespawn
level waittill spawn

//----------------------------------------------------------------------------
main:
//----------------------------------------------------------------------------

thread FriendInit //or waitthread FriendInit

end

//----------------------------------------------------------------------------
FriendInit:
//----------------------------------------------------------------------------


level.friendly1.targetname = friend1


$friend1.destination = $player


// Sets the type of friendly soldier

$friend1.friendtype = 1

// stagger how far away they keep from their destinations

$friend1.distance = 175

// setup the friendlies to follow the player...

$friend1 thread global/friendly.scr::friendlythink

end
Give him an #fnum of 1 and the $targetname friendly.
User avatar
dude77
Corporal
Posts: 49
Joined: Tue Sep 01, 2009 8:37 pm

Post by dude77 »

it still dosent work!! he follows me fine, but when he meets an enemy it still freezes!!
theres defenitely something wrong with the script, i took it out and he kills enemies fine....
maybe i didnt understand your post,
could you possibly do the script for me?

thanks
Aprop
Major
Posts: 291
Joined: Mon Nov 17, 2008 3:40 pm

Post by Aprop »

You can use your own script to control soldiers... this should work for you, of course you have to change $cappy to your soldier targetname

Code: Select all

main:

level waittill spawn
wait 1
$cappy thread follow $player 1000 5


end



follow local.player local.distance local.wait:		

self.destination = local.player
self.distance = local.distance

if (self.distance <= 10)
{
	self.distance = 50
}

while (isalive self)
{

	if !(vector_within self.origin self.destination.origin self.distance)
	{
		self runto self.destination
	}
	wait local.wait
}
end
ps:
dude, I'd like to see your map and scr file to find out what cause crash....
User avatar
dude77
Corporal
Posts: 49
Joined: Tue Sep 01, 2009 8:37 pm

Post by dude77 »

um, ok, thanks for the post by the way,
havent tried it yet, how do i send you my map file??
HeavenBound
Colour Sergeant
Posts: 85
Joined: Thu Sep 11, 2008 12:55 am

Post by HeavenBound »

Post it. lol
HeavenBound

I'm new at this :)
User avatar
dude77
Corporal
Posts: 49
Joined: Tue Sep 01, 2009 8:37 pm

Post by dude77 »

yeah but how?? theres no option to 'post map',
i would if i new how!?
Post Reply