Makaveli15 Posted November 14, 2018 Share Posted November 14, 2018 Hey guys. How can i make script like this. If i write command, i dont receive any message of choosen person. Even pm/msg commands not show up. Also able to unignore. And everything's for client of course. Link to comment
Fist Posted November 14, 2018 Share Posted November 14, 2018 (edited) You will need to create your own chat handling, same for private messaging if you want to prevent that as well and then you can manage to do that type of stuff. edit: actually never mind. There's a chat event on client as well. You can use that to detect whose message is who and then cancel it if it's one of blocked players. https://wiki.multitheftauto.com/wiki/OnClientChatMessage This should do the trick local blocked_players = {} addEventHandler("onClientChatMessage",root,function() if (blocked_players[source]) then cancelEvent() outputChatBox(getPlayerName(source).." wrote something in chat, but you blocked him.") end end) addCommandHandler("block",function(cmd,plyname) local target = getPlayerFromName(plyname) if (plyname and target) then if (not blocked_players[target]) then blocked_players[target] = true; outputChatBox("player"..plyname.." blocked!") else blocked_players[target] = nil; outputChatBox("player"..plyname.." unblocked!") end else outputChatBox("player not found") end end) Edited November 14, 2018 by Fist Link to comment
Makaveli15 Posted November 14, 2018 Author Share Posted November 14, 2018 18 minutes ago, Fist said: You will need to create your own chat handling, same for private messaging if you want to prevent that as well and then you can manage to do that type of stuff. edit: actually never mind. There's a chat event on client as well. You can use that to detect whose message is who and then cancel it if it's one of blocked players. https://wiki.multitheftauto.com/wiki/OnClientChatMessage This should do the trick local blocked_players = {} addEventHandler("onClientChatMessage",root,function() if (blocked_players[source]) then cancelEvent() outputChatBox(getPlayerName(source).." wrote something in chat, but you blocked him.") end end) addCommandHandler("block",function(cmd,plyname) local target = getPlayerFromName(plyname) if (plyname and target) then if (not blocked_players[target]) then blocked_players[target] = true; outputChatBox("player"..plyname.." blocked!") else blocked_players[target] = nil; outputChatBox("player"..plyname.." unblocked!") end else outputChatBox("player not found") end end) what will be the command for it? Link to comment
Fist Posted November 14, 2018 Share Posted November 14, 2018 11 minutes ago, OsO.cp said: what will be the command for it? /block playername also you can unblock someone by writing same command. dude, if you can't understand what command that script is using then idk. There's no hope for you, just drop learning this, if you are trying to learn it. It certainly doesn't look like you are trying to learn anything if you can't understand what command under is that script. Link to comment
Makaveli15 Posted November 14, 2018 Author Share Posted November 14, 2018 (edited) 41 minutes ago, Fist said: /block playername also you can unblock someone by writing same command. dude, if you can't understand what command that script is using then idk. There's no hope for you, just drop learning this, if you are trying to learn it. It certainly doesn't look like you are trying to learn anything if you can't understand what command under is that script. yea, im so bad.. 42 minutes ago, Fist said: /block playername also you can unblock someone by writing same command. dude, if you can't understand what command that script is using then idk. There's no hope for you, just drop learning this, if you are trying to learn it. It certainly doesn't look like you are trying to learn anything if you can't understand what command under is that script. It doesn't work. shows unexpected symbol near ' Edited November 14, 2018 by OsO.cp Link to comment
mazarati21 Posted November 14, 2018 Share Posted November 14, 2018 local blocked_players = {} addEventHandler("onClientChatMessage",root,function() if (blocked_players[source]) then cancelEvent() outputChatBox(getPlayerName(source).." wrote something in chat, but you blocked him.") end end) function block(cmd,plyname) local target = getPlayerFromName(plyname) if (plyname and target) then if (not blocked_players[target]) then blocked_players[target] = true; outputChatBox("player"..plyname.." blocked!") else blocked_players[target] = nil; outputChatBox("player"..plyname.." unblocked!") end else outputChatBox("player not found") end end addCommandHandler("block", block) Link to comment
Makaveli15 Posted November 15, 2018 Author Share Posted November 15, 2018 12 hours ago, mazarati21 said: local blocked_players = {} addEventHandler("onClientChatMessage",root,function() if (blocked_players[source]) then cancelEvent() outputChatBox(getPlayerName(source).." wrote something in chat, but you blocked him.") end end) function block(cmd,plyname) local target = getPlayerFromName(plyname) if (plyname and target) then if (not blocked_players[target]) then blocked_players[target] = true; outputChatBox("player"..plyname.." blocked!") else blocked_players[target] = nil; outputChatBox("player"..plyname.." unblocked!") end else outputChatBox("player not found") end end addCommandHandler("block", block) still writes the same: unexpected symbol near ' Link to comment
Dimos7 Posted November 15, 2018 Share Posted November 15, 2018 (edited) local blockedPlayers = {} function getPlayerFromPatrialName(name) local name = name and name:gsub("#%x%x%x%x%X%x", ""):lower() or nil if name then for _ , player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end addEventHandler("onClientMessage", root, function() if blockedPlayers[source] then cancelEvent() outputChatBox(getPlayerName(source).." wrote something in chat, but you block him!") end end ) function block(cmd, target) local targetPlayer = getPlayerFromPatrialName(target) if target and targetPlayer then if not blockedPlayers[targetPlayer] then blockedPlayer[targetPlayer] = true outputChatBox("player "..getPlayerName(targetPlayer).. "blocked") else blockedPlayers[targetPlayer] = nil outputChatBox("player ".. getPlayerName(targetPlayer).." unblocked") end else outputChatBox("Player not found!") end end addCommandHandler("block", block) Edited November 15, 2018 by Dimos7 Link to comment
Makaveli15 Posted November 15, 2018 Author Share Posted November 15, 2018 1 hour ago, Dimos7 said: local blockedPlayers = {} function getPlayerFromPatrialName(name) local name = name and name:gsub("#%x%x%x%x%X%x", ""):lower() or nil if name then for _ , player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end addEventHandler("onClientMessage", root, function() if blockedPlayers[source] then cancelEvent() outputChatBox(getPlayerName(source).." wrote something in chat, but you block him!") end end ) function block(cmd, target) local targetPlayer = getPlayerFromPatrialName(target) if target and targetPlayer then if not blockedPlayers[targetPlayer] then blockedPlayer[targetPlayer] = true outputChatBox("player "..getPlayerName(targetPlayer).. "blocked") else blockedPlayers[targetPlayer] = nil outputChatBox("player ".. getPlayerName(targetPlayer).." unblocked") end else outputChatBox("Player not found!") end end addCommandHandler("block", block) '=' expected near ' Link to comment
Dimos7 Posted November 15, 2018 Share Posted November 15, 2018 i don't have such error myself Link to comment
Makaveli15 Posted November 15, 2018 Author Share Posted November 15, 2018 Just now, Dimos7 said: i don't have such error myself maybe i did wrong meta or smth. could u send me or idk Link to comment
Dimos7 Posted November 15, 2018 Share Posted November 15, 2018 local blockedPlayers = {} function getPlayerFromPatrialName(name) local name = name and name:gsub("#%x%x%x%x%X%x", ""):lower() or nil if name then for _ , player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end addEventHandler("onClientMessage", root, function() if blockedPlayers[source] then cancelEvent() outputChatBox(getPlayerName(source).." wrote something in chat, but you block him!") end end ) function block(cmd, target) local targetPlayer = getPlayerFromPatrialName(target) if target and targetPlayer then if not blockedPlayers[targetPlayer] then blockedPlayers[targetPlayer] = true outputChatBox("player "..getPlayerName(targetPlayer).. " blocked") else blockedPlayers[targetPlayer] = nil outputChatBox("player ".. getPlayerName(targetPlayer).." unblocked") end else outputChatBox("Player not found!") end end addCommandHandler("block", block) <meta> <script src="namefile.lua" type="client"/> </meta> Link to comment
Makaveli15 Posted November 15, 2018 Author Share Posted November 15, 2018 4 minutes ago, Dimos7 said: local blockedPlayers = {} function getPlayerFromPatrialName(name) local name = name and name:gsub("#%x%x%x%x%X%x", ""):lower() or nil if name then for _ , player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end addEventHandler("onClientMessage", root, function() if blockedPlayers[source] then cancelEvent() outputChatBox(getPlayerName(source).." wrote something in chat, but you block him!") end end ) function block(cmd, target) local targetPlayer = getPlayerFromPatrialName(target) if target and targetPlayer then if not blockedPlayers[targetPlayer] then blockedPlayers[targetPlayer] = true outputChatBox("player "..getPlayerName(targetPlayer).. " blocked") else blockedPlayers[targetPlayer] = nil outputChatBox("player ".. getPlayerName(targetPlayer).." unblocked") end else outputChatBox("Player not found!") end end addCommandHandler("block", block) <meta> <script src="namefile.lua" type="client"/> </meta> Works, but still getting messages. pm/msg as well. Link to comment
Dimos7 Posted November 15, 2018 Share Posted November 15, 2018 do something like this and onPlayerMessage to see if works Link to comment
Makaveli15 Posted November 15, 2018 Author Share Posted November 15, 2018 1 minute ago, Dimos7 said: do something like this and onPlayerMessage to see if works im not that involved in scripting 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