Turbo777

Why not working onPlayerLogout?

Recommended Posts

addEventHandler("onPlayerLogout", getRootElement(),
function ()
local name = getPlayerName ( source )
    if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then
		exports[getResourceName(resource)]:addNotification(root, name.." kilépett a tulajdonos szolgálatból!", "success")
    end
end
)

what wrong? onPlayerLogin working with this.. wtf?!

Share this post


Link to post

Does it give you any error in debugscript?

Share this post


Link to post

Maybe because when they logout they are no longer in any team? (guest account). onPlayerLogout passes through 2 arguments, one of them is the oldAccount, use that instead.

Edited by pa3ck

Share this post


Link to post
8 hours ago, pa3ck said:

Maybe because when they logout they are no longer in any team? (guest account). onPlayerLogout passes through 2 arguments, one of them is the oldAccount, use that instead.

Like this? 

function test()
		if (isGuestAccount(getPlayerAccount(v)) == false) then
			accountname = getAccountName (getPlayerAccount(v))
			if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then
				exports[getResourceName(resource)]:addNotification(root, " logged out", "success")
		end
	end
end

 

Share this post


Link to post

Man, when player logs out he is no longer logged in. Look what argument onPlayerLogout event gives.

account thePreviousAccount, account theCurrentAccount

Do you see? So,

addEventHandler("onPlayerLogout", getRootElement(),
	function (acc, _)
		local name = getPlayerName ( source )
    	if isObjectInACLGroup("user." .. getAccountName(acc), aclGetGroup("Admin")) then
			exports[getResourceName(resource)]:addNotification(root, name.." kilépett a tulajdonos szolgálatból!", "success")
   	 	end
	end
)
Edited by WhoAmI
  • Like 1

Share this post


Link to post
3 minutes ago, WhoAmI said:

Man, when player logs out he is no longer logged in. Look what argument onPlayerLogout event gives.


account thePreviousAccount, account theCurrentAccount

Do you see? So,


addEventHandler("onPlayerLogout", getRootElement(),
	function (acc, _)
		local name = getPlayerName ( source )
    	if isObjectInACLGroup("user." .. getAccountName(acc), aclGetGroup("Admin")) then
			exports[getResourceName(resource)]:addNotification(root, name.." kilépett a tulajdonos szolgálatból!", "success")
   	 	end
	end
)

thanks :D

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.