When you add an element of type parameter to the parameter array, the element is not assigned, but is NULL.
Description
Details
- Severity
- Minor
- Resolution
- Open
- Reproducibility
- N/A
- Operating System
- Windows 7
- Category
- Modding
array<Param> ListZone = new array<Param>;
Param2<vector,int> m_Zone;
m_Zone = new Param2<vector, int>("3000 0 9000", 15);
Print(m_Zone);
ListZone.Insert(m_Zone);
Print(ListZone.Get(0));
In the log:
Param2<vector,int><94fb7990>
NULL
Event Timeline
SCRIPT : string s = 'Array count: 1'
SCRIPT : string s = '[0] => Param2<vector,int><9800ccb0>'
.get() might bug, can you give a try to :
Print(ListZone[0]); int i = 0; Print(ListZone.Get(i));
By the way, how can you execute Enforce Script?
Surprisingly!
SCRIPT : Param2<vector,int><97c6c240>
SCRIPT : Param2<vector,int><97c6c240>
This part also now works correctly:
Print(ListZone.Get(0));
SCRIPT : Param2<vector,int><97c6c240>
However, this only led to clarification of the problem.
class CustomMission: MissionServer { ref array<Param> ListZone = new array<Param>; override void OnInit() { Param2<vector,int> m_Zone; m_Zone = new Param2<vector, int>("3000 0 9000", 15); ListZone.Insert(m_Zone); ListZone.Debug(); Print("===<1>==="); Print(ListZone[0]); int i = 0; Print(ListZone.Get(i)); Print("===<1>==="); GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(CheckZone, 10000, true); } void CheckZone() { ListZone.Debug(); Print("===<2>==="); Print(ListZone[0]); int i = 0; Print(ListZone.Get(i)); Print("===<2>==="); } }
In log:
SCRIPT : string s = 'Array count: 1'
SCRIPT : string s = '[0] => Param2<vector,int><97c6c240>'
SCRIPT : ===<1>===
SCRIPT : Param2<vector,int><97c6c240>
SCRIPT : Param2<vector,int><97c6c240>
SCRIPT : ===<1>===
SCRIPT : string s = 'Array count: 1'
SCRIPT : ===<2>===
SCRIPT : NULL
SCRIPT : NULL
SCRIPT : ===<2>===
Isn't that how I initialize a global variable?
The script is executed on the server in the mission file init.c.
The server version: 0.63.148743
I`m sorry! Found a bug!
The error here:
ref array<Param> ListZone = new array<Param>;
Correct option:
ref array<ref Param> ListZone = new array<ref Param>;