I tried long time ago to do my test goal:
#include Library_Goal
local orangepoints;
local whitepoints;
protected func Initialize()
{
orangepoints = 0;
whitepoints = 0;
}
public func IsFulfilled(int player)
{
if(GetPlayerTeam(player)==1)&&(orangepoints>12))
return true;
if(GetPlayerTeam(player)==2)&&(whitepoints>12))
return true;
return false;
}
public func addorn()
{
orangepoints+=1;
}
public func addwhi()
{
whitepoints+=1;
}
and in one of object have this:
FindObject(Find_ID(Goal_WinTM))->addorn();
But it doesn't work. Why? And how to fix it ?
I add this goal by:
CreateObject(Goal_WinTM, 0, 0, NO_OWNER);
#include Library_Goal
local orangepoints;
local whitepoints;
protected func Initialize()
{
orangepoints = 0;
whitepoints = 0;
}
public func IsFulfilled(int player)
{
if(GetPlayerTeam(player)==1)&&(orangepoints>12))
return true;
if(GetPlayerTeam(player)==2)&&(whitepoints>12))
return true;
return false;
}
public func addorn()
{
orangepoints+=1;
}
public func addwhi()
{
whitepoints+=1;
}
and in one of object have this:
FindObject(Find_ID(Goal_WinTM))->addorn();
But it doesn't work. Why? And how to fix it ?
I add this goal by:
CreateObject(Goal_WinTM, 0, 0, NO_OWNER);
Mh, one reason could be that the Library_Goal does something itself in the function Initialize() and you overwrite that function with your own Initialize().
You can call the original Initialize() with _inherited.
Your Initialize() would then look like that:
You can call the original Initialize() with _inherited.
Your Initialize() would then look like that:
protected func Initialize()
{
orangepoints = 0;
whitepoints = 0;
return _inherited();
}
I fix it:
it was:
if(GetPlayerTeam(player)==1)&&(orangepoints>12))
but should be like:
if((GetPlayerTeam(player)==1)&&(orangepoints>12))
:P
it was:
if(GetPlayerTeam(player)==1)&&(orangepoints>12))
but should be like:
if((GetPlayerTeam(player)==1)&&(orangepoints>12))
:P
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill