Jump to content

Script Help


xeon17

Recommended Posts

I'm wanted to create a event script ( cbug-deagle event) but the timer no work, i wanted when players write /participar

they enter a lobby and after 2 minutes the event should start but nothing happen after 2 minutes.. can someone fix the setTimer please?

function Start ( player) 
    setElementDimension ( player, 300 ) 
    setElementInterior ( player, 6, 768.20910644531, -36.314926147461, 1000.6864624023 ) 
    giveWeapon ( player, 24, 1000000000 ) 
end 
function EventStart ( player )  
    local accountname = getAccountName ( getPlayerAccount ( player ) ) 
    if (isObjectInACLGroup ( "user.".. accountname, aclGetGroup ( "Admin" ) )) then     
        outputChatBox ( "#00ff00 [CBUG-GAME] #00FFFFU Event has been created write /participar to participate", root, 255, 0, 0, true ) 
        else 
       outputChatBox ( "#00ff00 [CBUG-GAME] #00FFFFU You aren't Admin", player, 255, 0, 0, true ) 
       end 
    end 
addCommandHandler ( "evento", EventStart )  
  
function funcoesEvento ( player ) 
  if(getPedOccupiedVehicle ( player))then 
   outputChatBox("#FFF000[EVENTO]#FFFFFF Leave your vehicle to enter the event",player,255,255,255,true) 
    else 
    local x,y,z = getElementPosition ( player ) 
    setElementModel ( player, 0 ) 
    takeAllWeapons ( player ) 
    setElementDimension ( player, 300 ) 
    setPedArmor ( player, 100 ) 
    setElementHealth ( player, 100 ) 
    setElementInterior ( player, 17, 486.63619995117, -13.5563792228699, 1000.6796875 ) 
    outputChatBox("[CBUG-GAME] Event Started.",player,0,255,255) 
    addEventHandler ( "onPlayerSpawn", root, aff ) 
    addEventHandler ( "onPlayerSpawn", player, onSpawn ) 
    setTimer ( Start, 2000, 2000, 0 ) 
end 
end 
addCommandHandler ( "participar", funcoesEvento ) 
function onSpawn ( player ) 
    setElementModel ( player, 0 ) 
    takeAllWeapons ( source ) 
    setElementInterior ( source, 6, 768.20910644531, -36.314926147461, 1000.6864624023 ) 
    setElementModel ( source, 0 ) 
    setElementDimension ( source, 300 ) 
    setPedArmor ( source, 100 ) 
    setElementHealth ( source, 569 ) 
    giveWeapon ( source, 24, 1000000000 ) 
end 
function aff ( ) 
cancelEvent() 
end 
addEventHandler ( "onPlayerSpawn", root, aff ) 
  
  

BUGS:

[2014-04-13 14:00:33] WARNING: EventSystem\server.lua:2: Bad argument @ 'setElementDimension' [Expected element at argument 1, got number '0'] 
[2014-04-13 14:00:33] WARNING: EventSystem\server.lua:3: Bad argument @ 'setElementInterior' [Expected element at argument 1, got number '0'] 
[2014-04-13 14:00:33] WARNING: EventSystem\server.lua:4: Bad argument @ 'giveWeapon' [Expected element at argument 1, got number '0'] 

123

Edited by Guest
Link to comment
Dominating = setmetatable({}, Container) 
Dominating.__index = Dominating
Dominating.__parent = Container
Dominating.name = "Dominating"
 
Dominating.instance = nil
 
