Jump to content

end expected near else [NEW SCRIPT]


~Air

Recommended Posts

  
  
function playerChat(message, messageType) 
    if messageType == 2 then 
        cancelEvent() 
        local acc = getPlayerAccount(source) 
        if not isGuestAccount(acc) then 
            if getAccountData(acc,"chatc") and getElementData(source, "Vip") == true then 
                local color = getAccountData(acc,"chatc") 
                for i,team in ipairs(getPlayersInTeam(getPlayerTeam(source))) do 
                local r,g,b = getTeamColor(getPlayerTeam(source)) 
                if ( r ) and ( g ) and ( b ) then 
                    outputChatBox(RGBToHex(r,g,b).."(TEAM): "..getPlayerName(source)..": "..color..""..message, root, r, g, b, true ) 
                else 
                    outputChatBox(RGBToHex(r,g,b).."(TEAM): "..getPlayerName(source)..": #FFFFFF"..message, root, r, g, b, true ) 
                end 
            else 
                outputChatBox("(TEAM): "..getPlayerName(source)..": #FFFFFF"..message, root, r, g, b, true ) 
            end 
            outputServerLog("CHAT: "..getPlayerName(source)..": "..message) 
        end 
    end 
end 
addEventHandler("onPlayerChat", root, playerChat) 
  
function RGBToHex(red, green, blue, alpha) 
    if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then 
        return nil 
    end 
    if(alpha) then 
        return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha) 
    else 
        return string.format("#%.2X%.2X%.2X", red,green,blue) 
    end 
end 
  

Link to comment
  
  
function playerChat(message, messageType) 
    if messageType == 2 then 
        cancelEvent() 
        local acc = getPlayerAccount(source) 
        if not isGuestAccount(acc) then 
            if getAccountData(acc,"chatc") and getElementData(source, "Vip") == true then 
                local color = getAccountData(acc,"chatc") 
                for i,team in ipairs(getPlayersInTeam(getPlayerTeam(source))) do 
                    local r,g,b = getTeamColor(getPlayerTeam(source)) 
                    if ( r ) and ( g ) and ( b ) then 
                        outputChatBox(RGBToHex(r,g,b).."(TEAM): "..getPlayerName(source)..": "..color..""..message, root, r, g, b, true ) 
                    else 
                        outputChatBox(RGBToHex(r,g,b).."(TEAM): "..getPlayerName(source)..": #FFFFFF"..message, root, r, g, b, true ) 
                    end 
                end  
            else 
                outputChatBox("(TEAM): "..getPlayerName(source)..": #FFFFFF"..message, root, r, g, b, true ) 
            end 
            outputServerLog("CHAT: "..getPlayerName(source)..": "..message) 
        end 
    end 
end 
addEventHandler("onPlayerChat", root, playerChat) 
  
function RGBToHex(red, green, blue, alpha) 
    if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then 
        return nil 
    end 
    if(alpha) then 
        return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha) 
    else 
        return string.format("#%.2X%.2X%.2X", red,green,blue) 
    end 
end 
  

Link to comment
  • Other Languages Moderators
function playerChat(message, messageType) 
    if messageType == 2 then 
        cancelEvent() 
        local acc = getPlayerAccount(source) 
        if not isGuestAccount(acc) then 
            local color = getAccountData(acc, "chatc") 
            local VIP = getElementData(source, "Vip") 
            local team = getPlayerTeam(source) 
            local r, g, b = getTeamColor(team) 
            local name = getPlayerName(source) 
            for i, player in ipairs(getPlayersInTeam(team)) do 
                if color and VIP then 
                    outputChatBox("(TEAM): "..name..": "..color..message, player, r, g, b, true) 
                else 
                    outputChatBox("(TEAM): "..name..": #FFFFFF"..message, player, r, g, b, true) 
                end 
            end 
            outputServerLog("CHAT: "..name..": "..message) 
        end 
    end 
end 
addEventHandler("onPlayerChat", root, playerChat) 

Link to comment

I have got one more problem but at one other script:

I had lots of tries to fix it but it still doesn't work.

(end expected near else)

Here is the script:

function setDiscoLights () 
    local bougheadlights = getAccountData(account,"boughtHeadlights2")  
    if not bougheadlights then  
    if cash >= 10000 or (getElementData(source, "Vip") and cash >= 5000) then 
    setTimer(outputChatBox,50,1,"* #FFFFFF"..getPlayerName(source).."#FFFFFF bought Disco-Headlights!",getRootElement(),0,255,0,true) 
    if getElementData(source, "Vip") == true then 
    addStat(account, "cash", -5000) 
    else 
    addStat(account, "cash", -10000) 
    end 
    setAccountData(account, "DiscoLights",true)  
    setAccountData(account, "boughtHeadlights2",true)  
    end 
    else 
    outputChatBox ("* #FFFFFFYou don't have got enough money!",source,unpack(scriptcol[5])) 
    cancelEvent()                
    else 
    outputChatBox ("* #FFFFFFYou already have bought Disco-Headlights!",source,unpack(scriptcol[5])) 
    cancelEvent()                
    end  
addEvent("setDiscoLights",true) 
addEventHandler("setDiscoLights",getRootElement(),setDiscoLights) 
  

Link to comment
I have got one more problem but at one other script:

I had lots of tries to fix it but it still doesn't work.

(end expected near else)

Here is the script:

function setDiscoLights () 
    local bougheadlights = getAccountData(account,"boughtHeadlights2")  
    if not bougheadlights then  
      if cash >= 10000 or (getElementData(source, "Vip") and cash >= 5000) then 
      setTimer(outputChatBox,50,1,"* #FFFFFF"..getPlayerName(source).."#FFFFFF bought Disco-Headlights!",getRootElement(),0,255,0,true) 
       if getElementData(source, "Vip") == true then 
       addStat(account, "cash", -5000) 
      else 
       addStat(account, "cash", -10000) 
      end 
      setAccountData(account, "DiscoLights",true)  
      setAccountData(account, "boughtHeadlights2",true)  
     end 
    else 
    outputChatBox ("* #FFFFFFYou don't have got enough money!",source,unpack(scriptcol[5])) 
    cancelEvent()                
    else 
    outputChatBox ("* #FFFFFFYou already have bought Disco-Headlights!",source,unpack(scriptcol[5])) 
    cancelEvent()                
    end  
addEvent("setDiscoLights",true) 
addEventHandler("setDiscoLights",getRootElement(),setDiscoLights) 
  

How hard can this be...

Two else in a row.

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