Jump to content

help me pls


Whit3

Recommended Posts

Error:

end' expected ( to close 'if' at line 165) near 'eof'

end expected to close if at line 165 eof

---------------

i'm trying to edit the time on the map...

if sname == "#time" then

---------------

local mapMeta = xmlLoadFile(":"..resName.."/meta.xml") 
    if mapMeta then 
        local mapChild = xmlFindChild(mapMeta,"map",0) 
        local mapPath = xmlNodeGetAttributes(mapChild) 
        local mapFile = xmlLoadFile(":"..resName.."/"..mapPath["src"]) 
        if mapFile then 
            local tempTable = {} 
            local fileTable = {} 
            local fileSize = 0 
            local spawnTable = {} 
            local scripts = xmlNodeGetChildren(mapMeta) 
                       for i, v in ipairs(xmlNodeGetChildren(mapMeta)) do 
                      local name = xmlNodeGetName(v) 
            if name == "settings" then 
                local sname = xmlNodeGetAttribute(v,"name") 
                if sname == "#time" then 
                    local value = xmlNodeGetAttribute(v, "value") 
                    if value then 
                        value = string.gsub(value, "%s+", "") 
                        value = string.gsub(value, "[%[%]]", "") 
                        setTime(value:match('(%d+)%d+)')) 
                    else 
                        setTime(12,0) 
                    end 
                               
-- il primo for 
            for i, node in ipairs(scripts) do 
                local type = xmlNodeGetName(node) 
                if type == "script" then 
                    local info = xmlNodeGetAttributes(node) 
                    if info["type"] and info["type"] == "client" then 
                        local hFile = fileOpen 
  
