Author Topic: Gamejoin Problems.  (Read 1283 times)

This, dose not work.
Code: [Select]
package Spawn
{
function gameconnection::OnClientEnterGame(%this,%client)
{
if(isFile("Add-Ons/Client_PitroGUI/client.cs"))
{
canvas.pushDialog(Pitrospawn);
}
else
{
%name = %client.name;
%client.delete("Sorry, you need pitro GUI!");
}
}
};
activatePackage(Spawn);



You're combining client-side and server-sided code.

You're combining client-side and server-sided code.
How do i get it to open GUI server side?

I think canvas.pushDialog(Pitrospawn); is clientsided.

Try something like:

client.cs:
Code: [Select]
function clientCmdPitroSpawn(%gui)
{
    %gui = canvas.pushDialog(Pitrospawn);
}

server.cs:
Code: [Select]
package Spawn
{
function gameconnection::OnClientEnterGame(%this,%client)
{
if(isFile("Add-Ons/Client_PitroGUI/client.cs"))
{
%name = %client.name;
                        commandToClient(findClientByName(%name), 'PitroSpawn');
}
else
{
%name = %client.name;
%client.delete("Sorry, you need pitro GUI!");
}
}
};
activatePackage(Spawn);

In order to make a client open your GUI, they'd need your Add-On installed and a script to tell the client to do it. As said, what you're doing is the command to locally open it and not a command to tell a client to open it. And, as I just said, they'd need it in the first place.

I could by going insane here becuase its late, but parent it?

"isFile" will always check your Blockland directory for the file, not search theirs.

Why would you check for the GUI after they spawn?

Code: [Select]
package Spawn
{
function gameconnection::OnClientEnterGame(%this,%client)
{
if(isFile("Add-Ons/Client_PitroGUI/client.cs"))
{
%name = %client.name;
                        commandToClient(findClientByName(%name), 'PitroSpawn');
}
else
{
%name = %client.name;
%client.delete("Sorry, you need pitro GUI!");
}
}
};
activatePackage(Spawn);
No need for the findClientByName(), just use %client...

you going to want something like this:

Code: [Select]
client.cs
function clientCmdPitroSpawn()
  {
   Canvas.pushDialog(Pitrospawn);
  }


server.cs
package Spawn
{
  function gameconnection::OnClientEnterGame(%this,%client)
   {
    Parent::onClientEnterGame(%this, %client);
    commandToClient(%client, 'PitroSpawn');
  }
};
activatePackage(Spawn);

However..... like MegaScientifical said - they will have to have your addon installed in order for this to work.

A better solution is to use RTB.  it has the ability to "send" a gui to the client. There are a lot of limitations in what you can & cant do with the gui, but it doesnt require everyone to have your addon installed.

they will have to have your addon installed in order for this to work.
Well i want them to have to download it, not from RTB.
"isFile" will always check your Blockland directory for the file, not search theirs.
How do i check the file of the player that just joined?
« Last Edit: May 28, 2010, 07:39:25 PM by pitfall »

Well i want them to have to download it, not from RTB.How do i check the file of the player that just joined?
Easy, call a clientCmd, make the clientCmd check it.

Well i want them to have to download it, not from RTB.

How do i check the file of the player that just joined?

1) You can't force a user download a GUI, as it can easily be abused to make GUI's that force closing and other harmful things.

2) As HellsHero said, you'd need them to have a command you can call on for them to find the file and tell you about it.

Easy, call a clientCmd, make the clientCmd check it.
Thats a start.

I would do something like this:

1)  in  ::onClientEnterGame, you set a variable to "false" or "no" or something to indicate "player does not have my mod installed"
2) also in ::onClientEnterGame, you do commandToClient(%client, 'CheckMyMod' ....

3) in client.cs (which they have downloaded).
put the code for:  clientCmdCheckMyMod - all it does is  something like: commandToServer('MyModIsLoaded')

4) in server.cs put code for:  serverCommandmyModIsLoaded(%client).  in that function you set your variable from step 1 to "true" or "yes" or something to indicate "player DOES have my mod installed"

5) anytime the player tries to do something you check your client variable, and if its set to no mod loaded, then you send the client an error.

Darklight had something like this on his server for his CityRP that if you didn't send him a command on joining or something it would kick you for not having his scripts.