Post your scripting questions / solutions here
Moderator: Moderators
SilentAngel
Captain
Posts: 239 Joined: Wed Mar 12, 2008 8:27 pm
Post
by SilentAngel » Mon Apr 27, 2009 6:59 pm
someone can tell me what's wrong with this?
Code: Select all
main:
level waittill prespawn
local.timeleft = (int(getcvar"timelimit")) * 60
thread global/sp_initial.scr::variables_declaration
thread main_of_the_mod
main_of_the_mod:
while ( local.timeleft > 0 )
{
wait 1
local.new_time = local.timeleft - 1
local.timeleft = local.new_time
}
while(local.timeleft != 0)
{
thread global/Sp_ingame.scr::look_for_news
waitframe
}
while(local.timeleft != 0)
{
thread global/Sp_ingame.scr::check_for_new_players
waitframe
}
while(local.timeleft != 0)
{
thread global/Sp_ingame.scr::activated
waitframe
}
while(local.timeleft != 0)
{
thread global/Sp_ingame.scr::display_pool
waitframe
}
level waittill spawn
it's causing this error message in console
level waittill prespawn (global/spawnpool-mode.scr, 3)
level ^
^~^~^ Script Error: invalid waittill prespawn for 'Level'
while ( local.timeleft > 0 ) (global/spawnpool-mode.scr, 13)
while ( local.timeleft ^
^~^~^ Script Error: binary '>' applied to incompatible types 'NIL' and 'int'
$oldier Of Ra
Lieutenant Colonel
Posts: 404 Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:
Post
by $oldier Of Ra » Mon Apr 27, 2009 7:07 pm
Your main thread gets activated. local.timeleft is defined. But, there's no end, so the engine continues and stumbles upon "main_of_the_mod:". Since there's no end, local.timeleft is still defined. HOWEVER, you have also threaded to the "main_of_the_mod:" thread, therefore the script starts that thread for a second time and since no variables are passed as arguments, local.timeleft is undefined in that second running thread, hence causing the error.
SilentAngel
Captain
Posts: 239 Joined: Wed Mar 12, 2008 8:27 pm
Post
by SilentAngel » Mon Apr 27, 2009 7:14 pm
let see if I've understood:
it should be something like that..
Code: Select all
main:
level waittill prespawn
local.timeleft = (int(getcvar"timelimit")) * 60
thread global/sp_initial.scr::variables_declaration
main_of_the_mod:
while ( local.timeleft > 0 )
{
wait 1
local.new_time = local.timeleft - 1
local.timeleft = local.new_time
}
while(local.timeleft != 0)
{
thread global/Sp_ingame.scr::look_for_news
waitframe
}
while(local.timeleft != 0)
{
thread global/Sp_ingame.scr::check_for_new_players
waitframe
}
while(local.timeleft != 0)
{
thread global/Sp_ingame.scr::activated
waitframe
}
while(local.timeleft != 0)
{
thread global/Sp_ingame.scr::display_pool
waitframe
}
end
level waittill spawn
$oldier Of Ra
Lieutenant Colonel
Posts: 404 Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:
Post
by $oldier Of Ra » Mon Apr 27, 2009 7:18 pm
Indeed. As a detail these 2 lines are obsolete:
and the lonely
outside of the thread.
SilentAngel
Captain
Posts: 239 Joined: Wed Mar 12, 2008 8:27 pm
Post
by SilentAngel » Mon Apr 27, 2009 7:28 pm
same error
level waittill prespawn (global/spawnpool-mode.scr, 3)
level ^
^~^~^ Script Error: invalid waittill prespawn for 'Level'
and that's what I've done:
Code: Select all
main:
level waittill prespawn
local.timeleft = (int(getcvar"timelimit")) * 60
thread global/sp_initial.scr::variables_declaration
while ( local.timeleft > 0 )
{
wait 1
local.new_time = local.timeleft - 1
local.timeleft = local.new_time
}
while(local.timeleft != 0)
{
thread global/Sp_ingame.scr::look_for_news
waitframe
}
while(local.timeleft != 0)
{
thread global/Sp_ingame.scr::check_for_new_players
waitframe
}
while(local.timeleft != 0)
{
thread global/Sp_ingame.scr::activated
waitframe
}
level waittill spawn
while(local.timeleft != 0)
{
thread global/Sp_ingame.scr::display_pool
waitframe
}
$oldier Of Ra
Lieutenant Colonel
Posts: 404 Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:
Post
by $oldier Of Ra » Mon Apr 27, 2009 7:46 pm
Execute that script before prespawn, then it won't make that error again.
Or delete that line.
The wait is invalid because prespawn has already happened.
SilentAngel
Captain
Posts: 239 Joined: Wed Mar 12, 2008 8:27 pm
Post
by SilentAngel » Mon Apr 27, 2009 7:51 pm
the fact is that I need to exec it from DMprechace, to load it for all maps..maybe delating the wait?
$oldier Of Ra
Lieutenant Colonel
Posts: 404 Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:
Post
by $oldier Of Ra » Mon Apr 27, 2009 7:58 pm
Ah I see and in all stock maps the DMprecache it executed after prespawn hence the error. Well that's no problem, you can execute it in the DMprecache, deleting the waittill prespawn line in your script will prevent the error.