(":"..resName.."/"..info["src"],true) 
                        if hFile then 
                            local size = fileGetSize(hFile) 
                            tempTable[#tempTable+1] =  
  
{type,fileRead(hFile, size)} 
                            fileClose(hFile) 
                        end 
                    end 
                                           
               -- local name = xmlNodeGetName(v) 
               -- local sname = xmlNodeGetAttribute(v,"name") 
                       --    elseif sname == "#time" then 
                --  local value = xmlNodeGetAttribute(v, "value") 
                    --if value then 
                    --  value = string.gsub(value, "%s+", "") 
                    --value = string.gsub(value, "[%[%]]", "") 
                    --  setTime(value:match('(%d+)%d+)')) 
                        --mapTime = value 
                    --else 
                        --setTime(12,0) 
                    --end 
                                        
                elseif type == "file" then 
                    local info = xmlNodeGetAttributes(node) 
                    if info["src"] then 
                        --if not string.find(info["src"],".mp3",1)  
  
and not string.find(info["src"],".ogg",1) then 
                            fileTable[#fileTable+1] = info["src"] 
                            local hFile = fileOpen 
  
(":"..resName.."/"..info["src"],true) 
                            fileSize = fileSize + fileGetSize 
  
(hFile) 
                            fileClose(hFile) 
                        --end 
                    end 
                end  
            end 
                        
            local mapStuff = xmlNodeGetChildren(mapFile) 
            for i,node in ipairs(mapStuff) do 
                local type = xmlNodeGetName(node) 
                local attrs = xmlNodeGetAttributes ( node ) 
                local et = {} 
                local st = {} 
                if type == "object" then 
                    local collisions = true; 
                    local alpha = 255; 
                    local doublesided = false 
                    local interior = 0; 
                    local scale = 1; 
                    if (attrs["interior"]) then 
                        interior = attrs["interior"]; 
                    end 
                    if (attrs["doublesided"]) then 
                        doublesided = attrs["doublesided"] 
                    end 
                    if (attrs["collisions"]) then 
                        collisions = attrs["collisions"]; 
                    end 
                    if (attrs["alpha"]) then 
                        alpha = attrs["alpha"]; 
                    end 
                    if (attrs["MSTalpha"]) then 
                        alpha = attrs["MSTalpha"]; 
                    end 
                    if (attrs["scale"]) then 
                        scale = attrs["scale"]; 
                    end 
                    et = {type,attrs["model"],attrs["posX"],attrs 
  
["posY"],attrs["posZ"],attrs["rotX"],attrs["rotY"],attrs 
  
["rotZ"],interior,collisions,alpha,scale,doublesided} 
                elseif type == "marker" then 
                    et = {type,attrs["posX"],attrs["posY"],attrs 
  
["posZ"],attrs["type"],attrs["size"],attrs["color"],attrs["interior"],attrs["id"]} 
                elseif type == "vehicle" then 
                    et = {type,attrs["model"],attrs["posX"],attrs 
  
["posY"],attrs["posZ"],attrs["rotX"],attrs["rotY"],attrs["rotZ"]} 
                elseif type == "racepickup" then 
                    et = {type,attrs["type"],attrs["vehicle"],attrs 
  
["posX"],attrs["posY"],attrs["posZ"],attrs["rotX"],attrs["rotY"],attrs["rotZ"]} 
                elseif type == "spawnpoint" then 
                    et = {type,attrs["vehicle"],attrs["posX"],attrs 
  
["posY"],attrs["posZ"],attrs["rotX"],attrs["rotY"],attrs["rotZ"]} 
                end 
                tempTable[#tempTable+1] = et 
            end 
  
              local realtime = tonumber(string.sub(get("#"..resName..".time"),1,2)) or 0; 
               
  
            local weather = tonumber(get("#"..resName..".weather")) or 0; 
             
            if (arg2 == 2) then 
                setElementData(source,"Map",mapName2) 
                triggerLatentClientEvent 
  
(source,"onServerSendMapTable",200000,false,source,tempTable,0,weather,resName,fileTable,file 
  
Size); 
            elseif (arg2 == 1) then 
                g_Map["Hunter"] =  
  
{tempTable,realtime,weather,resName,fileTable,fileSize,mapName2}; 
                for k,v in ipairs(getElementsByType("player")) do 
                    local room = getElementData(v,"room"); 
                    if room and (room == 1) then 
                        setElementData(v,"Map",mapName2) 
                        triggerLatentClientEvent 
  
(v,"onServerSendMapTable",200000,false,v,g_Map["Hunter"][1],g_Map["Hunter"][2],g_Map 
  
["Hunter"][3],g_Map["Hunter"][4],g_Map["Hunter"][5],g_Map["Hunter"][6]); 
                    end 
                end 
            elseif (arg2 == 4) then 
                g_Map["DM"] =  
  
{tempTable,realtime,weather,resName,fileTable,fileSize,mapName2}; 
                for k,v in ipairs(getElementsByType("player")) do 
                    local room = getElementData(v,"room"); 
                    if room and (room == 4) then 
                        setElementData(v,"Map",mapName2) 
                        setElementData(v,"Ready",false) 
                        setElementData(v,"State","Loading") 
                        triggerLatentClientEvent 
  
(v,"onServerSendMapTable",200000,false,v,g_Map["DM"][1],g_Map["DM"][2],g_Map["DM"][3],g_Map 
  
["DM"][4],g_Map["DM"][5],g_Map["DM"][6]); 
                    end 
                end 
                DMState = "waiting"; 
            elseif (arg2 == 5) then 
                g_Map["DD"] =  
  
{tempTable,realtime,weather,resName,fileTable,fileSize,mapName2}; 
                local id = 1; 
                for k,v in ipairs(getElementsByType("player")) do 
                    local room = getElementData(v,"room"); 
                    if room and (room == 5) then 
                        setElementData(v,"Map",mapName2) 
                        setElementData(v,"Ready",false) 
                        setElementData(v,"State","Loading") 
                        triggerLatentClientEvent 
  
(v,"onServerSendMapTable",200000,false,v,g_Map["DD"][1],g_Map["DD"][2],g_Map["DD"][3],g_Map 
  
["DD"][4],g_Map["DD"][5],g_Map["DD"][6],id); 
                        id = id + 1; 
                    end 
                end 
                DDState = "waiting"; 
            elseif (arg2 == 6) then 
                g_Map["Shooter"] =  
  
{tempTable,realtime,weather,resName,fileTable,fileSize,mapName2}; 
                for k,v in ipairs(getElementsByType("player")) do 
                    local room = getElementData(v,"room"); 
                    if room and (room == 6) then 
                        setElementData(v,"Map",mapName2) 
                        setElementData(v,"Ready",false) 
                        setElementData(v,"State","Loading") 
                        triggerLatentClientEvent 
  
(v,"onServerSendMapTable",200000,false,v,g_Map["Shooter"][1],g_Map["Shooter"][2],g_Map 
  
["Shooter"][3],g_Map["Shooter"][4],g_Map["Shooter"][5],g_Map["Shooter"][6]); 
                    end 
                end 
                OSState = "waiting"; 
            end 
            xmlUnloadFile(mapFile) 
        end 
        xmlUnloadFile(mapMeta) 
    end 
end 

Link to comment

This is the Code Edited( but it don't set the time )

The Defalut Code is this:

local realtime = tonumber(string.sub(get("#"..resName..".time"),1,2)) or 0;

( but don't set correctly the time )

    local mapMeta = xmlLoadFile(":"..resName.."/meta.xml") 
    if mapMeta then 
        local mapChild = xmlFindChild(mapMeta,"map",0) 
        local mapPath = xmlNodeGetAttributes(mapChild) 
        local mapFile = xmlLoadFile(":"..resName.."/"..mapPath["src"]) 
                --------------------------------------------- 
        for i, v in ipairs(xmlNodeGetChildren(mapMeta)) do 
            local name = xmlNodeGetName(v) 
            if name == "settings" then 
                local sname = xmlNodeGetAttribute(v,"name") 
                if sname == "#time" then 
                    local value = xmlNodeGetAttribute(v, "value") 
                    if value then 
                        value = string.gsub(value, "%s+", "") 
                        value = string.gsub(value, "[%[%]]", "") 
                        setTime(value:match('(%d+)%d+)')) 
                                                realtime = value 
                  
                    else 
                        setTime(0,0) 
                          end 
                                            end 
                                          end 
                                        end                                                   
  
 ---------------------------------------------  
        if mapFile then 
            local tempTable = {} 
            local fileTable = {} 
            local fileSize = 0 
            local spawnTable = {} 
            local scripts = xmlNodeGetChildren(mapMeta)                         
-- il primo for 
            for i, node in ipairs(scripts) do 
                local type = xmlNodeGetName(node) 
                if type == "script" then 
                    local info = xmlNodeGetAttributes(node) 
                    if info["type"] and info["type"] == "client" then 
                        local hFile = fileOpen 
  
(":"..resName.."/"..info["src"],true) 
                        if hFile then 
                            local size = fileGetSize(hFile) 
                            tempTable[#tempTable+1] =  
  
{type,fileRead(hFile, size)} 
                            fileClose(hFile) 
                        end 
                    end 
                                           
                elseif type == "file" then 
                    local info = xmlNodeGetAttributes(node) 
                    if info["src"] then 
                        --if not string.find(info["src"],".mp3",1)  
  
and not string.find(info["src"],".ogg",1) then 
                            fileTable[#fileTable+1] = info 
  
["src"] 
                            local hFile = fileOpen 
  
(":"..resName.."/"..info["src"],true) 
                            fileSize = fileSize + fileGetSize 
  
(hFile) 
                            fileClose(hFile) 
                        --end 
                    end 
                end  
            end 
                        
            local mapStuff = xmlNodeGetChildren(mapFile) 
            for i,node in ipairs(mapStuff) do 
                local type = xmlNodeGetName(node) 
                local attrs = xmlNodeGetAttributes ( node ) 
                local et = {} 
                local st = {} 
                if type == "object" then 
                    local collisions = true; 
                    local alpha = 255; 
                    local doublesided = false 
                    local interior = 0; 
                    local scale = 1; 
                    if (attrs["interior"]) then 
                        interior = attrs["interior"]; 
                    end 
                    if (attrs["doublesided"]) then 
                        doublesided = attrs["doublesided"] 
                    end 
                    if (attrs["collisions"]) then 
                        collisions = attrs["collisions"]; 
                    end 
                    if (attrs["alpha"]) then 
                        alpha = attrs["alpha"]; 
                    end 
                    if (attrs["MSTalpha"]) then 
                        alpha = attrs["MSTalpha"]; 
                    end 
                    if (attrs["scale"]) then 
                        scale = attrs["scale"]; 
                    end 
                    et = {type,attrs["model"],attrs["posX"],attrs 
  
["posY"],attrs["posZ"],attrs["rotX"],attrs["rotY"],attrs 
  
["rotZ"],interior,collisions,alpha,scale,doublesided} 
                elseif type == "marker" then 
                    et = {type,attrs["posX"],attrs["posY"],attrs 
  
["posZ"],attrs["type"],attrs["size"],attrs["color"],attrs["interior"],attrs["id"]} 
                elseif type == "vehicle" then 
                    et = {type,attrs["model"],attrs["posX"],attrs 
  
["posY"],attrs["posZ"],attrs["rotX"],attrs["rotY"],attrs["rotZ"]} 
                elseif type == "racepickup" then 
                    et = {type,attrs["type"],attrs["vehicle"],attrs 
  
["posX"],attrs["posY"],attrs["posZ"],attrs["rotX"],attrs["rotY"],attrs["rotZ"]} 
                elseif type == "spawnpoint" then 
                    et = {type,attrs["vehicle"],attrs["posX"],attrs 
  
["posY"],attrs["posZ"],attrs["rotX"],attrs["rotY"],attrs["rotZ"]} 
                end 
                tempTable[#tempTable+1] = et 
            en 
               
            local weather = tonumber(get("#"..resName..".weather")) or 0; 
             
            if (arg2 == 2) then 
                setElementData(source,"Map",mapName2) 
                triggerLatentClientEvent 
  
(source,"onServerSendMapTable",200000,false,source,tempTable,0,weather,resName,fileTable,fil 
  
eSize); 
            elseif (arg2 == 1) then 
                g_Map["Hunter"] =  
  
{tempTable,realtime,weather,resName,fileTable,fileSize,mapName2}; 
                for k,v in ipairs(getElementsByType("player")) do 
                    local room = getElementData(v,"room"); 
                    if room and (room == 1) then 
                        setElementData(v,"Map",mapName2) 
                        triggerLatentClientEvent 
  
(v,"onServerSendMapTable",200000,false,v,g_Map["Hunter"][1],g_Map["Hunter"][2],g_Map 
  
["Hunter"][3],g_Map["Hunter"][4],g_Map["Hunter"][5],g_Map["Hunter"][6]); 
                    end 
                end 
            elseif (arg2 == 4) then 
                g_Map["DM"] =  
  
{tempTable,realtime,weather,resName,fileTable,fileSize,mapName2}; 
                for k,v in ipairs(getElementsByType("player")) do 
                    local room = getElementData(v,"room"); 
                    if room and (room == 4) then 
                        setElementData(v,"Map",mapName2) 
                        setElementData(v,"Ready",false) 
                        setElementData(v,"State","Loading") 
                        triggerLatentClientEvent 
  
(v,"onServerSendMapTable",200000,false,v,g_Map["DM"][1],g_Map["DM"][2],g_Map["DM"][3],g_Map 
  
["DM"][4],g_Map["DM"][5],g_Map["DM"][6]); 
                    end 
                end 
                DMState = "waiting"; 
            elseif (arg2 == 5) then 
                g_Map["DD"] =  
  
{tempTable,realtime,weather,resName,fileTable,fileSize,mapName2}; 
                local id = 1; 
                for k,v in ipairs(getElementsByType("player")) do 
                    local room = getElementData(v,"room"); 
                    if room and (room == 5) then 
                        setElementData(v,"Map",mapName2) 
                        setElementData(v,"Ready",false) 
                        setElementData(v,"State","Loading") 
                        triggerLatentClientEvent 
  
(v,"onServerSendMapTable",200000,false,v,g_Map["DD"][1],g_Map["DD"][2],g_Map["DD"][3],g_Map 
  
["DD"][4],g_Map["DD"][5],g_Map["DD"][6],id); 
                        id = id + 1; 
                    end 
                end 
                DDState = "waiting"; 
            elseif (arg2 == 6) then 
                g_Map["Shooter"] =  
  
{tempTable,realtime,weather,resName,fileTable,fileSize,mapName2}; 
                for k,v in ipairs(getElementsByType("player")) do 
                    local room = getElementData(v,"room"); 
                    if room and (room == 6) then 
                        setElementData(v,"Map",mapName2) 
                        setElementData(v,"Ready",false) 
                        setElementData(v,"State","Loading") 
                        triggerLatentClientEvent 
  
(v,"onServerSendMapTable",200000,false,v,g_Map["Shooter"][1],g_Map["Shooter"][2],g_Map 
  
["Shooter"][3],g_Map["Shooter"][4],g_Map["Shooter"][5],g_Map["Shooter"][6]); 
                    end 
                end 
                OSState = "waiting"; 
            end 
            xmlUnloadFile(mapFile) 
        end 
        xmlUnloadFile(mapMeta) 
    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...