Tokio Posted June 3, 2017 Share Posted June 3, 2017 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
Addlibs Posted June 3, 2017 Share Posted June 3, 2017 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. Link to comment
Tokio Posted June 3, 2017 Author Share Posted June 3, 2017 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
idarrr Posted June 3, 2017 Share Posted June 3, 2017 addEventHandler('onPlayerChangeNick', root, function(oldNick, newNick) triggerClientEvent (source, "createNotification", source, "Your Text", "simple", oldNick, newNick) end ) 1 Link to comment
Tokio Posted June 3, 2017 Author Share Posted June 3, 2017 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 but, the join & quit why not working? 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
idarrr Posted June 3, 2017 Share Posted June 3, 2017 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 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now