Is OnPlayerExitedMenu called when a player disconnects?
#1

Hello, i was curious if this callback is called when a player disconnects if he is viewing the menu?? I could not find that on the wiki. Thank you.
Reply
#2

First thing I would do is test if it gets called. But even with that, I wouldn't count on it. Imagine it doesn't get called and you really need to do something important in OnPlayerExitedMenu.

If you want to make sure it gets called, call it in OnPlayerDisconnect(). Simple, in OnPlayerDisconnect, just call OnPlayerExitedMenu...

Код:
public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	OnPlayerExitedMenu(playerid);
	return 1;
}
Also, make sure to add a check in OnPlayerExitedMenu to make sure it doesn't get called twice. For example...Make sure the menu is open before doing the "cleanup".
Reply
#3

If it's called twice then just remove this addition at OnPlayerDisconnect ^
Reply
#4

^ And what if packet loss occurs and the server does not receive the packet that runs OnPlayerExitedMenu? causing OnPlayerExitedMenu to never run and something important in that function needs to run when a player disconnects? Better be safe then write code based on luck.
Reply
#5

Quote:
Originally Posted by jwh
Посмотреть сообщение
^ And what if packet loss occurs and the server does not receive the packet that runs OnPlayerExitedMenu? causing OnPlayerExitedMenu to never run and something important in that function needs to run when a player disconnects? Better be safe then write code based on luck.
What are you talking about? The callback only handles the ID of the player, which OnPlayerDisconnect always gets right.
Reply
#6

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
What are you talking about? The callback only handles the ID of the player, which OnPlayerDisconnect always gets right.
According to https://sampwiki.blast.hk/wiki/OnPlayerExitedMenu
Called when a player exits a menu. (Only when a player exits a menu)

When a packet loss occurs, that callback is never called. Server might see the menu as open, even though it was closed client sided (p.s. "not even sure the server tracks opened menus making it possible to send repeated "exitmenu" packets. to be safe, make sure that callback is not called when a menu is not open"). OnPlayerExitedMenu does not get called when a player disconnects. It's like saying OnPlayerExitVehicle is called when a player disconnects.
Reply
#7

Quote:
Originally Posted by jwh
Посмотреть сообщение
According to https://sampwiki.blast.hk/wiki/OnPlayerExitedMenu
Called when a player exits a menu. (Only when a player exits a menu)

When a packet loss occurs, that callback is never called. Server might see the menu as open, even though it was closed client sided (p.s. "not even sure the server tracks opened menus making it possible to send repeated "exitmenu" packets. to be safe, make sure that callback is not called when a menu is not open"). OnPlayerExitedMenu does not get called when a player disconnects. It's like saying OnPlayerExitVehicle is called when a player disconnects.
There is no problem at all in calling it under OnPlayerDisconnect. He probably just wants to reset some variables or stuff like that.
Reply
#8

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
There is no problem at all in calling it under OnPlayerDisconnect. He probably just wants to reset some variables or stuff like that.
I suggested him to call it in OnPlayerDisconnect :P
Reply
#9

I get a warning though now:
Код:
C:\Users\boksi\Desktop\SAMP reikalai\FunZoneLT\filterscripts\ADMINAS.pwn(6568) : warning 213: tag mismatch
C:\Users\boksi\Desktop\SAMP reikalai\FunZoneLT\filterscripts\ADMINAS.pwn(6571) : warning 213: tag mismatch
for lines:
Код:
if(examplemenu[playerid] != -1)
and:
Код:
examplemenu[playerid] = -1;
Maybe i cant make them equal something, when its Menu:examplemenu I think it works, but gives me warnings..
Reply
#10

How you are declaring examplemenu?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)