Aller au contenu

Photo

note on module event pc-loaded


  • Veuillez vous connecter pour répondre
4 réponses à ce sujet

#1
kevL

kevL
  • Members
  • 4 056 messages
[DEFUNCT] - the event works fine.

not a bug (i guess) but module event PC_Loaded fires only when starting a new game

loading a saved game does not fire the event or so it appears.


Use the old standby, on_Client_Enter
( The difference is that when onClientEnter fires the PC is still in a limbo, where trying to do things that require a valid area may crash; the PCLoaded event fires later and should mean the PC is in a well formed area where actions can be assigned for example. But you can get away with a lot in the onClientEnter, tbh )

"it's not a bug its a feature" -- for example if you want to set state only once at the start of the campaign, onPCLoaded could be the place to do it. But you'd want to test that a bit ......


It's the only way to be sure.

#2
Dann-J

Dann-J
  • Members
  • 3 161 messages

I've always made sure my OnPCLoaded scripts only run once at the start of the game, just to be on the safe side (usually via a global variable). It seems I've been wasting precious seconds of my life adding a couple of extra lines to scripts. :)



#3
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

not a bug (i guess) but module event PC_Loaded fires only when starting a new game

loading a saved game does not fire the event or so it appears.


Use the old standby, on_Client_Enter
( The difference is that when onClientEnter fires the PC is still in a limbo, where trying to do things that require a valid area may crash; the PCLoaded event fires later and should mean the PC is in a well formed area where actions can be assigned for example. But you can get away with a lot in the onClientEnter, tbh )

"it's not a bug its a feature" -- for example if you want to set state only once at the start of the campaign, onPCLoaded could be the place to do it. But you'd want to test that a bit ......

It's the only way to be sure.


Hi KevL,

I have a note at the top of my On PC Loaded script that says (to remind me): "THIS SCRIPT DOES APPEAR TO FIRE FOR EACH PLAYER ON A RELOAD (DOES SP ANYWAY)"
 

I have the following debug line check and it does send the message whenever I reload a saved game for the player:

 

SendMessageToPC(oPlayer, "PCLOAD FIRED FOR " + GetName(oPlayer));

I actually have more scripting code attached to this hook than the Client On Enter by the looks of it.

The note in my On Client Enter says this: "THIS SCRIPT FIRES AGAIN WHEN A PLAYER LOADS A SAVED GAME (BUT DOES NOT GUARANTEE PLAYER OBJECT - USE "ON PC LOADED" INSTEAD)"

Cheers,
Lance.



#4
kevL

kevL
  • Members
  • 4 056 messages
you're probably right. I was getting *highly* sporadic behavior from it, and since I was in the middle of tracking a weird bug that seems related to Armor unequipped when loading a saved game, what I wrote above is partly a rant.

thanks for the advice, but am not going to trust it until I figure out what was going on,

update: Ah, duplicate file in /Override, tks!

 

The note in my On Client Enter says this: "THIS SCRIPT FIRES AGAIN WHEN A PLAYER LOADS A SAVED GAME (BUT DOES NOT GUARANTEE PLAYER OBJECT - USE "ON PC LOADED" INSTEAD)"


i think the Player-object is well formed; CreateItemOnObject(oPC) works consistently for me. The entering object is rather not guaranteed to be in any sort of a game-world

#5
Dann-J

Dann-J
  • Members
  • 3 161 messages

It's good to hear that I haven't been wasting my time being overly cautious. :P