ent_create on client, no function started

Posted By: oliver2s

ent_create on client, no function started - 05/15/07 09:47

I thought this is a simple code, but I spent at least 4 hours of testing and nothing works. The problem is that I create an entity on the client with "ent_create". Now it will be created globally. That works fine. But the function were not started on the server...

Code:
dedicated server is running....
client join....

function sv_player
{
file_cpy("testfile", "player.mdl"); //create a file on harddisk to see if the function were started
}

starter start_game
{
if(connection == 2)
{
level_load("map1.wmb");

wait(-0.5);

player = ent_create("player.mdl", vector(0,0,20), sv_player); // now it should start the sv_player function on the server, but it doesn't
}
}




if I call the sv_player function manually offline the file will be created. Anyone an idea?
Posted By: Captain_Kiyaku

Re: ent_create on client, no function started - 05/15/07 10:53

do you start a server AND a client or server+client together?

Cause connection == 2 is only the client. if you run "-sv -cl" then its connection = 3.

also, does the server load the level too?

did you try to write an "exit;" into "sv_player" to see if the function gets called?
Posted By: oliver2s

Re: ent_create on client, no function started - 05/15/07 11:09

I run a server (-sv) server, the level is loaded correctly, I'm 100% sure. Then I start a client (-cl) which executes the functions above. I also tried exit, but this doesn't work too.
Posted By: Captain_Kiyaku

Re: ent_create on client, no function started - 05/15/07 11:32

are you 100% sure it connects to the correct server? (like does it show "session blabla found" in the loading screen?
Posted By: oliver2s

Re: ent_create on client, no function started - 05/15/07 11:54

Quote:

are you 100% sure it connects to the correct server? (like does it show "session blabla found" in the loading screen?




Yes, I'm 100000% sure. Because I have other functions like showing a message of connected players. This works fine.
Posted By: giorgi3

Re: ent_create on client, no function started - 05/15/07 13:55

This might be some type of timing issue with the startup of the game. I would suggest moving the code to main () and including a wait to make sure the client connection to the server has completed. Something like this:

Code:
  
function sv_player
{
file_cpy("testfile", "player.mdl"); //create a file on harddisk to see if the function were started
}



function main ()
{


level_load("map1.wmb");

wait(-0.5); // make sure the level is fully loaded

ifdef client;
while(connection== 0) {wait(1);} // make sure we have a connection to the server
endif;

if(connection == 2)
{

player = ent_create("player.mdl", vector(0,0,20), sv_player); // now it should start the sv_player function on the server, but it doesn't
}
}



Posted By: Ran Man

Re: ent_create on client, no function started - 05/15/07 19:01

Hi,

Yes, I also had problems creating and running the SERVER player using ent_create, so to make it work, I just made the SERVER to use an ACTION in the level, and just used ent_create for the clients.

Hey, it works.
Posted By: oliver2s

Re: ent_create on client, no function started - 05/15/07 19:18

After a few hours of testing find the source: I had some IFNDEFs in my script. But they had nothing to do with that functions above. I remove them and now it works....strange...
Posted By: Ran Man

Re: ent_create on client, no function started - 05/15/07 20:02

Glad to hear you got it working.

For me, I just made my SERVER players into ACTIONS in WED and then just removed the ones I did not use afterwards.
© 2024 lite-C Forums