Jump to content

[HELP] Question


Recommended Posts

Hi! With your help i started to learn scripting, thanks a lot! :D I have this script:

Quote

comand = "insta" 

function chatinsta( thePlayer, _, ... )
    local message = table.concat ( { ... }, " " )
    if ( isPlayerOnGroup ( thePlayer ) ) then
    for _, player in ipairs ( getElementsByType ( "player" ) ) do
    if ( isPlayerOnGroup ( player ) ) then
    if getElementData(thePlayer, "Chat:Delay1") == true then
    outputChatBox("#ff0000Stop spamming!", thePlayer, 255, 255, 255, true )
    return end
    conta = getAccountName(getPlayerAccount(thePlayer))                

    if isObjectInACLGroup ("user."..conta, aclGetGroup ( "Admin" ) ) then
        outputChatBox(" #F04190 » Instagram » #ADFF2FPresidente - #ADFF2F["..getElementData(thePlayer, "ID").."] - #ffffff".. getPlayerName ( thePlayer ) .." #ADFF2F» :#F04190 ".. message, player, 255, 255, 255, true )
                                                    
    elseif isObjectInACLGroup ("user."..conta, aclGetGroup ( "Everyone" ) ) then
        outputChatBox(" #F04190 » Instagram » #ADFF2FPlayer - #ADFF2F["..getElementData(thePlayer, "ID").."] - #ffffff".. getPlayerName ( thePlayer ) .." #ADFF2F» :#F04190 ".. message, player, 255, 255, 255, true )    
        end
    end
    end
    end
    setElementData ( thePlayer, "Chat:Avisado", true )
    setElementData ( thePlayer, "Chat:Delay1",true )
    setTimer ( setElementData, 3000, 1, thePlayer, "Chat:Delay1", false )
end
addCommandHandler ( comand,  chatinsta)

addEventHandler("onPlayerJoin", getRootElement(),  
function() 
  bindKey(source, "m", "down", "chatbox", "insta") 
end 

addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() 
  for index,player in pairs(getElementsByType("player")) do 
        bindKey(player,"m", "down", "chatbox", "insta")
  end 
end 

The problem is this: When i press "m" and text or type "/insta <Text>" i'm getting this in Console: ERROR: [Mods]\InstaChat\Chat.lua:36: attempt to concatenate a boolean value.

Line 36 is "outputChatBox(" #F04190 » Instagram » #ADFF2FPresidente - #ADFF2F["..getElementData(thePlayer, "ID").."] - #ffffff".. getPlayerName ( thePlayer ) .." #ADFF2F» :#F04190 ".. message, player, 255, 255, 255, true )"   --- The line with aclGetGroup Admin

Can you please, help me?

Link to comment

Use the code button when posting code:
ImwbNsC.png

 

getElementData(thePlayer, "ID")

is returning a bool(true/false)
Most likely the element data for ID isn't set for the player so it returns false which gives you the error that it is trying to combine a string and a bool.

You can output the bool as a string by changing it to this:

tostring(getElementData(thePlayer, "ID"))

 

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