DrPhoX Posted January 18, 2013 Share Posted January 18, 2013 (edited) solved, please lock Edited January 18, 2013 by Guest Link to comment
Perfect Posted January 18, 2013 Share Posted January 18, 2013 Its easy and simple. btw the message should show to all players or only like person ? Try this (Not Tested):- function likePlayer ( player, cmd, victim ) local victim = getPlayerFromName ( victim ) if ( victim ) then outputChatBox ( " "..tostring(player).." like You", victim, 0, 255, 0, true ) else outputChatBox ( "Could not find player with name: ".. tostring ( victim ), player, 255, 0, 0, true ) end end addCommandHandler ( "likeu", likePlayer ) Link to comment
DrPhoX Posted January 18, 2013 Author Share Posted January 18, 2013 It work but it didn't write "I like you" or "I like you with my name". When i write /likeu it say: "Could not find player with name: false" PS: For all player's, not only for person. And example: Player: I like you Player PS2: and you removed my antispam protection can you create the script with that? Link to comment
Perfect Posted January 18, 2013 Share Posted January 18, 2013 It work but it didn't write"I like you" or "I like you with my name". When i write /likeu it say: "Could not find player with name: false" PS: For all player's, not only for person. And example: Player: I like you Player PS2: and you removed my antispam protection can you create the script with that? did you write /likeu or just /likeu ? maybe you just write /likeu without writing player name and thats why it says false. write /likeu DrPhox it will say something like:- DrPhox like u. and for antispam thing, i am bad at it. sorry Link to comment
DrPhoX Posted January 18, 2013 Author Share Posted January 18, 2013 I tried /likeu and /likeu .... And all of these option's don't work. Or, it work's but it say: "Could not find player with name: false" PS: In-game i have nick: "-LaB-#HEXHEXPhoFe" and when i write /likeu PhoFe it say's: "Could not find player with name: false" Link to comment
MR.S3D Posted January 18, 2013 Share Posted January 18, 2013 (edited) local restriction = {} function getPlayerFromNamePart(name) if name then for i, player in ipairs(getElementsByType("player")) do if string.find(getPlayerName(player):lower(), tostring(name):lower(), 1, true) then return player end end end return false end function likeYou(player, cmd, players) local players = getPlayerFromNamePart(players) if players then if not restriction[player][cmd] then outputChatBox("#FFFFFF".. getPlayerName(player) ..": #ffa500I like you #ffffff" .. players .. "", root, 255, 165, 0, true) restriction[player][cmd] = true setTimer(function () restriction[player][cmd] = false end, 5000, 1) else outputChatBox("-LaB-: #ffffffYou must wait 5 seconds to write this command again.", player, 255, 165, 0, true) end else outputChatBox("|type| /likeu [player Name]",player) end end addCommandHandler("likeu", likeYou) Edited January 18, 2013 by Guest Link to comment
DrPhoX Posted January 18, 2013 Author Share Posted January 18, 2013 Thank you so much, but it work's only for "I like you PLAYER". I want too "I like you". PS: and it doesn't work for my nick Link to comment
MR.S3D Posted January 18, 2013 Share Posted January 18, 2013 I did not understand what you want Link to comment
DrPhoX Posted January 18, 2013 Author Share Posted January 18, 2013 I want when player write /likeu it write to chatbox "I like you!" When he write /likeu PhoFe It write to chatbox "I like you -LaB-#HEXHEXPhoFe" do you understand? and I also want that when I write /likeu PhoFe so it will apply to me. Link to comment
MR.S3D Posted January 18, 2013 Share Posted January 18, 2013 function likeYou(player, cmd, players) if players then local players = getPlayerFromNamePart(players) if not restriction[player][cmd] then outputChatBox("#FFFFFF".. getPlayerName(player) ..": #ffa500I like you #ffffff" .. players .. "", root, 255, 165, 0, true) restriction[player][cmd] = true setTimer(function () restriction[player][cmd] = false end, 5000, 1) else outputChatBox("-LaB-: #ffffffYou must wait 5 seconds to write this command again.", player, 255, 165, 0, true) end else outputChatBox("#ffa500 I like you", player, 255, 165, 0, true) end end addCommandHandler("likeu", likeYou) Link to comment
DrPhoX Posted January 18, 2013 Author Share Posted January 18, 2013 Ye, now we are on good way... but, when i write /likeu PhoFe ... so nothing will happen.. And it work's for other player's? i'm testing it on my localhost server PS: But antispam don't work Link to comment
MR.S3D Posted January 18, 2013 Share Posted January 18, 2013 Ye, now we are on good way... but, when i write /likeu PhoFe ... so nothing will happen.. And it work's for other player's? i'm testing it on my localhost server PS: But antispam don't work local restriction = {} function getPlayerFromNamePart(name) if name then for i, player in ipairs(getElementsByType("player")) do if string.find(getPlayerName(player):lower(), tostring(name):lower(), 1, true) then return player end end end return false end addCommandHandler("likeu", function(player, cmd, players) if players then if restriction[player] then return outputChatBox("-LaB-: #ffffffYou must wait 5 seconds to write this command again.", player, 255, 165, 0, true) end local name = getPlayerName(player) local playerss = getPlayerFromNamePart(players) if playerss then outputChatBox("#FFFFFF".. name ..": #ffa500I like you #ffffff" .. getPlayerName(playerss) .. "", root, 255, 165, 0, true) restriction[player] = true setTimer(function () restriction[player] = false end, 5000, 1) end else outputChatBox("#ffa500 I like you", player, 255, 165, 0, true) end end ) Link to comment
DrPhoX Posted January 18, 2013 Author Share Posted January 18, 2013 Next problem When i write /likeu so antispam don't work and when i write /likeu PhoFe it write (You must wait 5 seconds.....) Link to comment
MR.S3D Posted January 18, 2013 Share Posted January 18, 2013 local restriction = {} function getPlayerFromNamePart(name) if name then for i, player in ipairs(getElementsByType("player")) do if string.find(getPlayerName(player):lower(), tostring(name):lower(), 1, true) then return player end end end return false end addCommandHandler("likeu", function(player, cmd, players) if players then if restriction[player] then return outputChatBox("-LaB-: #ffffffYou must wait 5 seconds to write this command again.", player, 255, 165, 0, true) end local name = getPlayerName(player) local playerss = getPlayerFromNamePart(players) if playerss then outputChatBox("#FFFFFF".. name ..": #ffa500I like you #ffffff" .. getPlayerName(playerss) .. "", root, 255, 165, 0, true) end else outputChatBox("#ffa500 I like you", player, 255, 165, 0, true) end restriction[player] = true setTimer(function () restriction[player] = false end, 5000, 1) end ) Link to comment
DrPhoX Posted January 18, 2013 Author Share Posted January 18, 2013 (edited) Yea! Thank you.. one problem solved /likeu PhoFe now working but, /likeu antispam don't work Edit: When i wrote /likeu PhoFe it said to chatbox "Player: I like you Player" but, when i wrote it again, so it wrote that I have to wait 5 seconds and now don't work Edited January 18, 2013 by Guest Link to comment
MR.S3D Posted January 18, 2013 Share Posted January 18, 2013 (edited) Yea! Thank you.. one problem solved /likeu PhoFe now working but, /likeu antispam don't work local restriction = {} function getPlayerFromNamePart(name) if name then for i, player in ipairs(getElementsByType("player")) do if string.find(getPlayerName(player):lower(), tostring(name):lower(), 1, true) then return player end end end return false end addCommandHandler("likeu", function(player, cmd, players) if restriction[player] then return outputChatBox("-LaB-: #ffffffYou must wait 5 seconds to write this command again.", player, 255, 165, 0, true) end if players then local name = getPlayerName(player) local playerss = getPlayerFromNamePart(players) if playerss then outputChatBox("#FFFFFF".. name ..": #ffa500I like you #ffffff" .. getPlayerName(playerss) .. "", root, 255, 165, 0, true) end else outputChatBox("#ffa500 I like you", player, 255, 165, 0, true) end restriction[player] = true setTimer(function () restriction[player] = false end, 5000, 1) end ) Edited January 18, 2013 by Guest Link to comment
DrPhoX Posted January 18, 2013 Author Share Posted January 18, 2013 I edited message: Edit: When i wrote /likeu PhoFe it said to chatbox "Player: I like you Player" but, when i wrote it again, so it wrote that I have to wait 5 seconds and now don't work .... Now it's solved, but antispam still don't work for command /likeu Link to comment
MR.S3D Posted January 18, 2013 Share Posted January 18, 2013 I edited message: Edit: When i wrote /likeu PhoFe it said to chatbox "Player: I like you Player" but, when i wrote it again, so it wrote that I have to wait 5 seconds and now don't work .... Now it's solved, but antispam still don't work for command /likeu copy my code agin i tested it Now worked Link to comment
DrPhoX Posted January 18, 2013 Author Share Posted January 18, 2013 (edited) i copied.. this is code what i have: local restriction = {} function getPlayerFromNamePart(name) if name then for i, player in ipairs(getElementsByType("player")) do if string.find(getPlayerName(player):lower(), tostring(name):lower(), 1, true) then return player end end end return false end addCommandHandler("likeu", function(player, cmd, players) if restriction[player] then return outputChatBox("-LaB-: #ffffffYou must wait 5 seconds to write this command again.", player, 255, 165, 0, true) end if players then local name = getPlayerName(player) local playerss = getPlayerFromNamePart(players) if playerss then outputChatBox("#FFFFFF".. name ..": #ffa500I like you #ffffff" .. getPlayerName(playerss) .. "", root, 255, 165, 0, true) end else outputChatBox("".. name .."#ffa500: I like you", player, 255, 165, 0, true) end restriction[player] = true setTimer(function () restriction[player] = false end, 5000, 1) end ) When i write /likeu ... 2x So antispam don't work.. but antispam work for /likeu PS: I looked to debugscript and it have error.. "ERROR: commands.lua:26 attempt to concatenate global 'name' Edited January 18, 2013 by Guest Link to comment
MR.S3D Posted January 18, 2013 Share Posted January 18, 2013 local restriction = {} function getPlayerFromNamePart(name) if name then for i, player in ipairs(getElementsByType("player")) do if string.find(getPlayerName(player):lower(), tostring(name):lower(), 1, true) then return player end end end return false end addCommandHandler("likeu", function(player, cmd, players) if restriction[player] == true then return outputChatBox("-LaB-: #ffffffYou must wait 5 seconds to write this command again.", player, 255, 165, 0, true) end restriction[player] = true setTimer(function () restriction[player] = false end, 5000, 1) if players then local name = getPlayerName(player) local playerss = getPlayerFromNamePart(players) if playerss then outputChatBox("#FFFFFF".. name ..": #ffa500I like you #ffffff" .. getPlayerName(playerss) .. "", root, 255, 165, 0, true) end else outputChatBox("#ffa500 I like you", player, 255, 165, 0, true) end end ) Link to comment
DrPhoX Posted January 18, 2013 Author Share Posted January 18, 2013 Great, antispam writes to chatbox but still don't work... It's looks like this: "-LaB-PhoFe: I like you!" "-LaB-: You must wait 5 seconds.." "-LaB-PhoFe: I like you!" "-LaB-: You must wait 5 seconds.." and kept repeating it when I write /likeu PS: "ERROR: commands.lua:29 attempt to concatenate global 'name' Link to comment
MR.S3D Posted January 18, 2013 Share Posted January 18, 2013 i tested it its work for me Link to comment
DrPhoX Posted January 18, 2013 Author Share Posted January 18, 2013 when i fast write /likeu so alternates sentence "I like you" with the sentence for anti-spam do you want screenshot? Link to comment
MR.S3D Posted January 18, 2013 Share Posted January 18, 2013 yes show me your screen this my screen Link to comment
DrPhoX Posted January 18, 2013 Author Share Posted January 18, 2013 So this is my screenshot.. http://www.2i.cz/f8b985af7c ... (Click to image for fullscreen) PS: Copy my code and try... PS2: on screenshot is "It still turns" my bad.. should there be this: "and still is repeated" local restriction = {} function getPlayerFromNamePart(name) if name then for i, player in ipairs(getElementsByType("player")) do if string.find(getPlayerName(player):lower(), tostring(name):lower(), 1, true) then return player end end end return false end addCommandHandler("likeu", function(player, cmd, players) if restriction[player] == true then return outputChatBox("-LaB-: #ffffffYou must wait 5 seconds to write this command again.", player, 255, 165, 0, true) end restriction[player] = true setTimer(function () restriction[player] = false end, 5000, 1) if players then local name = getPlayerName(player) local playerss = getPlayerFromNamePart(players) if playerss then outputChatBox("#FFFFFF".. name .."#ffa500: I like you #ffffff" .. getPlayerName(playerss) .. "! #ffffff(type: /likeu )", root, 255, 165, 0, true) end else outputChatBox("#ffffff".. name .."#ffa500: I like you! #ffffff(type: /likeu)", player, 255, 165, 0, true) end end ) 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