I am trying to catch the playerSpawn event. From what I have read, playerSpawn is only available on the client side. Below is the code I am using but it doesn’t work…
namespace Client
{
public class Client : BaseScript
{
public Client()
{
Tick += OnTick;
EventHandlers.Add("playerSpawned", new Action<Player>(OnPlayerSpawn));
}
private async Task OnTick()
{
await Delay(100);
}
private void OnPlayerSpawn([FromSource]Player player)
{
TriggerEvent("chatMessage", "", new[] { 0, 0, 0 }, "Player Spawned!");
}
}
}
Player ([FromSource]Player player) is only available for server side event if i am not wrong.
Juste replace Player by dynamic
EventHandlers["playerSpawned"] += new Action< dynamic >(OnPlayerSpawn);
private void OnPlayerSpawn(object obj)
{
//Handle your stuff
}
1 Like
SheppeR,
Thank you for you input and assistance. I made your recommend changes and I still do not see the event getting triggered.
Its should work
try to put a debug message Debug.WriteLine(“Hello World Spawn Event”);
I am still working on this issue and have not solved it yet. The code below shows the simple script I am loading and according to another post I saw in the forum, it should span the client debug console. I press F8 and do not see the spam.
Something I notice in the log output when I start the server is this…
Loaded shared.net, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null into ScriptDomain_1150916478
Loaded server.net, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null into ScriptDomain_1150916478
The client resource is named client.net.dll, should I not see it load as well? The __resource.lua look like this.
client_script {
"shared.net.dll",
"client.net.dll"
}
server_script {
"shared.net.dll",
"server.net.dll"
}
// Client Script
namespace client
{
public class Client : BaseScript
{
public Client()
{
Tick += OnTick;
}
private async Task OnTick()
{
await Delay(100);
Debug.WriteLine("**** Client Tick ****");
}
}
}
//Server Script
namespace server
{
public class Server : BaseScript
{
public Server()
{ }
}
}
Debug.WriteLine("**** Client Tick ****"); is on client side, open your client console (F8) when you are in game
That is where I am looking.
Here is my CitizexFX.log … it does have an error.
CitizenFX.log (75.1 KB)
Set Build -> Target Platforms -> Any CPU, aslo use .Net4.5.2
2 Likes
SheppeR, That fixed it, you are a R*!
Thank You!
1 Like