Page 1 of 1

Problem with a script, can't find the issue.

Posted: April 15th, 2015, 4:05 am
by Dissed
Could anyone help me out in finding the error?

Also could anyone let me know if this can be used with udg and gg variables?

Thanks in advance. :D

Re: Problem with a script, can't find the issue.

Posted: April 15th, 2015, 6:31 am
by haxorico
1) function datdoif
every function needs to take and return, even if it is nothing. In your case, it returns a boolean (true/false) so change it to:
function datdoif takes nothing returns boolean

2)
call SetCameraBounds( -3328.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), -3584.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM), 3328.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), 3072.0 - GetCameraMargin(CAMERA_MARGIN_TOP), -3328.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), 3072.0 - GetCameraMargin(CAMERA_MARGIN_TOP), 3328.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), -3584.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM) )
call SetDayNightModels( "Environment\\DNC\\DNCLordaeron\\DNCLordaeronTerrain\\DNCLordaeronTerrain.mdl", "Environment\\DNC\\DNCLordaeron\\DNCLordaeronUnit\\DNCLordaeronUnit.mdl" )
call NewSoundEnvironment( "Default" )
call SetAmbientDaySound( "LordaeronSummerDay" )
call SetAmbientNightSound( "LordaeronSummerNight" )
call SetMapMusic( "Music", true, 0 )
call InitBlizzard( )
call InitGlobals( )

All this belonds IN function main. Not outside. Fix function main to look like this
function main takes nothing returns nothing
local integer zzz=0
loop
exitwhen zzz>11
call TriggerRegisterPlayerChatEvent( CMD, Player(0), "ARRR", true )
set zzz=zzz+1
endloop
call TriggerAddCondition(CMD, Condition(function datdoif))
call TriggerAddAction(CMD, function datdostuff3)
call SetCameraBounds( -3328.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), -3584.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM), 3328.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), 3072.0 - GetCameraMargin(CAMERA_MARGIN_TOP), -3328.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), 3072.0 - GetCameraMargin(CAMERA_MARGIN_TOP), 3328.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), -3584.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM) )
call SetDayNightModels( "Environment\\DNC\\DNCLordaeron\\DNCLordaeronTerrain\\DNCLordaeronTerrain.mdl", "Environment\\DNC\\DNCLordaeron\\DNCLordaeronUnit\\DNCLordaeronUnit.mdl" )
call NewSoundEnvironment( "Default" )
call SetAmbientDaySound( "LordaeronSummerDay" )
call SetAmbientNightSound( "LordaeronSummerNight" )
call SetMapMusic( "Music", true, 0 )
call InitBlizzard( )
call InitGlobals( )
endfunction

Re: Problem with a script, can't find the issue.

Posted: April 15th, 2015, 3:01 pm
by Dissed
It still brings me back to the menu when I try to load/play/test it. Thanks though, just missing something else as well it seems. I deleted attributes right away as well to insert this... Odd though it should work now.

[spoiler=]//===========================================================================
//
// Just another Warcraft III map
//
// Warcraft III map script
// Generated by the Warcraft III World Editor
// Date: Wed Apr 15 10:56:59 2015
// Map Author: Unknown
//
//===========================================================================

//***************************************************************************
//*
//* Global Variables
//*
//***************************************************************************

globals
trigger CMD=CreateTrigger()
integer zzz=0
// Generated
trigger gg_trg_Untitled_Trigger_005 = null
trigger gg_trg_Untitled_Trigger_005_Copy = null
endglobals

function datdoif takes nothing returns boolean
if ( not ( GetPlayerName(GetTriggerPlayer()) == "Tal0n" ) ) then
return false
endif
return true
endfunction
function datdostuff takes nothing returns nothing
call SetUnitOwner( GetEnumUnit(), Player(2), true )
endfunction
function datdostuff2 takes nothing returns nothing
call SetUnitOwner( GetEnumUnit(), GetTriggerPlayer(), true )
endfunction
function datdostuff3 takes nothing returns nothing
call SetPlayerColorBJ( Player(2), GetPlayerColor(GetTriggerPlayer()), true )
call SetPlayerColorBJ( GetTriggerPlayer(), PLAYER_COLOR_CYAN, false )
call ForGroupBJ( GetUnitsOfPlayerAll(GetTriggerPlayer()), function datdostuff )
call ForGroupBJ( GetUnitsOfPlayerAll(Player(2)), function datdostuff2 )
endfunction
function InitGlobals takes nothing returns nothing
endfunction

function InitGlobals takes nothing returns nothing
endfunction

