Script Anime

Zabogal

Little Mouse
Work in progress

local Anime = ''

function eventChatCommand(playerName, command)
if command == "naruto" then
DB = tfm.exec.addImage("aa52f32e6b5a11e78ef9109836a51f7d.png", "%"..playerName, -35, -80)
elseif command == "goku" then
DB = tfm.exec.addImage("3a5267126b5a11e78ef9109836a51f7d.png", "%"..playerName, -35, -80)
elseif command == "goku black" then
DB = tfm.exec.addImage("7527e8906b5911e78ef9109836a51f7d.png", "%"..playerName, -35, -80)
elseif command == "ash ketchup" then
DB = tfm.exec.addImage("b9fccfc46b5b11e78ef9109836a51f7d.png", "%"..playerName, -35, -60)
elseif command == "kaneki" then
DB = tfm.exec.addImage("fffec41e6b5b11e78ef9109836a51f7d.png", "%"..playerName, -35, -60)
elseif command == "saitama" then
DB = tfm.exec.addImage("0f3d26086b5e11e78ef9109836a51f7d.png", "%"..playerName, -35, -100)
elseif command == "stingy" then
DB = tfm.exec.addImage("ce0413266b5e11e78ef9109836a51f7d.png", "%"..playerName, -35, -120)
elseif command == "ram" then
DB = tfm.exec.addImage("21cb43166e8a11e78ef9109836a51f7d.png", "%"..playerName, -35, -100)
elseif command == "izuku" then
DB = tfm.exec.addImage("65a962ce6e8b11e78ef9109836a51f7d.png", "%"..playerName, -35, -100)
elseif command == "sasuke" then
DB = tfm.exec.addImage("4ae6ba086e8c11e78ef9109836a51f7d.png", "%"..playerName, -35, -75)
end
end

system.disableChatCommandDisplay("naruto")
system.disableChatCommandDisplay("goku")
system.disableChatCommandDisplay("goku black")
system.disableChatCommandDisplay("ash ketchup")
system.disableChatCommandDisplay("stingy")
system.disableChatCommandDisplay("ram")
system.disableChatCommandDisplay("izuku")
system.disableChatCommandDisplay("sasuke")

-The perssonages are naruto,goku,goku black, ash ketchup,stingy,ram,izuku and sasuke
 

Horthex

Little Mouse
Nice job, I like it, but you repeat the same functions over and over instead of putting them in a loop. If you add about 10-20 more of these characters your code will be unreasonably long.

I fixed this by adding a table called "resources" which contains 10 arrays (if you add more characters, then this amount increases). Each array has 3 values: the first one is the command you want to execute, the second is the URL to the image, and the third one is the Y coordinate. These are the only values in your code that change in the functions.

Instead of using if-elseif statements, it's a better idea to use a repeat-until loop. In this scenario it does the same, but it's a lot shorter. I'm pretty sure you understand the code, so I won't explain it. Also in your code if you executed the commands over and over your images didn't disappear. I fixed it in this one.

Don't take me wrong, I don't want to be the guy who knows better and corrects everyone, I'm just trying to help you make more efficient codes.

Have a nice day!

Code:
imageID = 0
resources = {{"naruto","aa52f32e6b5a11e78ef9109836a51f7d.png",-80},{"goku","3a5267126b5a11e78ef9109836a51f7d.png",-80},{"goku black","7527e8906b5911e78ef9109836a51f7d.png",-80},{"ash ketchup","b9fccfc46b5b11e78ef9109836a51f7d.png",-60},{"kaneki","fffec41e6b5b11e78ef9109836a51f7d.png",-60},{"saitama","0f3d26086b5e11e78ef9109836a51f7d.png",-100},{"stingy","ce0413266b5e11e78ef9109836a51f7d.png",-120},{"ram","21cb43166e8a11e78ef9109836a51f7d.png",-100},{"izuku","65a962ce6e8b11e78ef9109836a51f7d.png",-100},{"sasuke","4ae6ba086e8c11e78ef9109836a51f7d.png",-75}}

function eventChatCommand(playerName,command)
    local counter = 1
    local found = false
    repeat
        if (counter == 11) then
            break
        end
        if (command == resources[counter][1]) then
            tfm.exec.removeImage(imageID)
            imageID = tfm.exec.addImage(resources[counter][2],"%"..playerName,-35,resources[counter][3])
            found = true
        else
            counter = counter + 1
        end
    until (found == true)
end

for (i=1,#resources,1) do
    system.disableChatCommandDisplay(resources[i][1])
end
 
Last edited:

Zabogal

Little Mouse
Nice job, I like it, but you repeat the same functions over and over instead of putting them in a loop. If you add about 10-20 more of these characters your code will be unreasonably long.

I fixed this by adding a table called "resources" which contains 10 arrays (if you add more characters, then this amount increases). Each array has 3 values: the first one is the command you want to execute, the second is the URL to the image, and the third one is the Y coordinate. These are the only values in your code that change in the functions.

Instead of using if-elseif statements, it's a better idea to use a repeat-until loop. In this scenario it does the same, but it's a lot shorter. I'm pretty sure you understand the code, so I won't explain it. Also in your code if you executed the commands over and over your images didn't disappear. I fixed it in this one.

Don't take me wrong, I don't want to be the guy who knows better and corrects everyone, I'm just trying to help you make more efficient codes.

Have a nice day!

Code:
imageID = 0
resources = {{"naruto","aa52f32e6b5a11e78ef9109836a51f7d.png",-80},{"goku","3a5267126b5a11e78ef9109836a51f7d.png",-80},{"goku black","7527e8906b5911e78ef9109836a51f7d.png",-80},{"ash ketchup","b9fccfc46b5b11e78ef9109836a51f7d.png",-60},{"kaneki","fffec41e6b5b11e78ef9109836a51f7d.png",-60},{"saitama","0f3d26086b5e11e78ef9109836a51f7d.png",-100},{"stingy","ce0413266b5e11e78ef9109836a51f7d.png",-120},{"ram","21cb43166e8a11e78ef9109836a51f7d.png",-100},{"izuku","65a962ce6e8b11e78ef9109836a51f7d.png",-100},{"sasuke","4ae6ba086e8c11e78ef9109836a51f7d.png",-75}}

function eventChatCommand(playerName,command)
    local counter = 1
    local found = false
    repeat
        if (counter == 11) then
            break
        end
        if (command == resources[counter][1]) then
            tfm.exec.removeImage(imageID)
            imageID = tfm.exec.addImage(resources[counter][2],"%"..playerName,-35,resources[counter][3])
            system.disableChatCommandDisplay(resources[counter][1])
            found = true
        else
            counter = counter + 1
        end
    until (found == true)
end

for (i=1,#resources,1) do
    system.disableChatCommandDisplay(resources[i][1])
end
Thanks <3
 
Nice
 
Top
"Dev-TR" theme by Soulzone