Jump to content

FSXTim

Members
  • Posts

    220
  • Joined

  • Last visited

Posts posted by FSXTim

  1. Hello,

    I got the following error in the serverside script: Bad argument @ 'setElementData' [Expected element at argument 1, got string '0'] (Zeile 5)

    clientside:

    function unbannB (state) 
        if state == "left" then 
            if source == GUIEditor_Admin_Button[10] then 
                local nick = guiGetText(GUIEditor_Admin_Edit[9]) 
                triggerServerEvent("unbannP", lp, nick) 
            end 
        end  
    end 
    addEventHandler("onClientGUIClick", getRootElement(), unbannB) 
    

    serverside:

    function unbannP (nick) 
        local name = MySQL_GetString("Bann", "user_data", nick) 
        if name then 
            local admin = getPlayerName(source) 
            setElementData(name, "Bann", "0") 
            outputChatBox ("#FFFFFF|INFO| "..admin.." #FF3030hat #FFFFFF"..nick.." #FF3030entbannt!", getRootElement(), 205, 0, 0, true)     
        else 
            local player = source 
            outputChatBox ("Der Spieler existiert nicht!", player, 255, 48, 48) 
        end 
    end 
    addEvent("unbannP", true) 
    addEventHandler ("unbannP", getRootElement(), unbannP) 
    

    Greets

  2. Error (line 13): Bad argument @ 'setElementData' [expected element at argument one, got nil]

    function spam(message) 
        local player = source 
        local msg = getElementData(source, "Spam") 
        if message == msg then 
            outputChatBox("Bitte wiederhole dich nicht!", source, 255, 0, 0) 
            cancelEvent() 
        end 
        if isTimer(spamTimer) then 
            killTimer(spamTimer)  
        end 
        spamTimer = setTimer( 
            function() 
                setElementData(source, "Spam", "0") 
            end  
        , 10000, 1, source) 
        setElementData(source, "Spam", message)      
    end 
    addEventHandler("onPlayerChat", getRootElement(), spam) 
    

    Greets

  3. I have still the same error. What do I have to change?

    function muteCheck()     
        setTimer( 
            function() 
                playerN = source 
                playerNa = getPlayerName(playerN) 
                if tonumber(getElementData(playerN, "Mute")) > 0 then 
                    local muteTime = tonumber(getElementData(playerN, "Mute")) 
                    setPlayerMuted(playerN, true) 
                    mTime = muteTime*60000 
                    setTimer( 
                        function() 
                            if getElementData(playerN, "LoggedIn") then 
                                setPlayerMuted(playerN, false) 
                                outputChatBox("#FFFFFF"..playerNa.." #00CD00kann nun wieder schreiben!", getRootElement(), 0, 205, 0, true) 
                            end  
                        end 
                    , mTime, 1, 0) 
                end  
            end 
        , 50, 1)     
    end 
    

  4. Hello,

    I have a small problem.

    Error (line 6): Bad argument @ 'getElementData' [expected element at argument one, got nil]

    function muteCheck()     
        setTimer( 
            function() 
                local player = source 
                local name = getPlayerName(player) 
                if tonumber(getElementData(player, "Mute")) > 0 then 
                    local muteTime = tonumber(getElementData(player, "Mute")) 
                    setPlayerMuted(player, true) 
                    mTime = muteTime*60000 
                    setTimer( 
                        function() 
                            if getElementData(player, "LoggedIn") then 
                                setPlayerMuted(player, false) 
                                outputChatBox("#FFFFFF"..name.." #00CD00kann nun wieder schreiben!", getRootElement(), 0, 205, 0, true) 
                            end  
                        end 
                    , mTime, 1, 0) 
                end  
            end 
        , 50, 1)     
    end 
    

    Greets

  5. Hello,

    I have more than 61000 dollars and I type "/givemoney FSXTim 100", but the console says:

    "You don't have enough money!" (line 9 in the script)

    function giveMoney(player, command, target, m) 
        local target = getPlayerFromName(target) 
        local money = tonumber(m) 
        if isElement(target) then 
            if tonumber(getElementData(player, "Geld") == money) or tonumber(getElementData(player, "Geld") > money) then 
                setElementData(player, "Geld", getElementData(player, "Geld") - money)  
                setElementData(target, "Geld", getElementData(target, "Geld") + money)  
            else 
                outputChatBox("You don't have enough money!", player, 255, 48, 48) 
            end 
        end  
    end 
    addCommandHandler("givemoney", giveMoney) 
    

    Greets

  6. Error: Bad argument @ 'guiSetVisible' [expected gui-element at argument 1, got nil] [line 8]

    images = {} 
    for i, index in ipairs (getElementsByType("player")) do 
        guiCreateStaticImage(650,30 - 15 + 15 * i,18,16, rank, false, gImage["playerList"]) 
    end 
      
    function iFalse() 
        for i = 1, getPlayerCount() do 
            guiSetVisible(images[i], false) 
        end 
    end 
    addEvent("iFalse", true) 
    addEventHandler("iFalse", getRootElement(), iFalse) 
      
    function getPlayerCount()  
        return #getElementsByType("player") 
    end 
    

    Greets

  7. Thank you, but now I have another problem.

    Error: attempt to index global 'images' (a nil value) (line 2)

    for i, index in ipairs (getElementsByType("player")) do 
        images[i] = guiCreateStaticImage(650,30 - 15 + 15 * i,18,16, "rank/rank.png", false, gImage["playerList"]) 
    end 
         
    function iFalse() 
        for i = 1, getPlayerCount() do 
            guiSetVisible(images[i], false) 
        end 
    end 
    addEvent("iFalse", true) 
    addEventHandler("iFalse", getRootElement(), iFalse) 
      
    function getPlayerCount()  
        return #getElementsByType("player") 
    end 
    

    Greets

  8. Error: 'end' expected (to close 'function' at line 1) near 'setTimer'

    function getPlayerCount() 
        for i, playerName in ipairs (getElementsByType("player")) do 
            players = players + 1 
        end 
        return players 
        setTimer( 
            function()  
                players = 0  
            end 
        , 100, 1)    
    end 
    

    Greets

  9. Hello,

    I have a problem with my script.

    i = number of players

    An example: There are 3 players on the server, than is i = 3. If I type "test", only one of the 3 images is invisible, but I want, that all 3 images are invisible.

    images = guiCreateStaticImage(650,30 - 15 + 15 * i,18,16, "rank/rank.png", false, gImage["playerList"]) 
      
    function iFalse() 
        guiSetVisible(images, false) 
    end 
    addCommandHandler("test", iFalse) 
    

    Is there a function, to make all the images of a GUI invisible?

    Greets

  10. Hello,

    the resource "playerlist" doesn't restart, if somebody join the game.

    Error: Bad argument @ 'restartResource'

    function join () 
        local jPlayer = getPlayerName (source) 
        outputChatBox("|INFO| #6495ED"..jPlayer.." #FFFFFFhat German Blue Race betreten.", getRootElement(), 255, 255, 255, true) 
        restartResource(playerlist)      
    end 
    addEventHandler("onPlayerJoin", getRootElement(), join) 
    

    Greets

  11. Hallo,

    I want to kill the timer in this script. But now all the timers of the resource are killed. How can I only kill this one?

    function spam(message, messageType) 
        local player = source 
        local msg = getElementData(source, "Spam") 
        if message == msg then 
            outputChatBox("Bitte wiederhole dich nicht!", source, 255, 0, 0) 
            cancelEvent() 
        end 
        timers = getTimers(10000) 
        for timerKey, timerValue in ipairs(timers) do 
          killTimer(timerValue) 
        end 
        setTimer( 
            function() 
                setElementData(player, "Spam", "0") 
            end  
        , 10000, 1) 
        setElementData(source, "Spam", message)      
    end 
    addEventHandler("onPlayerChat", getRootElement(), spam) 
    

    Greets

  12. If I am alone on my server, this script works perfectly. If another player join, the loop stops, but why?

      
    function setZeit() 
        outputChatBox("Test1", getRootElement()) 
        for index, spieler in ipairs (getElementsByType("player")) do 
            outputChatBox("Test2", getRootElement()) 
            if getElementData( spieler, "LoggedIn" ) then 
                outputChatBox("Test3", getRootElement()) 
                setElementData(spieler, "Spielzeit", getElementData(spieler, "Spielzeit") + 1) 
                local result =  mysql_query(sqlcon, "UPDATE user_data SET Spielzeit='"..tostring(getElementData(spieler,"Spielzeit")).."' WHERE Username='"..tostring(getElementData(spieler,"Username")).."';") 
                if (result) then mysql_free_result(result) end 
            end 
        end 
        setTimer(setZeit2, 30000, 1)     
    end 
    addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), setZeit) 
      
    function setZeit2() 
        setTimer(setZeit, 30000, 1) 
    end 
    

    Greets

×
×
  • Create New...