SA-MP Forums Archive
CreateDynamicObjectEx constant experssion? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: CreateDynamicObjectEx constant experssion? (/showthread.php?tid=374522)



CreateDynamicObjectEx constant experssion? - Roko_foko - 03.09.2012

I want to make objects that are visible only for one player with incognitos streamer.
As CreateDynamicObjectEx should look like this:
Код:
native CreateDynamicObjectEx(modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, Float:drawdistance = 0.0, Float:streamdistance = 200.0, worlds[] = { -1 }, interiors[] = { -1 }, players[] = { -1 }, maxworlds = sizeof worlds, maxinteriors = sizeof interiors, maxplayers = sizeof players);
I did it this way:
pawn Код:
CreateDynamicObjectEx(1454, -209.0760,-33.3091,3.0828, 0, 0, 0, 0, 200, {0},{ 0 }, {playerid});
Error that I am getting:
Код:
error 008: must be a constant expression; assumed zero
As constant, I think it is aiming at '{playerid}' (when I put any constant on place of it it's fine). The only solution of this problem that I see is:
pawn Код:
switch(playerid)
{
    case 0:CreateDynamicObjectEx(1454, -209.0760,-33.3091,3.0828, 0, 0, 0, 0, 200, {0},{ 0 }, {0});
    case 1:CreateDynamicObjectEx(1454, -209.0760,-33.3091,3.0828, 0, 0, 0, 0, 200, {0},{ 0 }, {1});
    case 2:CreateDynamicObjectEx(1454, -209.0760,-33.3091,3.0828, 0, 0, 0, 0, 200, {0},{ 0 }, {2});
//...
    case 499:CreateDynamicObjectEx(1454, -209.0760,-33.3091,3.0828, 0, 0, 0, 0, 200, {0},{ 0 }, {499});
}
But it looks crazy. Is there a better solution, and why does it need to be a constant anyway?
Thank you in advance.


Re: CreateDynamicObjectEx constant experssion? - Misiur - 03.09.2012

https://sampforum.blast.hk/showthread.php?tid=102865
check out data manipulation functions - the array ones are what you need


Re: CreateDynamicObjectEx constant experssion? - Roko_foko - 03.09.2012

Thank you very much. But I still don't get it completly.
This is what I tried:
pawn Код:
WheatObj[playerid][i]=CreateDynamicObjectEx(1454, -209.0760,-33.3091,3.0828, 0, 0, 0, 0, 200, {0},{ 0 });
//^erased the {playerid}
Streamer_SetArrayData(STREAMER_TYPE_OBJECT,WheatObj[playerid][i],E_STREAMER_PLAYER_ID,{playerid});
and getting
Код:
 error 008: must be a constant expression; assumed zero
What am I doing wrong?

EDIT:
pawn Код:
WheatObj[playerid][i]=CreateDynamicObjectEx(1454, -209.0760,-33.3091,3.0828, 0, 0, 0, 0, 200, { 0 },{ 0 },{MAX_PLAYERS});
//^MAX_PLAYERS- I had to set something. In case I don't it will be visible for all.
//^playerid that equals MAX_PLAYERS doesn't exist - that is the reason I've put it here.
Streamer_AppendArrayData(STREAMER_TYPE_OBJECT, WheatObj[playerid][i], E_STREAMER_PLAYER_ID, playerid);
I came up to this alternative.
Will this work? ( i want that it's shown only for playerid )


Re: CreateDynamicObjectEx constant experssion? - Misiur - 03.09.2012

It should work, but (you will have array { MAX_PLAYERS, playerid }). Is it possible to pass empty {} there? If not - just try current code


Re: CreateDynamicObjectEx constant experssion? - Roko_foko - 03.09.2012

its not working, but this is. I will try with empty as well and tell you results.
But this does work:
pawn Код:
new WheatObj1=CreateDynamicObjectEx(1454, gPlayerPos[playerid][X],gPlayerPos[playerid][Y],gPlayerPos[playerid][Z], 0, 0, 0, 0, 200, { 0 },{ 0 },{1});
Streamer_RemoveArrayData(STREAMER_TYPE_OBJECT, WheatObj1, E_STREAMER_PLAYER_ID, 1);
Streamer_AppendArrayData(STREAMER_TYPE_OBJECT, WheatObj1, E_STREAMER_PLAYER_ID, playerid);
Thank you very much. You earned rep

Edit: '{}' not working:
Код:
error 029: invalid expression, assumed zero
error 001: expected token: ",", but found ";"
Anyway, the way above edit works.


Re: CreateDynamicObjectEx constant experssion? - Misiur - 03.09.2012

You can check the Streamer_SetArrayData - but I think it requires constant too. I'll dig some more, because this problem is quite common

`e: Oh, didn't see that. Damn I'm tired


Re: CreateDynamicObjectEx constant experssion? - Roko_foko - 03.09.2012

Quote:
Originally Posted by Misiur
Посмотреть сообщение
You can check the Streamer_SetArrayData - but I think it requires constant too. I'll dig some more, because this problem is quite common
You can't with that. Said in 2nd post. No needs for digging. Found the solution.