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 not restriction[player] then restriction[player] = true setTimer(function () restriction[player] = false end, 5000, 1) else return outputChatBox("-LaB-: #ffffffYou must wait 5 seconds to write this command again.", player, 255, 165, 0, true) end if players then local playerss = getPlayerFromNamePart(players) if playerss then outputChatBox("#FFFFFF".. getPlayerName(player) .."#ffa500: I like you #ffffff" .. getPlayerName(playerss) .. "! #ffffff(type: /likeu )", root, 255, 165, 0, true) end else outputChatBox("#ffffff".. getPlayerName(player) .."#ffa500: I like you! #ffffff(type: /likeu)", player, 255, 165, 0, true) end end ) Link to comment
DrPhoX Posted January 18, 2013 Author Share Posted January 18, 2013 Same problem but next new problem is here... when i write /likeu it show on chat 2 times.. 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 not restriction[player] then restriction[player] = true setTimer(function () restriction[player] = false end, 5000, 1) if players then local playerss = getPlayerFromNamePart(players) if playerss then outputChatBox("#FFFFFF".. getPlayerName(player) .."#ffa500: I like you #ffffff" .. getPlayerName(playerss) .. "! #ffffff(type: /likeu )", root, 255, 165, 0, true) end else outputChatBox("#ffffff".. getPlayerName(player) .."#ffa500: I like you! #ffffff(type: /likeu)", player, 255, 165, 0, true) end else outputChatBox("-LaB-: #ffffffYou must wait 5 seconds to write this command again.", player, 255, 165, 0, true) end end ) Link to comment
MR.S3D Posted January 18, 2013 Share Posted January 18, 2013 (edited) this repeat? outputChatBox("-LaB-: #ffffffYou must wait 5 seconds to write this command again.", player, 255, 165, 0, true) Edited January 18, 2013 by Guest Link to comment
DrPhoX Posted January 18, 2013 Author Share Posted January 18, 2013 Ohhh.. Now work's all solved Problem was that I had there are other commands TY! so much Link to comment
DrPhoX Posted January 18, 2013 Author Share Posted January 18, 2013 And one more thing... When i have this: 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 not restriction[player] then restriction[player] = true setTimer(function () restriction[player] = false end, 5000, 1) if players then local playerss = getPlayerFromNamePart(players) if playerss then outputChatBox("#FFFFFF".. getPlayerName(player) .."#ffa500: I like you #ffffff" .. getPlayerName(playerss) .. "! #ffffff(type: /likeu )", root, 255, 165, 0, true) end else outputChatBox("#ffffff".. getPlayerName(player) .."#ffa500: I like you! #ffffff(type: /likeu)", player, 255, 165, 0, true) end else outputChatBox("-LaB-: #ffffffYou must wait 5 seconds to write this command again.", player, 255, 165, 0, true) end end ) function hateMap(player, cmd) if (not restriction[player]) then restriction[player] = {} end if not restriction[player][cmd] then outputChatBox("#FFFFFF".. getPlayerName(player) .."#ffa500: I hate this map! #ffffff(type: /hatemap)", root, 255, 255, 255, true) restriction[player][cmd] = true setTimer(function () restriction[player][cmd] = false end, 5000, 1) else outputChatBox("#ffa500-LaB-: #ffffffYou must wait 5 seconds to write this command again.", player, 255, 255, 255, true) end end addCommandHandler("hatemap", hateMap) So command /hatemap working but command /likeu and /likeu don't work, it shows antispam message, not (I like you) message 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 (not restriction[player]) then restriction[player] = {} end if not restriction[player][cmd] then restriction[player][cmd] = true setTimer(function () restriction[player][cmd] = false end, 5000, 1) if players then local playerss = getPlayerFromNamePart(players) if playerss then outputChatBox("#FFFFFF".. getPlayerName(player) .."#ffa500: I like you #ffffff" .. getPlayerName(playerss) .. "! #ffffff(type: /likeu )", root, 255, 165, 0, true) end else outputChatBox("#ffffff".. getPlayerName(player) .."#ffa500: I like you! #ffffff(type: /likeu)", player, 255, 165, 0, true) end else outputChatBox("-LaB-: #ffffffYou must wait 5 seconds to write this command again.", player, 255, 165, 0, true) end end ) function hateMap(player, cmd) if (not restriction[player]) then restriction[player] = {} end if not restriction[player][cmd] then outputChatBox("#FFFFFF".. getPlayerName(player) .."#ffa500: I hate this map! #ffffff(type: /hatemap)", root, 255, 255, 255, true) restriction[player][cmd] = true setTimer(function () restriction[player][cmd] = false end, 5000, 1) else outputChatBox("#ffa500-LaB-: #ffffffYou must wait 5 seconds to write this command again.", player, 255, 255, 255, true) end end addCommandHandler("hatemap", hateMap) Link to comment
DrPhoX Posted January 18, 2013 Author Share Posted January 18, 2013 Thank you very much 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