Jump to content

Help with script


DrPhoX

Recommended Posts

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

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 :P can you create the script with that?

Link to comment
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 :P 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

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
  
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 by Guest
Link to comment
  
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
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
  
  
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

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 by Guest
Link to comment
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 by Guest
Link to comment

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
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

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 by Guest
Link to comment
  
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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...