Jump to content

strange things and few warnings


battlefield

Recommended Posts

Hi it happend something strange to me that I had server online and went mapping. When I finished all of my resource data except of meta.xml .map and login script was deleted. Then I restored all of the data but now I have next warnings

[2010-12-30 22:51:11] WARNING: FunFlight1\script4.lua:2: Bad argument @ 'addEventHandler'

here is script4

addEvent("clientKickInactivePlayer",true) 
addEventHandler("clientKickInactivePlayer",root,kickInactivePlayer) 
function kickInactivePlayer() 
    kickPlayer(client,"Please accept our rules.") 
end 

[2010-12-30 22:51:11] WARNING: Loading script failed: FunFlight1\script7.lua:3: '}' expected (to close '{' at line 1) near '['

and script7

local keypadCodes = { 
    ["a51MainGateKeypadCode"] = "0000" 
        ["a51tank"] = "0000" 
        ["a51car"] = "0000" 
        ["a51rescar"] = "0000" 
        ["dtresc"] = "0000" 
} 
addEvent("verifyKeypadCode",true) 
addEventHandler("verifyKeypadCode",root,function(code,keypadID) 
    if code then 
        if code == keypadCodes[keypadID] then 
            triggerClientEvent(client,"onKeypadVerificationSuccessful",client,keypadID) 
        else 
            triggerClientEvent(client,"onKeypadVerificationFailed",client,keypadID) 
        end 
    end 
end) 

Untill I added all the other things except a51MainGateKeypatCode it worked fine but now crashes.

Note:all the codes are different they are set to 0000 only for forum

P.S. Can someone tell me how to put all of that codes in xml file because I have no idea how to do that. :|

Edited by Guest
Link to comment

script4: function must be created BEFORE you add is as an event handler (now it doesnt exist when you adding it)

addEvent("clientKickInactivePlayer",true) 
function kickInactivePlayer() 
    kickPlayer(client,"Please accept our rules.") 
end 
addEventHandler("clientKickInactivePlayer",root,kickInactivePlayer) 

script7: table values must be separated by commas:

local keypadCodes = { 
        ["a51MainGateKeypadCode"] = "0000", 
         ["a51tank"] = "0000", 
         ["a51car"] = "0000", 
         ["a51rescar"] = "0000", 
         ["dtresc"] = "0000" 
 } 

as for XML — read wiki about XML functions

Link to comment

Thanks for that it works but i have problem at GUI. [2010-12-30 23:49:00] WARNING: Loading script failed: FunFlight1\client\gui4.lua:146: 'end' expected (to close 'function' at line 124) near ''

function createKeypad() 
    local sWidth, sHeight = guiGetScreenSize() 
  
    local Width,Height = 142,276 
    local X = (sWidth/2) - (Width/2) 
    local Y = (sHeight/2) - (Height/2) 
    keypadWindow = guiCreateWindow(X,Y,Width,Height,"Keypad",false) 
  
    guiWindowSetSizable(keypadWindow,false) 
  
    keypadButton1 = guiCreateButton(13,68,37,36,"1",false,keypadWindow) 
    keypadButton2 = guiCreateButton(53,68,37,36,"2",false,keypadWindow) 
    keypadButton3 = guiCreateButton(93,68,37,36,"3",false,keypadWindow) 
    keypadButton4 = guiCreateButton(13,108,37,36,"4",false,keypadWindow) 
    keypadButton5 = guiCreateButton(53,108,37,36,"5",false,keypadWindow) 
    keypadButton6 = guiCreateButton(93,108,37,36,"6",false,keypadWindow) 
    keypadButton7 = guiCreateButton(13,148,37,36,"7",false,keypadWindow) 
    keypadButton8 = guiCreateButton(53,148,37,36,"8",false,keypadWindow) 
    keypadButton9 = guiCreateButton(93,148,37,36,"9",false,keypadWindow) 
    keypadButtonAsterix = guiCreateButton(13,188,37,36,"*",false,keypadWindow) 
    keypadButton0 = guiCreateButton(53,188,37,36,"0",false,keypadWindow) 
    keypadButtonHash = guiCreateButton(93,188,37,36,"#",false,keypadWindow) 
    keypadButtonExit = guiCreateButton(13,228,37,36,"Exit",false,keypadWindow) 
    keypadButtonEnter = guiCreateButton(53,228,37,36,"Enter",false,keypadWindow) 
    keypadButtonClear = guiCreateButton(93,228,37,36,"Clear",false,keypadWindow) 
  
    addEventHandler("onClientGUIClick",keypadWindow,processKeypadClicks,true) 
         
        keypadGridlistDisplay = guiCreateGridList(13,25,117,33,false,keypadWindow) 
    guiGridListSetSelectionMode(keypadGridlistDisplay,2) 
    guiSetAlpha(keypadGridlistDisplay,0.6) 
    keypadLabelDisplay = guiCreateLabel(14,26,115,30,"Enter Keycode.",false,keypadWindow) 
    guiLabelSetColor(keypadLabelDisplay,255,000,000) 
    guiLabelSetVerticalAlign(keypadLabelDisplay,"center") 
    guiLabelSetHorizontalAlign(keypadLabelDisplay,"center",false) 
  
    guiSetVisible(keypadWindow,false) 
