gokalpfirat Posted August 15, 2011 Posted August 15, 2011 g_R = getRootElement() messages{ "Hi" "How are u" "Whats up?" } serials { "2F79CDD46FA67EB6006A1C1E24BD3583" } randm = messages[math.random(1,3)] serial = getPlayerSerial(source) function onJoin() for i,v in pairs(serials) if (serial = v) then setElementData(source,"LP",true) end end addEventHandler("onPlayerJoin",g_R,onJoin) function chat(message,messageType) if getElementData(source,"LP") then cancelEvent() outputChatBox(getPlayerName(source).."#FFFFFF:"..randm ,g_R,0,0,0,true) end end addEventHandler("onPlayerChat",g_R,chat) Please fix it It should do when the serial that i want join setElementData LP true and when he chats cancelEvent() and create a new message to him. Its server-side.
MTA Team qaisjp Posted August 15, 2011 MTA Team Posted August 15, 2011 (edited) messages = { "Hi", "How are u?", "Whats up?", "I love you", "I speak shit", "add more here", "no need to change anything else, too;)" } serials = { "2F79CDD46FA67EB6006A1C1E24BD3583" } function chat(message,messageType) serial = getPlayerSerial(source) if serials[serial] then cancelEvent() outputChatBox(getPlayerName(source).."#FFFFFF:"..messages[math.random(1,table.getn(messages))] or "Hehe, you suck!" ,source,0,0,0,true) end end addEventHandler("onPlayerChat",root,chat) Edited August 15, 2011 by Guest
Kenix Posted August 15, 2011 Posted August 15, 2011 You mean this ? g_R = getRootElement() messages = { "Hi", "How are u", "Whats up?" } serials = { "2F79CDD46FA67EB6006A1C1E24BD3583" } randm = messages[math.random(1,#messages)] function onJoin() serial = getPlayerSerial(source) if serial == serials then setElementData(source,"LP",true) end end addEventHandler("onPlayerJoin",g_R,onJoin) function chat(message,messageType) if getElementData(source,"LP") == true then cancelEvent() outputChatBox(getPlayerName(source).."#FFFFFF:"..randm ,source,0,0,0,true) end end addEventHandler("onPlayerChat",g_R,chat)
MTA Team qaisjp Posted August 15, 2011 MTA Team Posted August 15, 2011 volk-rus, I just did that, but better. Look carefully before you post -.-
Kenix Posted August 15, 2011 Posted August 15, 2011 Lol i use mobile phone and i write code not faster
JR10 Posted August 15, 2011 Posted August 15, 2011 g_R = getRootElement() messages{ "Hi" "How are u" "Whats up?" } serials { ["2F79CDD46FA67EB6006A1C1E24BD3583"] = true } function onJoin() local serial = getPlayerSerial(source) if serials[serial] then setElementData(source,"LP",true) end end addEventHandler("onPlayerJoin",g_R,onJoin) function chat(message,messageType) if getElementData(source,"LP") then cancelEvent() local randm = messages[math.random(1,3)] outputChatBox(getPlayerName(source).."#FFFFFF:"..randm ,g_R,0,0,0,true) end end addEventHandler("onPlayerChat",g_R,chat)
JR10 Posted August 15, 2011 Posted August 15, 2011 messages = { "Hi", "How are u", "Whats up?" } serials = { ["2F79CDD46FA67EB6006A1C1E24BD3583"] = true } function onJoin() local serial = getPlayerSerial(source) if serials[serial] then setElementData(source,"LP",true) end end addEventHandler("onPlayerJoin",root,onJoin) function chat(message,messageType) if getElementData(source,"LP") then cancelEvent() local randm = messages[math.random(#messages)] outputChatBox(getPlayerName(source).."#FFFFFF:"..randm ,root,0,0,0,true) end end addEventHandler("onPlayerChat",root,chat) Tested, don't forget to give the resource admin.
gokalpfirat Posted August 15, 2011 Author Posted August 15, 2011 One more function hideJack(player,command,who,message) local targetPlayer = getPlayerFromName ( who ) if targetPlayer then outputChatBox(getPlayerName(who).."#EBDDB2: "..message ,root,255,255,255,true) end end addCommandHandler("yaziasda",hideJack)
JR10 Posted August 15, 2011 Posted August 15, 2011 function hideJack(player,command,who,...) local targetPlayer = getPlayerFromName ( who ) if targetPlayer then local message = table.concat({...}, " ") outputChatBox(getPlayerName(who).."#EBDDB2: "..message ,root,255,255,255,true) end end addCommandHandler("yaziasda",hideJack)
gokalpfirat Posted August 15, 2011 Author Posted August 15, 2011 Doent work. When i use /yaziasda gokalp hi It wont works.
SDK Posted August 15, 2011 Posted August 15, 2011 Use /debugscript 3 function hideJack(player,command,who,...) local targetPlayer = getPlayerFromName ( who ) if targetPlayer then local message = table.concat({...}, " ") outputChatBox(getPlayerName(targetPlayer ).."#EBDDB2: "..message ,root,255,255,255,true) end end addCommandHandler("yaziasda",hideJack)
BinSlayer1 Posted August 15, 2011 Posted August 15, 2011 Doent work. When i use /yaziasda gokalp hi It wont works. You have to use full name with that command something like /yaziasda gokalpfirat hi should work
gokalpfirat Posted August 15, 2011 Author Posted August 15, 2011 I dont want to use full name. But i use getPlayerFromName
JR10 Posted August 15, 2011 Posted August 15, 2011 You will have to make a "getPlayerFromPartialName" here: function getPlayerFromName( partialName ) if partialName then local matches = {} for i, player in ipairs ( getElementsByType ( "player" ) ) do if getPlayerName ( player ) == partialName then return player end if getPlayerName ( player ) : gsub ( "#%x%x%x%x%x%x" , "" ) : lower ( ) : find ( partialName : lower ( ) ) then table.insert ( matches , player ) end end if #matches == 1 then return matches [ 1 ] end end return false end Now just put it anywhere, and don't change anything.
gokalpfirat Posted August 16, 2011 Author Posted August 16, 2011 I found a one more problem how can i change the color of ":" to the players last hex code.
JR10 Posted August 16, 2011 Posted August 16, 2011 To change any thing happens in the chat, you need to cancel the event, and outputChatBox your own message.
gokalpfirat Posted August 16, 2011 Author Posted August 16, 2011 No no when normal players say somethin ":" is the players latest hex code color like my name #ff000Gokalp then : should #ff0000 how can i do this.
will briggs Posted August 16, 2011 Posted August 16, 2011 function sendMessageToNearbyPlayers( message, messageType ) if messageType == 0 then for i,v in ipairs( getElementsByType ("player") ) do local theName = getAccountName (getPlayerAccount (source)) outputChatBox( "#00FF00".. theName ..": #FFFFFF" .. message, v, 0, 0, 0, true ) end cancelEvent() end end addEventHandler( "onPlayerChat", getRootElement(), sendMessageToNearbyPlayers ) That should do it
gokalpfirat Posted August 17, 2011 Author Posted August 17, 2011 No i dont say it i say like in normal chat if your name is #ff0000JR10: Hi. And in normal chat ":"is your hex color in your name how can i do it for my code?
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