function Dominating:new()
    local self = self or setmetatable({}, Dominating)
    Container.new(self)
 
    self:setBounds(Graphics.getInsets(0, 0, 800, 600))
    self:setZOrder(-100)
   
    self.container = Container.new():init()
    local posx, posy, w, h = Graphics.getInsets(40,394,135,10)
    self.container:setBounds(posx,posy,w,h)
    self.container:setBackground(tocolor(0,0,0,101))
    self.container:setForeground(tocolor(0,0,0,200))
    self:add(self.container)
 
    self.progress = ProgressBar.new():init(ProgressBar.HORIZONTAL, 0, 100)
    self.progress:setBounds(0,0,w,h)
    self.progress:setBackground(tocolor(0,0,0,200))
    self.progress:setForeground(tocolor(250,110,0,200))
 
    self.progress:setValue(0)
    self.progress:setVisible(false)
 
   
    self.info = Label.new()
    self.info:setForeground(tocolor(255,255,255))
    self.info:setBackground(tocolor(0,0,0))
    self.info:setScale(1.0)
    self.info:setText("Iniciando Ataque")
    self.info:setAlignment(Label.CENTER)
    --self.info:setLocation(((w-h)/2)*scale, (46/2)*scale)
    self.info:setBounds(0,0,w,h)
    --self.info:setLocation(w/2, h/2)
    self.info:setVisible(false)
   
    self.type = Label.new()
    self.type:setForeground(tocolor(250,110,0,200))
    self.type:setBackground(tocolor(0,0,0))
    self.type:setScale(2.0)
    self.type:setText("~Gang Zona~")
    self.type:setFont("default-bold")
   
    self.type:setAlignment(Label.CENTER)
    --self.type:setLocation(((w-h)/2)*scale, (46/2)*scale)
    self.type:setBounds(0,h*2,w,h)
    --self.type:setLocation(w/2, h/2)
 
    self.name = Label.new()
    self.name:setForeground(tocolor(255,255,255))
    self.name:setBackground(tocolor(0,0,0))
    self.name:setScale(2.0)
    self.name:setText("")
    self.name:setAlignment(Label.CENTER)
    self.name:setBounds(0,h*4,w,h) 
   
 
    self.owner = Label.new()
    self.owner:setForeground(tocolor(255,255,255))
    self.owner:setBackground(tocolor(0,0,0))
    self.owner:setScale(Graphics.relativeH(1.2))
    self.owner:setText("")
    self.owner:setAlignment(Label.LEFT)
    self.owner:setBounds(Graphics.getInsets(180,555,w,h))   
    self:add(self.owner)
   
    self.gangwar = Panel.new()
    self.gangwar:setBounds(-10,-h*12,w+20,h*12)
    self.gangwar:setBackground(tocolor(0,0,0,101))
    self.gangwar:setForeground(tocolor(0,0,0,200))
   
    --self.teste = Panel.new()
    --self.teste:setBounds(self.gangwar:getWidth()/4,0,self.gangwar:getWidth()/3,self.gangwar:getHeight()/10)
    --self.teste:setBackground(tocolor(0,0,0,101))
    --self.teste:setForeground(tocolor(0,0,0,200))
    --self.gangwar:add(self.teste) 
   
    self.scoreLabel = Label.new()
    self.scoreLabel:setForeground(tocolor(255,255,255))
    self.scoreLabel:setBackground(tocolor(0,0,0))
    self.scoreLabel:setScale(1.0)
    self.scoreLabel:setText("Score")
    self.scoreLabel:setAlignment(Label.CENTER)
    self.scoreLabel:setBounds(self.gangwar:getWidth()/2,0,self.gangwar:getWidth()/3,self.gangwar:getHeight()/10)
 
    self.attackName = Label.new()
    self.attackName:setForeground(tocolor(255,255,255))
    self.attackName:setBackground(tocolor(0,0,0))
    self.attackName:setScale(1.0)
    self.attackName:setFont("default-bold")
    self.attackName:setText("???")
    self.attackName:setAlignment(Label.LEFT)
    self.attackName:setBounds(0,self.gangwar:getHeight()/10,self.gangwar:getWidth()/3,self.gangwar:getHeight()/10)
       
    self.attackDeaths = Label.new()
    self.attackDeaths:setForeground(tocolor(255,255,255))
    self.attackDeaths:setBackground(tocolor(0,0,0))
    self.attackDeaths:setScale(1.0)
    self.attackDeaths:setFont("default")
    self.attackDeaths:setText(" -Deaths: 0")
    self.attackDeaths:setAlignment(Label.LEFT)
    self.attackDeaths:setBounds(0,self.attackName:getY()+self.attackName:getHeight(),self.attackName:getWidth(),self.attackName:getHeight())   
       
    self.attackScore = Label.new()
    self.attackScore:setForeground(tocolor(255,255,255))
    self.attackScore:setBackground(tocolor(0,0,0))
    self.attackScore:setScale(1.0)
    self.attackScore:setText("")
    self.attackScore:setAlignment(Label.CENTER)
    self.attackScore:setBounds(self.scoreLabel:getX(), self.attackName:getY(),self.scoreLabel:getWidth(),self.scoreLabel:getHeight())
           
    self.defenseName = Label.new()
    self.defenseName:setForeground(tocolor(255,255,255))
    self.defenseName:setBackground(tocolor(0,0,0))
    self.defenseName:setScale(1.0)
    self.defenseName:setFont("default-bold")
    self.defenseName:setText("???")
    self.defenseName:setAlignment(Label.LEFT)
    self.defenseName:setBounds(0,self.attackDeaths:getY()+self.attackDeaths:getHeight(),self.attackName:getWidth(),self.attackName:getHeight())
   
    self.defenseDeaths = Label.new()
    self.defenseDeaths:setForeground(tocolor(255,255,255))
    self.defenseDeaths:setBackground(tocolor(0,0,0))
    self.defenseDeaths:setScale(1.0)
    self.defenseDeaths:setFont("default")
    self.defenseDeaths:setText(" -Deaths: 0")
    self.defenseDeaths:setAlignment(Label.LEFT)
    self.defenseDeaths:setBounds(0,self.defenseName:getY()+self.defenseName:getHeight(),self.defenseName:getWidth(),self.defenseName:getHeight())   
       
    self.defenseScore = Label.new()
    self.defenseScore:setForeground(tocolor(255,255,255))
    self.defenseScore:setBackground(tocolor(0,0,0))
    self.defenseScore:setScale(1.0)
    self.defenseScore:setText("")
    self.defenseScore:setAlignment(Label.CENTER)
    self.defenseScore:setBounds(self.scoreLabel:getX(), self.defenseName:getY(),self.scoreLabel:getWidth(),self.scoreLabel:getHeight())    
       
       
    self.timeLabel = Label.new()
    self.timeLabel:setForeground(tocolor(255,255,255))
    self.timeLabel:setBackground(tocolor(0,0,0))
    self.timeLabel:setScale(1.0)
    self.timeLabel:setText("TIME:  0:0")
    self.timeLabel:setAlignment(Label.LEFT)
    self.timeLabel:setBounds(0,self.defenseDeaths:getY()+self.defenseDeaths:getHeight()*2,self.defenseName:getWidth(),self.defenseName:getHeight()) 
   
    self.gangwar:add(self.scoreLabel)   
   
    self.gangwar:add(self.attackName)
    self.gangwar:add(self.attackDeaths) 
    self.gangwar:add(self.attackScore) 
   
    self.gangwar:add(self.defenseName) 
    self.gangwar:add(self.defenseDeaths)   
    self.gangwar:add(self.defenseScore)
   
    self.gangwar:add(self.timeLabel)   
   
    self.gangwar:setVisible(false);
   
   
    self.container:add(self.gangwar)
   
    self.container:add(self.progress)
    self.container:add(self.info)
    self.container:add(self.type)
    self.container:add(self.name)
 
    self.onDataChange = function(dataName, oldValue)
        if(source == localPlayer) then
            if(dataName == "hud_dominating") then
                local target = getElementData(localPlayer, "hud_dominating")
                if(isElement(target)) then
                    if(not self:isVisible()) then
                        self:setVisible(true)
                    end
                    if(getElementType(target) == 'gangzone') then
                        local war = getElementData(target, "war")
                        self.type:setText("~Gang Zona~")
                        self.name:setText(getElementData(target,"name"))
                        if(war and type(war) == "table") then
                            self.gangwar:setVisible(true)
                            self.progress:setVisible(false)
                            self.info:setVisible(false) 
                        else
                            self.gangwar:setVisible(false)
                            if(getElementData(localPlayer, "domination_checks")) then
                                local checks = getElementData(localPlayer, "domination_checks")
                                if(checks and checks > 0 and checks <= 100) then
                                    --self.progress:setVisible(true)
                                else
                                    self.progress:setVisible(false)
                                    self.info:setVisible(false) 
                                end
                            end
                        end
                        --self.name:setForeground(tocolor(getElementData(self.target,"r") or 255,getElementData(self.target,"g") or 255,getElementData(self.target,"b") or 255))   
                    elseif(getElementType(target) == 'territory') then
                        local war = getElementData(target, "war")
                        self.type:setText("~Territorio~")
                        self.name:setText(getElementData(target,"name"))
                        local gangName = getElementData(target,"gangName")
                        if(gangName) then
                            self.owner:setText("Owner: " .. gangName)
                        else
                            self.owner:setText("")
                        end
                        if(war and type(war) == "table") then
                            self.gangwar:setVisible(true)
                            self.progress:setVisible(false)
                            self.info:setVisible(false) 
                        else
                            self.gangwar:setVisible(false)
                            if(getElementData(localPlayer, "domination_checks")) then
                                local checks = getElementData(localPlayer, "domination_checks")
                                if(checks and checks > 0 and checks <= 100) then
                                    --self.progress:setVisible(true)
                                else
                                    self.progress:setVisible(false)
                                    self.info:setVisible(false) 
                                end
                            end
                        end 
                    elseif(getElementType(target) == 'village') then
                        local war = getElementData(target, "war")
                        self.type:setText("~Vila~")
                        self.name:setText(getElementData(target,"name"))
                        if(war and type(war) == "table") then
                            self.gangwar:setVisible(true)
                            self.progress:setVisible(false)
                            self.info:setVisible(false) 
                        else
                            self.gangwar:setVisible(false)
                            if(getElementData(localPlayer, "domination_checks")) then
                                local checks = getElementData(localPlayer, "domination_checks")
                                if(checks and checks > 0 and checks <= 100) then
                                    --self.progress:setVisible(true)
                                else
                                    self.progress:setVisible(false)
                                    self.info:setVisible(false) 
                                end
                            end
                        end                        
                    elseif(getElementType(target) == 'base') then
                        self:setVisible(true)
                        self.
