micheal1230 Posted June 9, 2012 Share Posted June 9, 2012 I Dont Understand Elseif Error: The Error Would Be A Line 52 This is Just A Snipit Of The Whole Script function globalOOC(thePlayer, commandName, ...) local logged = tonumber(getElementData(thePlayer, "loggedin")) if (logged==1) then if not (...) then outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14) else local oocEnabled = exports.global:getOOCState() message = table.concat({...}, " ") local muted = getElementData(thePlayer, "muted") if (oocEnabled==0) and not (exports.global:isPlayerAdmin(thePlayer)) then outputChatBox("OOC Chat is currently disabled.", thePlayer, 255, 0, 0) elseif (muted==1) then outputChatBox("You are currenty muted from the OOC Chat.", thePlayer, 255, 0, 0) else local players = exports.pool:getPoolElementsByType("player") local playerName = getPlayerName(thePlayer) local playerID = getElementData(thePlayer, "playerid") exports.logs:logMessage("[OOC: Global Chat] " .. playerName .. ": " .. message, 1) for k, arrayPlayer in ipairs(players) do local logged = tonumber(getElementData(arrayPlayer, "loggedin")) local targetOOCEnabled = getElementData(arrayPlayer, "globalooc") local adminlevel = exports.global:getPlayerAdminLevel(thePlayer) local gmlevel = exports.global:getPlayerGMLevel(thePlayer) title = exports.global:getPlayerAdminTitle(thePlayer) gmtitle = exports.global:getPlayerGMTitle(thePlayer) if adminlevel >= 4 then color = "#CC0000" else color = "#00ff00" end if gmlevel >= 4 then color1 = "#CC0000" else color1 = "#00ff00" end if adminlevel == 0 or getElementData(thePlayer,"hiddenadmin") == 1 then title = false end if exports.global:getPlayerDonatorLevel(thePlayer) > 0 and exports.global:getPlayerAdminLevel(thePlayer) == 0 and exports.global:getPlayerGMLevel(thePlayer) == 0 then color = "#CC9933" title = "Donator" end if (logged==1) and (targetOOCEnabled==1) then if title and color then outputChatBox("(( [GOOC] (" .. playerID .. ") ["..color.."" ..title.. "#ffe4c4] " .. playerName .. ": " .. message.." ))",arrayPlayer, 255,228,196,true) else outputChatBox("(( [GOOC] (" .. playerID .. ") " .. playerName .. ": " .. message.." ))", arrayPlayer, 255,228,196,true) elseif gmtitle and color1 then outputChatBox("(( [GOOC] (" .. playerID .. ") ["..color1.."" ..gmtitle.. "#ffe4c4] " .. playerName .. ": " .. message.." ))",arrayPlayer, 255,228,196,true) end end end end end end end addCommandHandler("o", globalOOC, false, false) addCommandHandler("GlobalOOC", globalOOC) Link to comment
Vision Posted June 9, 2012 Share Posted June 9, 2012 function globalOOC(thePlayer, commandName, ...) local logged = tonumber(getElementData(thePlayer, "loggedin")) if (logged==1) then if not (...) then outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14) else local oocEnabled = exports.global:getOOCState() message = table.concat({...}, " ") local muted = getElementData(thePlayer, "muted") if (oocEnabled==0) and not (exports.global:isPlayerAdmin(thePlayer)) then outputChatBox("OOC Chat is currently disabled.", thePlayer, 255, 0, 0) elseif (muted==1) then outputChatBox("You are currenty muted from the OOC Chat.", thePlayer, 255, 0, 0) else local players = exports.pool:getPoolElementsByType("player") local playerName = getPlayerName(thePlayer) local playerID = getElementData(thePlayer, "playerid") exports.logs:logMessage("[OOC: Global Chat] " .. playerName .. ": " .. message, 1) for k, arrayPlayer in ipairs(players) do local logged = tonumber(getElementData(arrayPlayer, "loggedin")) local targetOOCEnabled = getElementData(arrayPlayer, "globalooc") local adminlevel = exports.global:getPlayerAdminLevel(thePlayer) local gmlevel = exports.global:getPlayerGMLevel(thePlayer) title = exports.global:getPlayerAdminTitle(thePlayer) gmtitle = exports.global:getPlayerGMTitle(thePlayer) if adminlevel >= 4 then color = "#CC0000" else color = "#00ff00" end if gmlevel >= 4 then color1 = "#CC0000" else color1 = "#00ff00" end if adminlevel == 0 or getElementData(thePlayer,"hiddenadmin") == 1 then title = false end if exports.global:getPlayerDonatorLevel(thePlayer) > 0 and exports.global:getPlayerAdminLevel(thePlayer) == 0 and exports.global:getPlayerGMLevel(thePlayer) == 0 then color = "#CC9933" title = "Donator" end if (logged==1) and (targetOOCEnabled==1) then if title and color then outputChatBox("(( [GOOC] (" .. playerID .. ") ["..color.."" ..title.. "#ffe4c4] " .. playerName .. ": " .. message.." ))",arrayPlayer, 255,228,196,true) else outputChatBox("(( [GOOC] (" .. playerID .. ") " .. playerName .. ": " .. message.." ))", arrayPlayer, 255,228,196,true) end elseif gmtitle and color1 then outputChatBox("(( [GOOC] (" .. playerID .. ") ["..color1.."" ..gmtitle.. "#ffe4c4] " .. playerName .. ": " .. message.." ))",arrayPlayer, 255,228,196,true) end end end end end end addCommandHandler("o", globalOOC, false, false) addCommandHandler("GlobalOOC", globalOOC) Link to comment
Castillo Posted June 9, 2012 Share Posted June 9, 2012 function globalOOC(thePlayer, commandName, ...) local logged = tonumber(getElementData(thePlayer, "loggedin")) if (logged==1) then if not (...) then outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14) else local oocEnabled = exports.global:getOOCState() message = table.concat({...}, " ") local muted = getElementData(thePlayer, "muted") if (oocEnabled==0) and not (exports.global:isPlayerAdmin(thePlayer)) then outputChatBox("OOC Chat is currently disabled.", thePlayer, 255, 0, 0) elseif (muted==1) then outputChatBox("You are currenty muted from the OOC Chat.", thePlayer, 255, 0, 0) else local players = exports.pool:getPoolElementsByType("player") local playerName = getPlayerName(thePlayer) local playerID = getElementData(thePlayer, "playerid") exports.logs:logMessage("[OOC: Global Chat] " .. playerName .. ": " .. message, 1) for k, arrayPlayer in ipairs(players) do local logged = tonumber(getElementData(arrayPlayer, "loggedin")) local targetOOCEnabled = getElementData(arrayPlayer, "globalooc") local adminlevel = exports.global:getPlayerAdminLevel(thePlayer) local gmlevel = exports.global:getPlayerGMLevel(thePlayer) title = exports.global:getPlayerAdminTitle(thePlayer) gmtitle = exports.global:getPlayerGMTitle(thePlayer) if adminlevel >= 4 then color = "#CC0000" else color = "#00ff00" end if gmlevel >= 4 then color1 = "#CC0000" else color1 = "#00ff00" end if adminlevel == 0 or getElementData(thePlayer,"hiddenadmin") == 1 then title = false end if exports.global:getPlayerDonatorLevel(thePlayer) > 0 and exports.global:getPlayerAdminLevel(thePlayer) == 0 and exports.global:getPlayerGMLevel(thePlayer) == 0 then color = "#CC9933" title = "Donator" end if (logged==1) and (targetOOCEnabled==1) then if title and color then outputChatBox("(( [GOOC] (" .. playerID .. ") ["..color.."" ..title.. "#ffe4c4] " .. playerName .. ": " .. message.." ))",arrayPlayer, 255,228,196,true) elseif gmtitle and color1 then outputChatBox("(( [GOOC] (" .. playerID .. ") ["..color1.."" ..gmtitle.. "#ffe4c4] " .. playerName .. ": " .. message.." ))",arrayPlayer, 255,228,196,true) else -- This has to go after 'elseif'. outputChatBox("(( [GOOC] (" .. playerID .. ") " .. playerName .. ": " .. message.." ))", arrayPlayer, 255,228,196,true) end end end end end end end addCommandHandler("o", globalOOC, false, false) addCommandHandler("GlobalOOC", globalOOC) Read comment. Link to comment
micheal1230 Posted June 9, 2012 Author Share Posted June 9, 2012 I Dont Understand ElseifError: The Error Would Be A Line 52 This is Just A Snipit Of The Whole Script function globalOOC(thePlayer, commandName, ...) local logged = tonumber(getElementData(thePlayer, "loggedin")) if (logged==1) then if not (...) then outputChatBox("SYNTAX: /" .. commandName .. " [Message]", thePlayer, 255, 194, 14) else local oocEnabled = exports.global:getOOCState() message = table.concat({...}, " ") local muted = getElementData(thePlayer, "muted") if (oocEnabled==0) and not (exports.global:isPlayerAdmin(thePlayer)) then outputChatBox("OOC Chat is currently disabled.", thePlayer, 255, 0, 0) elseif (muted==1) then outputChatBox("You are currenty muted from the OOC Chat.", thePlayer, 255, 0, 0) else local players = exports.pool:getPoolElementsByType("player") local playerName = getPlayerName(thePlayer) local playerID = getElementData(thePlayer, "playerid") exports.logs:logMessage("[OOC: Global Chat] " .. playerName .. ": " .. message, 1) for k, arrayPlayer in ipairs(players) do local logged = tonumber(getElementData(arrayPlayer, "loggedin")) local targetOOCEnabled = getElementData(arrayPlayer, "globalooc") local adminlevel = exports.global:getPlayerAdminLevel(thePlayer) local gmlevel = exports.global:getPlayerGMLevel(thePlayer) title = exports.global:getPlayerAdminTitle(thePlayer) gmtitle = exports.global:getPlayerGMTitle(thePlayer) if adminlevel >= 4 then color = "#CC0000" else color = "#00ff00" end if gmlevel >= 4 then color1 = "#CC0000" else color1 = "#00ff00" end if adminlevel == 0 or getElementData(thePlayer,"hiddenadmin") == 1 then title = false end if exports.global:getPlayerDonatorLevel(thePlayer) > 0 and exports.global:getPlayerAdminLevel(thePlayer) == 0 and exports.global:getPlayerGMLevel(thePlayer) == 0 then color = "#CC9933" title = "Donator" end if (logged==1) and (targetOOCEnabled==1) then if title and color then outputChatBox("(( [GOOC] (" .. playerID .. ") ["..color.."" ..title.. "#ffe4c4] " .. playerName .. ": " .. message.." ))",arrayPlayer, 255,228,196,true) else outputChatBox("(( [GOOC] (" .. playerID .. ") " .. playerName .. ": " .. message.." ))", arrayPlayer, 255,228,196,true) elseif gmtitle and color1 then outputChatBox("(( [GOOC] (" .. playerID .. ") ["..color1.."" ..gmtitle.. "#ffe4c4] " .. playerName .. ": " .. message.." ))",arrayPlayer, 255,228,196,true) end end end end end end end addCommandHandler("o", globalOOC, false, false) addCommandHandler("GlobalOOC", globalOOC) Oh so elseif is like the else for if? Link to comment
Castillo Posted June 9, 2012 Share Posted June 9, 2012 http://www.troubleshooters.com/codecorn ... and_Elseif Link to comment
Moderators IIYAMA Posted June 11, 2012 Moderators Share Posted June 11, 2012 Elseif is something like "other" But why not?> if yes == 1 then if yes ==2 then end if yes ==3 then end if yes ==4 then end if yes ==5 then end end and else"is something like "or" ???????? I am right or wrong? Link to comment
TAPL Posted June 11, 2012 Share Posted June 11, 2012 Elseif is something like "other"But why not?> if yes == 1 then if yes ==2 then end if yes ==3 then end if yes ==4 then end if yes ==5 then end end and else"is something like "or" ???????? I am right or wrong? 'if' is the same as 'elseif' but the different that you won't need to put end every time in 'elseif' so the 11 line in 'if' can be 6 line in 'elseif' if yes == 1 then elseif yes ==2 then elseif yes ==3 then elseif yes ==4 then elseif yes ==5 then end Link to comment
Moderators IIYAMA Posted June 11, 2012 Moderators Share Posted June 11, 2012 ok, this was very clear information. thx 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