Help in object creating
#1

I want to create an object in different places using variables.

Код:
#define MAX_LOCKER			2
enum __lockerDat
{
	Float:lockerPos[12],
	lockerID
}

new lockerData[MAX_LOCKER][__lockerDat] =
{
    {{-36.9, -91.6, 1003, 0, 0, 180, -1, -1, -1, 200.0, 0.0}}, // object (man_safenew) (1)
    {{-18.2, -49.6, 1003, 0, 0, 316, -1, -1, -1, 200.0, 0.0}}
};

forward loadlockerData();
public loadlockerData()
{
	for(new i = 0; i < MAX_LOCKER; i++)
	{
		lockerData[i][lockerPlace][0] = CreateDynamicObject(1829, lockerData[i][lockerPos][0], lockerData[i][lockerPos][1], lockerData[i][lockerPos][2], lockerData[i][lockerPos][3], lockerData[i][lockerPos][4], lockerData[i][lockerPos][5], lockerData[i][lockerPos][6], lockerData[i][lockerPos][7], lockerData[i][lockerPos][8], lockerData[i][lockerPos][9], lockerData[i][lockerPos][10], lockerData[i][lockerPos][11]);
		lockerData[i][lockerID] = i;
	}
	return 1;
}
I tried this but it's not working, what to do?
Reply
#2

Bump... Someone help please?
Reply
#3

check the coordinates if they are good, and logs from the server may have errors
Reply
#4

Still.. Someone help
Reply
#5

Put a printf line above the CreateDynamicObject, and output the data that CreateDynamicObject is going to be receiving... Then you'll see exactly what it's actually getting.
Reply
#6

check if streamer is ok

and try

{-36.9, -91.6, 1003, 0, 0, 180}
...

the other data of the objects leave them as they are set in the streamer.
you only need the coordinates where you want to put the object.
Reply
#7

Quote:
Originally Posted by Florin48
Посмотреть сообщение
and try

{-36.9, -91.6, 1003, 0, 0, 180}
That's plain out terrible advice... Please learn enums and such before suggesting this again.


There's 12 fields defined, so when it hits this code, it WILL error out saying there's not enough params, or such.

And it's not the streamer that would error, the compiler should fail and give the error at compile time.
Reply
#8

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
That's plain out terrible advice... Please learn enums and such before suggesting this again.


There's 12 fields defined, so when it hits this code, it WILL error out saying there's not enough params, or such.

And it's not the streamer that would error, the compiler should fail and give the error at compile time.
You can define arrays with data and leave out as many entries as you wish (eg only 2 values for an array with the size of 5). The rest will be initialized with zeros.


The problem here is that all entries of lockerPos are Float values, but later they are used for all arguments of CreateDynamicObject (eg. playerid, virtualworld or interior) and are passed as int representation of the Float values.

That means -1.0 will not be passed as -1 and the object will have wrong properties, it will probably not show in any of the virtual worlds, interiors etc.

@OP The best solution would be to not use an embedded array here. It's not neccessary.

Define the lockers like this:

Код:
enum ___lockerDat
{
Float:lockerX,
Float:lockerY,
Float:lockerZ,
Float:lockerRX,
Float:lockerRY,
Float:lockerRZ
lockerVirtualWorld,
lockerPlayerID,
lockerInterior,
Float:lockerStreamDistance,
lockerID
};

new Lockers[MAX_LOCKER][___lockerDat] =
{
{-36.9, -91.6, 1003, 0, 0, 180, -1, -1, -1, 200.0, 0},
// etc..
};
Or just embed the actual coords in one array, but do not mix integer and Float values in one Array without enum.
Reply
#9

Quote:
Originally Posted by NaS
Посмотреть сообщение
You can define arrays with data and leave out as many entries as you wish (eg only 2 values for an array with the size of 5). The rest will be initialized with zeros.
Is there any way of making a 'default' (Like 200) rather than having it 0?


But really, the reason for my post was the idea of the constant 'try this' spam that's being thrown around on the forums. No explanations, no reasons for any changes, no showing where any changes are, often with a 'hope this helped' signoff.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)