end 
  
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),createKeypad) 
function updateDisplay(text) 
    if text then 
        if tonumber(text) or text == "*" or text == "#" then 
            guiSetText(keypadLabelDisplay,guiGetText(keypadLabelDisplay) .. text) 
        else 
            guiSetText(keypadLabelDisplay,text) 
        end  
    else 
        guiSetText(keypadLabelDisplay,"") 
    end 
end 
function processKeypadClicks(button,state) 
    if button == "left" and state == "up" then 
        if getElementType(source) == "gui-button" then 
            triggerEvent("onKeypadButtonClicked",source,getElementData(keypadWindow,"keypadID")) 
        end 
    end 
end 
addEvent("onKeypadButtonClicked",false) 
addEventHandler("onKeypadButtonClicked",root, 
    function(keypadID) 
        if guiGetText(keypadLabelDisplay) == "Enter Keycode." or guiGetText(keypadLabelDisplay) == "Invalid Keycode." then 
            updateDisplay() 
        end 
  
  
        if guiGetText(source) == "Clear" then 
            updateDisplay() 
  
        elseif guiGetText(source) == "Enter" then 
            local code = guiGetText(keypadLabelDisplay) 
  
            if code then 
                triggerServerEvent("verifyKeypadCode",getLocalPlayer(),code,keypadID) 
            end 
  
        elseif guiGetText(source) == "Exit" then 
            guiSetVisible(keypadWindow,false) 
            updateDisplay("Enter Keycode.") 
            showCursor(false,false) 
  
        else 
            updateDisplay(guiGetText(source))    
        end 
    end 
) 
addEvent("onKeypadVerificationSuccessful",true) 
addEventHandler("onKeypadVerificationSuccessful",root, 
    function() 
        guiSetVisible(keypadWindow,false) 
        updateDisplay("Enter Keycode.") 
        showCursor(false,false) 
    end 
) 
addEvent("onKeypadVerificationFailed",true) 
addEventHandler("onKeypadVerificationFailed",root, 
    function() 
        updateDisplay("Enter Keycode.") 
                guiSetVisibel(keypadWindow,false) 
                showCursor(false,false) 
                outputChatBox("Wrong code contact [FF]Battlefield for more inf or visit [url=http://www.funflightserver.co.nr]http://www.funflightserver.co.nr[/url]") 
        end 
) 
addCommandHandler("gate",function() 
    guiSetVisible(keypadWindow,true) 
    showCursor(true,true) 
    setElementData(keypadWindow,"keypadID","a51MainGateKeypadCode") 
end) 
addCommandHandler("rescue",function() 
        guiSetVisible(keypadWindow,true) 
        showCursor(true,true) 
        setElementData(keypadWindow,"keypadID","dtresc") 
end) 
addCommandHandler("tank",function() 
        guiSetVisible(keypadWindow,true) 
        showCursor(true,true) 
        setElementData(keypadWindow,"keypadID","a51tank") 
end) 
addCommandHandler("jetroom",function() 
        guiSetVisible(keypadWindow,true) 
        showCursor(true,true) 
        setElementData(keypadWindow,"keypadID","a51rescar") 
end) 
addCommandHandler("car",function() 
        guiSetVisible(keypadWindow,true) 
        showCursor(true,true) 
        setElementData(keypadWindow,"keypadID","a51car") 
end) 
addEventHandler("onKeypadVerificationSuccessful",root, 
    function(keypadID) 
        local gate = getElementByID(keypadID) 
  
        if gate then 
            local x = tonumber(getElementData(gate,"newPosX")) 
            local y = tonumber(getElementData(gate,"newPosY")) 
            local z = tonumber(getElementData(gate,"newPosZ")) 
  
            moveObject(gate,1500,x,y,z) 
  
            x = tonumber(getElementData(gate,"posX")) 
            y = tonumber(getElementData(gate,"posY")) 
            z = tonumber(getElementData(gate,"posZ"))    
  
            setTimer(moveObject,5000,1,gate,1500,x,y,z) 
        end 
    end 
) 

Can you help me about this one too please? EDIT:Nvm I fixed it.

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