Jump to content

[QUESTION] Why not working the notification?


Tokio

Recommended Posts

Why not working this notification system?

Client side:

local notifications = {}

function createNotification(text2, typ, name1, name2)
	if typ == "simple" then
		text = name1.." "..text2
		data = {
			text = text,
			startTime = getTickCount(),
			endTime = getTickCount() + 10000
		}
	elseif typ == "duble" then
		text = name1.." "..text2.." "..name2
		data = {
			text = text,
			startTime = getTickCount(),
			endTime = getTickCount() + 10000
		}
	end
	
	table.insert(notifications, data)
end
addEvent( "createNotification", true )
addEventHandler( "createNotification", localPlayer, createNotification )

Server side:

addEventHandler('onClientPlayerChangeNick', root,
	function(oldNick, newNick, text2, typ, name1, name2)
		triggerServerEvent ("createNotification", root, text2, typ, name1, name2) 
	end
)

How to fix this problem in this script? Thanks the help! :) 

Link to comment
4 minutes ago, MrTasty said:

onClientPlayerChangeNick is a client-side event, why are you attaching a handler to it on the server side?

Also, I'm assuming you do have some sort of rendering done for the notifications table, not just hoping that is displays itself somehow.

Rly, but doesn't working. :/ 

addEventHandler('onPlayerChangeNick', root,
	function(oldNick, newNick, text2, typ, name1, name2)
		triggerClientEvent ("createNotification", root, text2, typ, name1, name2) 
	end
)

what wrong?

and yes, i have render

Link to comment
1 hour ago, idarrr said:

addEventHandler('onPlayerChangeNick', root,
	function(oldNick, newNick)
		triggerClientEvent (source, "createNotification", source, "Your Text", "simple", oldNick, newNick) 
	end
)

 

the playerchangenick working fine, thanks :D

but, the join & quit why not working? :o 

addEventHandler('onPlayerJoin', root,
	function(name1)
		triggerClientEvent (root, "createNotification", root, "#FFffFFcsatlakozott a szerverre.", "simple", name1) 
	end
)

addEventHandler('onPlayerQuit', root,
	function(name1)
	Reasons = { 
		["Unknown"] = "Nem tudni", 
		["Quit"] = "kilépett.", 
		["Kicked"] = "kirúgva a szerverről.", 
		["Banned"] = "kibanolva a szerverről.", 
		["Timed Out"] = "kifagyott.", 
		["Bad Connection"] = "rossz internetkapcsolat" 
	}
		triggerClientEvent (root, "createNotification", root, "#FFffFF"..Reason, "simple", name1) 
	end
)

 

Link to comment
addEventHandler('onPlayerJoin', root,
	function()
    	local name = getPlayerName(source)
    	setTimer( function()
			triggerClientEvent (root, "createNotification", root, "#FFffFFcsatlakozott a szerverre.", "simple", name) 
        end, 1000, 1)
	end
)

addEventHandler('onPlayerQuit', root,
	function(reason)
    	local name = getPlayerName(source)
		triggerClientEvent (root, "createNotification", root, "#FFffFF"..reason, "simple", name) 
	end
)

Read more detail here about paramaters that are passing when event is triggered.

https://wiki.multitheftauto.com/wiki/Event_system

https://wiki.multitheftauto.com/wiki/AddEventHandler

https://wiki.multitheftauto.com/wiki/OnPlayerQuit

https://wiki.multitheftauto.com/wiki/OnPlayerJoin

  • Like 1
Link to comment

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.
×
×
  • Create New...