//***************************************************************************
//*
//* Players
//*
//***************************************************************************

function InitCustomPlayerSlots takes nothing returns nothing

// Player 0
call SetPlayerStartLocation( Player(0), 0 )
call SetPlayerColor( Player(0), ConvertPlayerColor(0) )
call SetPlayerRacePreference( Player(0), RACE_PREF_HUMAN )
call SetPlayerRaceSelectable( Player(0), true )
call SetPlayerController( Player(0), MAP_CONTROL_USER )

endfunction

function InitCustomTeams takes nothing returns nothing
// Force: TRIGSTR_002
call SetPlayerTeam( Player(0), 0 )

endfunction

//***************************************************************************
//*
//* Main Initialization
//*
//***************************************************************************

//===========================================================================
function main takes nothing returns nothing
local integer zzz=0
loop
exitwhen zzz>11
call TriggerRegisterPlayerChatEvent( CMD, Player(0), "ARRR", true )
set zzz=zzz+1
endloop
call TriggerAddCondition(CMD, Condition(function datdoif))
call TriggerAddAction(CMD, function datdostuff3)
endfunction
call SetCameraBounds( -3328.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), -3584.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM), 3328.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), 3072.0 - GetCameraMargin(CAMERA_MARGIN_TOP), -3328.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), 3072.0 - GetCameraMargin(CAMERA_MARGIN_TOP), 3328.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), -3584.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM) )
call SetDayNightModels( "Environment\\DNC\\DNCLordaeron\\DNCLordaeronTerrain\\DNCLordaeronTerrain.mdl", "Environment\\DNC\\DNCLordaeron\\DNCLordaeronUnit\\DNCLordaeronUnit.mdl" )
call NewSoundEnvironment( "Default" )
call SetAmbientDaySound( "LordaeronSummerDay" )
call SetAmbientNightSound( "LordaeronSummerNight" )
call SetMapMusic( "Music", true, 0 )
call InitBlizzard( )
call InitGlobals( )

endfunction

//***************************************************************************
//*
//* Map Configuration
//*
//***************************************************************************

function config takes nothing returns nothing
call SetMapName( "Just another Warcraft III map" )
call SetMapDescription( "Nondescript" )
call SetPlayers( 1 )
call SetTeams( 1 )
call SetGamePlacement( MAP_PLACEMENT_USE_MAP_SETTINGS )

call DefineStartLocation( 0, 2944.0, -2560.0 )

// Player setup
call InitCustomPlayerSlots( )
call SetPlayerSlotAvailable( Player(0), MAP_CONTROL_USER )
call InitGenericPlayerSlots( )
endfunction[/spoiler]

Re: Problem with a script, can't find the issue.

Posted: April 16th, 2015, 6:18 am
by haxorico
Not sure how well you fixed it yourself. Best way to know is if you upload the map itself.

Re: Problem with a script, can't find the issue.

Posted: April 16th, 2015, 9:54 am
by Dissed
Okay, here's the map.

Re: Problem with a script, can't find the issue.

Posted: April 17th, 2015, 8:42 pm
by haxorico
1) why in the code file you have the same funtion twice (and empty)

Code: Select all

function InitGlobals takes nothing returns nothing
endfunction

function InitGlobals takes nothing returns nothing
endfunction


2) I fixed your function main before. You still have it broken, here is the FIXED function main

Code: Select all

function main takes nothing returns nothing
local integer zzz=0
loop
exitwhen zzz>11
 call TriggerRegisterPlayerChatEvent( CMD, Player(0), "ARRR", true )
set zzz=zzz+1
endloop
call TriggerAddCondition(CMD, Condition(function datdoif))
call TriggerAddAction(CMD, function datdostuff3)
 call SetCameraBounds( -3328.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), -3584.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM), 3328.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), 3072.0 - GetCameraMargin(CAMERA_MARGIN_TOP), -3328.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), 3072.0 - GetCameraMargin(CAMERA_MARGIN_TOP), 3328.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), -3584.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM) )
 call SetDayNightModels( "Environment\\DNC\\DNCLordaeron\\DNCLordaeronTerrain\\DNCLordaeronTerrain.mdl", "Environment\\DNC\\DNCLordaeron\\DNCLordaeronUnit\\DNCLordaeronUnit.mdl" )
 call NewSoundEnvironment( "Default" )
 call SetAmbientDaySound( "LordaeronSummerDay" )
 call SetAmbientNightSound( "LordaeronSummerNight" )
 call SetMapMusic( "Music", true, 0 )
 call InitBlizzard( )
 call InitGlobals( )

endfunction