Edited by Guest
Link to comment
function Start ( player) 
    setElementDimension ( player, 300 ) 
    setElementInterior ( player, 6, 768.20910644531, -36.314926147461, 1000.6864624023 ) 
    giveWeapon ( player, 24, 1000000000 ) 
end 
function EventStart ( player ) 
    local accountname = getAccountName ( getPlayerAccount ( player ) ) 
    if (isObjectInACLGroup ( "user.".. accountname, aclGetGroup ( "Admin" ) )) then     
        outputChatBox ( "#00ff00 [CBUG-GAME] #00FFFFU Event has been created write /participar to participate", root, 255, 0, 0, true ) 
        else 
       outputChatBox ( "#00ff00 [CBUG-GAME] #00FFFFU You aren't Admin", player, 255, 0, 0, true ) 
       end 
    end 
addCommandHandler ( "evento", EventStart ) 
  
function funcoesEvento ( player ) 
  if(getPedOccupiedVehicle ( player))then 
   outputChatBox("#FFF000[EVENTO]#FFFFFF Leave your vehicle to enter the event",player,255,255,255,true) 
    else 
    local x,y,z = getElementPosition ( player ) 
    setElementModel ( player, 0 ) 
    takeAllWeapons ( player ) 
    setElementDimension ( player, 300 ) 
    setPedArmor ( player, 100 ) 
    setElementHealth ( player, 100 ) 
    setElementInterior ( player, 17, 486.63619995117, -13.5563792228699, 1000.6796875 ) 
    outputChatBox("[CBUG-GAME] Event Started.",player,0,255,255) 
    addEventHandler ( "onPlayerSpawn", root, aff ) 
    addEventHandler ( "onPlayerSpawn", player, onSpawn ) 
    setTimer ( Start, 2000, 2000, player ) 
end 
end 
addCommandHandler ( "participar", funcoesEvento ) 
function onSpawn ( player ) 
    setElementModel ( player, 0 ) 
    takeAllWeapons ( source ) 
    setElementInterior ( source, 6, 768.20910644531, -36.314926147461, 1000.6864624023 ) 
    setElementModel ( source, 0 ) 
    setElementDimension ( source, 300 ) 
    setPedArmor ( source, 100 ) 
    setElementHealth ( source, 569 ) 
    giveWeapon ( source, 24, 1000000000 ) 
end 
function aff ( ) 
cancelEvent() 
end 
addEventHandler ( "onPlayerSpawn", root, aff ) 

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