2 registered members (Imhotep, opm),
785
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: sending array
[Re: Reconnoiter]
#438932
03/23/14 18:54
03/23/14 18:54
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
Your array is perfectly fine. But send_var_id expects a pointer to user defined variable. Pointer is the important part here. player_handle[i] is a handle, not a pointer. If you want to pass that specific content you have to pass the address of the variable. For Example &(player_handle[i]). Lite-C takes some of the complexity away for you, by automatically using pointers where appropriate. But this does not work in all cases.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: sending array
[Re: Uhrwerk]
#438959
03/24/14 15:01
03/24/14 15:01
|
Joined: Dec 2011
Posts: 1,823 Netherlands
Reconnoiter
OP
Serious User
|
OP
Serious User
Joined: Dec 2011
Posts: 1,823
Netherlands
|
I first thought that with pointer you meant the entity pointer, I overlooked that the var/array could also have a pointer. But how do write the send line correctly?, I now have tried the following 2 but those resulted in the instant crash:
if (player_handle[i] != 0) send_var_id(id,&player_handle[i]);
if (player_handle[i] != 0) send_var_id(id,&(player_handle[i]));
Thank you for your patience
|
|
|
Re: sending array
[Re: Reconnoiter]
#438974
03/24/14 19:39
03/24/14 19:39
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
I didn't try it, when posting, sorry. My guess was that the second version is the correct one. Are you maybe forced to send the array as a whole?
if (player_handle[i] != 0) send_var_id(id,player_handle);
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: sending array
[Re: xbox]
#438981
03/24/14 21:26
03/24/14 21:26
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
That would return a pointer to an entity of course...
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: sending array
[Re: Uhrwerk]
#439003
03/25/14 10:17
03/25/14 10:17
|
Joined: Dec 2011
Posts: 1,823 Netherlands
Reconnoiter
OP
Serious User
|
OP
Serious User
Joined: Dec 2011
Posts: 1,823
Netherlands
|
Are you maybe forced to send the array as a whole? , bingo, that worked tyty. Now I don't have to use the for loop here . Also this means less overhead right? I don't have any way of testing this, but if you have an array of handles and you need to pass a pointer instead, couldn't you do send_var_id(id, ptr_for_handle(player_handle[i])) , I could be wrong but I have a feeling that sending a handle is more safe (I have it from AUM77).
Last edited by Reconnoiter; 03/25/14 10:21.
|
|
|
Re: sending array
[Re: Reconnoiter]
#439039
03/25/14 19:32
03/25/14 19:32
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
You should always and exclusively send handles. Never ever send pointers! The point was just that you have to pass the pointer to send_var_id. That however is not the same as sending the pointer.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
|