2 registered members (Akow, SBGuy),
1,423
guests, and 7
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: can't send to specific entity... -_-' send_skill_id
[Re: PrenceOfDarkness]
#349909
12/12/10 09:00
12/12/10 09:00
|
Joined: Sep 2003
Posts: 929
Spirit
Moderator
|
Moderator
Joined: Sep 2003
Posts: 929
|
Yes. This is my very minimum multiplayer script, its straight from the documentation:
function main()
{
... // do some initialization
if(!session_connect(app_name,"")) // no client found on the localhost?
session_open(app_name); // start as server
// => IMPORTANT!!
while(dplay_status < 2) wait(1); // wait until the session is opened or joined
dplay_localfunction = 2;
level_load("level.wmb");
while(dplay_status < 6) wait(1); // wait until the level is up to date
if (connection & CONNECT_SERVER) {
// do server stuff...
} else {
// do client stuff...
}
... // do more initialization...
}
All this must be also in your script. You can not write a multiplayer script without reading the manual or tutorial!! Your code posted here looks different to the examples, it contains many lines that make no sense to me, but essential things are missing. When you create a client player in a multiplayer game, you must wait until its ID becomes valid before you can send its skills to the other clients:
while(!my.client_id) wait(1);
All this is in the tutorial. When you understand how the basic stuff works, then you can use more advanced functions like sending skills to a certain client.
|
|
|
Re: can't send to specific entity... -_-' send_skill_id
[Re: Spirit]
#349964
12/12/10 19:56
12/12/10 19:56
|
Joined: Aug 2004
Posts: 1,305 New York
PrenceOfDarkness
OP
Serious User
|
OP
Serious User
Joined: Aug 2004
Posts: 1,305
New York
|
ok ty but everything in my game was working fine just wanted to send data to individual clients. when get home ill add those lines and let you all know how it works out.
"There is no problem that can't be solved with time and determination." -me prenceofdarkness for instant messages on AIM.
Looking for a model designer PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
|
|
|
Re: can't send to specific entity... -_-' send_skill_id
[Re: PrenceOfDarkness]
#349990
12/13/10 00:54
12/13/10 00:54
|
Joined: Aug 2004
Posts: 1,305 New York
PrenceOfDarkness
OP
Serious User
|
OP
Serious User
Joined: Aug 2004
Posts: 1,305
New York
|
PANEL* testPNL = {
flags = SHOW;
digits(0,0,6.4,*,1,player.skill1);
digits(0,10,6.4,*,1,player.skill98);
digits(0,20,6.4,*,1,dplay_id);
digits(0,30,6.4,*,1,player.client_id);
}
void fPlayer()
{
set(my,TRANSLUCENT);
while(my == NULL){wait(1);beep();}
player = my;
if(connection == 1 || connection == 3)
{
my.skill1 = 100;
}
if(connection == 2)
{
my.skill = 50;
}
while(my.skill1 == 50)
{
wait(-2);
if(connection == 2 && my.skill1 == 50)
{
my.skill98 = dplay_id;
send_skill(my.skill98,0);
beep();
}
}
wait(-0.5);
reset(my,TRANSLUCENT);
if(connection == 2)
{
my.skill1 = 25;
}
while(1)
{
wait(1);
if(connection == 2 && my.skill1 == 25)
{
my.skill98 = dplay_id;
send_skill(my.skill98,0);
while(my.skill1 != 1000)
{
wait(1);
}
}
if(my.skill98 != 0 && (connection == 1 || connection == 3))
{
wait(-1);
my.skill1 = 1000;
beep();
send_skill_id(my.skill98,my.skill1,0);
beep();
my.skill98 = 0;
}
}
}
void main()
{
dplay_localfunction = 2; //run actions on both server and client
while(dplay_status < 2) wait(1);
level_load("valiance.wmb");
while(dplay_status < 6) wait(1);
#ifdef server //if we defined this game as a server
while(connection == 0) {wait(1);} // wait until we have a connection
#endif
#ifdef client //if we defined this game as a client
while(connection == 0) {wait(1);} // wait until we have a connection
#endif
if(connection == 1 || connection == 3)
{
player = ent_create("testing.mdl",vector(100,0,0),fPlayer);
}
}
Okay I made the modification you told me to make and nothing.... Check it out. Also this line of code:
while(!my.client_id) wait(1);
just causes an endless loop. If you would have read my code you would of seen that the entity is being created on the server. ALSO WHICH TUTORIAL ARE YOU TALKING ABOUT? I've looked through all of the tutorial and not one of them talks about send_skill_id. All I want to do is send a skill to a specific client. If it's so simple why is there no example out there? Why can't someone just modify the code I've provided to let it do just that??
Last edited by PrenceOfDarkness; 12/13/10 00:55.
"There is no problem that can't be solved with time and determination." -me prenceofdarkness for instant messages on AIM.
Looking for a model designer PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
|
|
|
Re: can't send to specific entity... -_-' send_skill_id
[Re: Superku]
#349994
12/13/10 02:40
12/13/10 02:40
|
Joined: Aug 2004
Posts: 1,305 New York
PrenceOfDarkness
OP
Serious User
|
OP
Serious User
Joined: Aug 2004
Posts: 1,305
New York
|
Thank you guys very much. I'll check this all out ASAP.
"There is no problem that can't be solved with time and determination." -me prenceofdarkness for instant messages on AIM.
Looking for a model designer PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
|
|
|
Re: can't send to specific entity... -_-' send_skill_id
[Re: PrenceOfDarkness]
#349995
12/13/10 02:49
12/13/10 02:49
|
Joined: Aug 2004
Posts: 1,305 New York
PrenceOfDarkness
OP
Serious User
|
OP
Serious User
Joined: Aug 2004
Posts: 1,305
New York
|
PANEL* testPNL = {
flags = SHOW;
digits(0,0,6.4,*,1,player.skill1);
digits(0,10,6.4,*,1,player.skill98);
digits(0,20,6.4,*,1,dplay_id);
digits(0,30,6.4,*,1,player.client_id);
}
void fPlayer()
{
while(my.client_id < 0) wait(1);
set(my,TRANSLUCENT);
while(my == NULL){wait(1);}
player = my;
if(connection == 1 || connection == 3)
{
my.skill1 = 100;
}
if(connection == 2)
{
my.skill1 = 50;
}
//my.ENABLE_RECEIVE = ON; // sensible for this event
my.emask |= ENABLE_RECEIVE;
while(my.skill1 == 50)
{
wait(-2);
if(connection == 2 && my.skill1 == 50)
{
my.skill98 = dplay_id;
send_skill(my.skill98,0);
beep();
}
}
wait(-0.5);
reset(my,TRANSLUCENT);
if(connection == 2)
{
my.skill1 = 25;
}
while(1)
{
wait(1);
if(connection == 2 && my.skill1 == 25)
{
my.skill98 = dplay_id;
send_skill(my.skill98,0);
while(my.skill1 != 1000)
{
wait(1);
}
break;
}
if(my.skill98 != 0 && (connection == 1 || connection == 3))
{
wait(-1);
my.skill1 = 1000;
send_skill_id(my.skill98,my.skill1,0);
my.skill98 = 0;
}
}
beep();
beep();
beep();
}
void main()
{
dplay_localfunction = 2; //run actions on both server and client
while(dplay_status < 2) wait(1);
level_load("valiance.wmb");
while(dplay_status < 6) wait(1);
#ifdef server //if we defined this game as a server
while(connection == 0) {wait(1);} // wait until we have a connection
#endif
#ifdef client //if we defined this game as a client
while(connection == 0) {wait(1);} // wait until we have a connection
#endif
if(connection == 1 || connection == 3)
{
player = ent_create("testing.mdl",vector(100,0,0),fPlayer);
}
}
I made all the changes you guys suggested... Simply put the client hangs in that loops forever never having it's skill1 updated to 1000.
"There is no problem that can't be solved with time and determination." -me prenceofdarkness for instant messages on AIM.
Looking for a model designer PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
|
|
|
Re: can't send to specific entity... -_-' send_skill_id
[Re: PrenceOfDarkness]
#350038
12/13/10 13:28
12/13/10 13:28
|
Joined: Feb 2009
Posts: 2,154
Damocles_
Expert
|
Expert
Joined: Feb 2009
Posts: 2,154
|
But connection 1 and 3 mean, that the player gets created on the server.
Try to let the client create the player entity:
if(connection == 2) { player = ent_create("testing.mdl",vector(100,0,0),fPlayer); }
Else, the player does not belong to the client, but is spawed by the server, and it would not change the client_id
"client_id: # On a server, this variable is automatically set on all entites created by a client. # A7.70 On a client, this variable is set to a negative value until the server confirmed the creation of a global entity and the handle becomes valid. Then client_id is set to dplay_id. "
|
|
|
Re: can't send to specific entity... -_-' send_skill_id
[Re: Damocles_]
#350051
12/13/10 14:43
12/13/10 14:43
|
Joined: Aug 2004
Posts: 1,305 New York
PrenceOfDarkness
OP
Serious User
|
OP
Serious User
Joined: Aug 2004
Posts: 1,305
New York
|
Okay sorry guys... the player pointer isn't a player it's just a pointer... JCL believe my code is a complete mess and I completely agree with him. So I decided to rewrite it using the multiplayer tutorial as a base. Also this time I'll actually explain what I'm trying to do. I have items in my RPG... Theses items have an ID number that determines the type of item it is. When a player kills a monster the monster drops an item and a random ID number is assigned to it. Now lets say there is an item on the ground and a client joins the game. Naturally the item's ID number will be zero (because all skills start at 0). Now what I've been doing until now is simply telling the server to tell all clients the ID Number any time a new client joins. This is stupid because all the other clients already know the item's ID number. In order to save traffic I just want to send the information to the new client. So let's recap: 1) I need to create an item on the server machine. 2) The item must be assigned an ID number (This must be done on the server) and all connected clients must be informed of the item's ID number. 3) If a new client joins that doesn't know the item's ID number this new client (and alone this client) must be updated. 4) I have read (many times over) the tutorials although I will admit I did miss a thing or two, BUT my game works fine and I have ZERO problems when things are sent to all clients. I've had problems sending information to individual clients for years now. If you look me up on the forums you'll realize I'm not constantly having new problems with multiplayer... IT'S THE SAME PROBLEM. I keep just letting the thread die because I'm hoping that over time someone else would have posted something or whatever but now my game is getting to the point where I need this. I want to release a demo soon. I have a mySQL database working and everything else is working fine. This is all I need now and I can't put it off any longer. I decided to clean up my code. There is no way I can make it easier then this:
ENTITY* item; //a pointer not called player to eliminate confusion
var itemSkill1;//a global variable for the item's skill1 so that the engine doesnt return a "IDK what item.skill1 is" error
var itemClient_id;//this is the items's client_id of the item's maker. This should be zero because the SERVER made this entity
var vClientid; //a variable to indicate the client_id of a client that has just joined
PANEL* testPNL = {
flags = SHOW;
digits(0,0,"item.skill1: %.3f",*,1,itemSkill1);
digits(0,10,"dplay_id: %.3f",*,1,dplay_id);
digits(0,20,"item.client_id: %.3f",*,1,itemClient_id);
digits(0,30,"vClientid: %.3f",*,1,vClientid);
}
function on_server_event(void* str,var id) // automatically assigned to on_server
{
if(event_type == EVENT_JOIN) //if a client joined
{
vClientid = id; //store the ID of the client that just joined into a global variable
}
}
void fItem()
{
while(my.client_id < 0) wait(1); //this item is created on the server there for client_id will be zero but I'll include it anyway
item = my; //this is an item
if(connection & CONNECT_SERVER) //in my game the server would assign the item an ID number so i'll do the same here for skill1
{
my.skill1 = 1000;
}
else //if we're not a server we're a client
{
while(my.skill1 != 1000) //wait until our skill1 because the value we know it should be. In this case 1000
{
itemSkill1 = my.skill1; //since we're locked in this loop forever because send_skill_id isn't working I want
itemClient_id = my.client_id;//to update our client_id and skill1 values.
wait(1);
}
}
while(1)
{
wait(1);
itemSkill1 = my.skill1; //this only works on the server because the client never makes it to this point
itemClient_id = my.client_id; //because it's skill1 never changes from zero
if(connection & CONNECT_SERVER)
{
send_skill_id(vClientid,my.skill1,0); //the server sends the vClientid FOREVER but the client never seems to receive it
} //regardless of the fact that the client's dplay_id is equal to vClient_id which
else //is the where the server is sending information to.
{
if(my.skill1 != 0) //if the client would ever make it to this point the problem is solved and we break out of the while loop
{
break;
}
}
}
beep(); //two beeps indicate success!!
beep();
}
on_server = on_server_event; //if a client joins two parameters are passed: the player's name and the client identification number
//this is all in the manual if you look up on_server.
void main()
{
if (!connection) { // not started with -cl / -sv -cl?
if (!session_connect(app_name,"")) // no client found on the localhost?
session_open(app_name); // start as server
}
do{wait(1);}
while(dplay_status < 2); // wait until the session is opened or joined
dplay_localfunction = 2; //run actions on both server and client
level_load("valiance.wmb"); // load the level
if(connection & CONNECT_SERVER) //are we a server?
{
ent_create("testing.mdl",vector(100,0,0),fItem); //OMG a monster was killed!!! Drop an item ont he server!
}
}
So there you go so now everyone knows what's going on. IMO send_skill_id simply isn't working. edit: send_skill_id IS sending the information HOWEVER the client never receives it. You can download the file I posted earlier and just delete the test.c and replace it with this new script.
Last edited by PrenceOfDarkness; 12/13/10 15:03.
"There is no problem that can't be solved with time and determination." -me prenceofdarkness for instant messages on AIM.
Looking for a model designer PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
|
|
|
Re: can't send to specific entity... -_-' send_skill_id
[Re: PrenceOfDarkness]
#350066
12/13/10 15:28
12/13/10 15:28
|
Joined: Aug 2004
Posts: 1,305 New York
PrenceOfDarkness
OP
Serious User
|
OP
Serious User
Joined: Aug 2004
Posts: 1,305
New York
|
UPDATE: JCL confirms there is a problem with send_skill_id and it will be fixed in A8.10. I'm trying to convince him to release this one fix for A7 as well. http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=350071&#Post350071
Last edited by PrenceOfDarkness; 12/13/10 15:38.
"There is no problem that can't be solved with time and determination." -me prenceofdarkness for instant messages on AIM.
Looking for a model designer PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
|
|
|
|