Page MenuHomeFeedback Tracker

Error when using array parameters.
Closed, ResolvedPublic

Description

When you add an element of type parameter to the parameter array, the element is not assigned, but is NULL.

Details

Severity
Minor
Resolution
Open
Reproducibility
N/A
Operating System
Windows 7
Category
Modding
Steps To Reproduce

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));

Additional Information

In the log:

Param2<vector,int><94fb7990>
NULL

Event Timeline

DayzLab created this task.Sep 20 2018, 3:36 PM
Cid added a subscriber: Cid.EditedSep 20 2018, 6:29 PM

What informations give :

Print(ListZone.Count());
ListZone.Debug();

SCRIPT : string s = 'Array count: 1'
SCRIPT : string s = '[0] => Param2<vector,int><9800ccb0>'

Cid added a comment.EditedSep 20 2018, 10:18 PM

.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>;

tom_48_97 closed this task as Resolved.Nov 22 2018, 3:52 PM
tom_48_97 claimed this task.
tom_48_97 added a subscriber: tom_48_97.

So I guess I can close this :)