Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, Quad, 1 invisible), 721 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
sending array #438853
03/22/14 15:01
03/22/14 15:01
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Hey,

it is me spamming the multiplayer boards again, sry grin. Anyway, my game instantly crashes when I send an array (where I save a handle of an entity in) from the server to the client, in the on_server_event. If I just send a var with the handle, instead of an array, I get no crash.

Is it not possible sending arrays with handles?

Re: sending array [Re: Reconnoiter] #438854
03/22/14 15:44
03/22/14 15:44
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Sending arrays should be possible. But you have an error in your code in line 23.


Always learn from history, to be sure you make the same mistakes again...
Re: sending array [Re: Uhrwerk] #438873
03/22/14 18:54
03/22/14 18:54
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Line 23? You mean error message or diag or something like that?

Re: sending array [Re: Reconnoiter] #438874
03/22/14 19:05
03/22/14 19:05
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
It was a gentle hint that it's kind of pointless to ask for help when not posting your code. How are we supposed to tell you why its not working when you're not showing us what you did?


Always learn from history, to be sure you make the same mistakes again...
Re: sending array [Re: Uhrwerk] #438888
03/22/14 21:47
03/22/14 21:47
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
I thought that maybe it was not possible or something like that.

Here is the code that saves the handle of players (up to 8 players in theory), I let player 2 (client) wait for testing purposes:

Code:
ENTITY* pointer_player[9] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; 
var player_handle[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // stores the handle to the player
....
....

wait(-3); //wait till client has received player handles
if (connection == 2) while(1) { wait(1); }
   
   //create player
   var i;
   for(i = 1; i < 9; i++)
   {
    if (pointer_player[i] == NULL) { pointer_player[i] = ent_create("MDL_Player.mdl",vector(0,0,100),player_control);  	
    wait(-2); // wait until the handle is ready
    player_handle[i] = handle(pointer_player[i]);
    break;
    }
   }



And here is the code that sends the handle from the server to the client:

Code:
function on_server_event(void *pVarPtr, var id) // automatically assigned to on_server
{
    if (event_type == EVENT_JOIN) {
    var i;
    for(i = 1; i < 9; i++) { 
    if (player_handle[i] != 0) send_var_id(id,player_handle[i]); } // send init handles
    }	
...



I start the server+client (/connection = 3) first, that works fine. Than I join as client after >10 seconds and get an instant crash without an error message.

Thanks for watching.

Re: sending array [Re: Reconnoiter] #438889
03/22/14 22:03
03/22/14 22:03
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
Id love to see the receive code too if theres some.
Also you should use send_data_id instead of sending the shit in a for loop because of overhead and cuz its just simplier, saves lines of code and is even faster^^

Re: sending array [Re: Ch40zzC0d3r] #438890
03/22/14 22:18
03/22/14 22:18
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
send_var_id expects a pointer to a user defined variable / struct. You're passing an entity pointer to it.

http://www.conitec.net/beta/asend_var.htm !


Always learn from history, to be sure you make the same mistakes again...
Re: sending array [Re: Uhrwerk] #438914
03/23/14 14:06
03/23/14 14:06
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Thanks for the comments.

Quote:
Id love to see the receive code too if theres some.
, there is none. I check on the client within a while loop if the player_handle var array is not 0 and if the pointer is null and than retrieve the pointer through ptr_handle. But for testing purposes I disabled it and other functions that manipulate the player pointers.

Quote:
Also you should use send_data_id instead of sending the shit in a for loop because of overhead and cuz its just simplier, saves lines of code and is even faster^^
, sounds like a good idea, thanks laugh.

Quote:
send_var_id expects a pointer to a user defined variable / struct. You're passing an entity pointer to it.
, sry but I don't get this. Am I not sending an array (where the entity handle is saved in) through instead of an entity pointer? And why does it work when I send the handle through a var instead of an array?:

Code:
var player_handle_test = 0;
...
...
pointer_player_test = ent_create("MDL_Player.mdl",vector(0,0,100),player_control);  
wait(-2); // wait until the handle is ready
player_handle_test = handle(pointer_player[i]);
...
...
if (player_handle_test != 0) send_var_id(id,player_handle_test);



So many questions grin

Re: sending array [Re: Reconnoiter] #438915
03/23/14 14:37
03/23/14 14:37
Joined: Nov 2006
Posts: 497
Ohio
xbox Offline
Senior Member
xbox  Offline
Senior Member

Joined: Nov 2006
Posts: 497
Ohio
Quote:
Quote:
send_var_id expects a pointer to a user defined variable / struct. You're passing an entity pointer to it.
, sry but I don't get this. Am I not sending an array (where the entity handle is saved in) through instead of an entity pointer? And why does it work when I send the handle through a var instead of an array?:


When passing the variable, it works because "send_var_id expects a pointer to a user defined variable" and your variable is just simply a variable you defined. When you try to pass it via array, "You're passing it an entity pointer" which it does not accept because your array is of type ENTITY*, therefore the crash.

Re: sending array [Re: xbox] #438928
03/23/14 18:14
03/23/14 18:14
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
This is my array that contains the handle:

Code:
var player_handle[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // stores the handle to the player



So have I defined it wrong for send_var_id?

Sry I am kind of newb at this.

Page 1 of 2 1 2

Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1