Author Topic: OnJoinGame OnLeaveGame OnJoinTeam not always  (Read 1887 times)

0 Members and 1 Guest are viewing this topic.

Offline chase is my name

  • Major(1)
  • Posts: 19
OnJoinGame OnLeaveGame OnJoinTeam not always
« on: March 14, 2007, 02:47:10 am »
Several of my scripts set different variables when a player joins a game. For this thread I'll use my subadmin script as an example.

When a player joins the game, he/she/it goes through OnJoinGame and OnJoinTeam. During this time the script checks the player's IP via a list of IP's in a static array. If it matches, then it sets their status as 1 for that ID = it is a subadmin. OnLeaveGame, it sets it back to 0 for that ID=not subadmin anymore.

When I placed the subadmin check IP script in OnJoinGame, it NEVER worked the first time a subadmin would join because it never set the "I am a subadmin" flag = 1. I know because I would have it print out the entire array of flags. The player would have to disconnect, reconnect and then only sometimes it would set the flag.

I got better luck when I placed the script in OnJoinTeam. This seemed to work about 80-95% of the time. My subadmins would rarely have to disconnect and reconnect again.

Any idea why this is anyone?

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: OnJoinGame OnLeaveGame OnJoinTeam not always
« Reply #1 on: March 14, 2007, 05:01:35 am »
Theres a bug with most of those functions where the ID is 0, its fixed in the next version. Nothing you can do about it now though.

Offline chase is my name

  • Major(1)
  • Posts: 19
Re: OnJoinGame OnLeaveGame OnJoinTeam not always
« Reply #2 on: March 14, 2007, 10:13:31 am »
HA! I would NEVER have expected that. The reason why I wouldn't have suspected that is because I thought that the game wouldn't ever assign an ID of 0. I was under the impression the game strictly used ID's 1 and up.

Why would the game go on and assign a player of ID 0? Is it just something the game does by accident on Player connect?

and if that's the case. It would be nice to have a function to be able to MODIFY a player's ID number in the game. In order to prevent future things like this though :)

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: OnJoinGame OnLeaveGame OnJoinTeam not always
« Reply #3 on: March 14, 2007, 10:15:25 am »
Its because the OnLeaveGame event is being called AFTER the player's information has been removed from the server's memory. OnJoinGame is along the same lines, except its before the player information is updated. Just some logic ordering flaws

Offline chase is my name

  • Major(1)
  • Posts: 19
Re: OnJoinGame OnLeaveGame OnJoinTeam not always
« Reply #4 on: March 14, 2007, 10:38:26 am »
oh what the ..... !!! That's a serious problem. Alright let me back it up. I probably would have made the same mistake if I had to make this game from scratch and worse probably.

EVERYONE: do not use OnJoinGame or OnLeaveGame. It'll cause problems

Offline FliesLikeABrick

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 6144
    • Ultimate 13 Soldat
Re: OnJoinGame OnLeaveGame OnJoinTeam not always
« Reply #5 on: March 14, 2007, 10:40:30 am »
oh what the ..... !!! That's a serious problem. Alright let me back it up. I probably would have made the same mistake if I had to make this game from scratch and worse probably.

EVERYONE: do not use OnJoinGame or OnLeaveGame. It'll cause problems

well, at least don't use it until the next version is out

Offline chase is my name

  • Major(1)
  • Posts: 19
Re: OnJoinGame OnLeaveGame OnJoinTeam not always
« Reply #6 on: March 14, 2007, 11:02:53 am »
true true