Jump to content

1LoL1

Members
  • Posts

    944
  • Joined

  • Last visited

Posts posted by 1LoL1

  1. Hey guys,

    I want to ask you a question, I scripted a script, and my problem when I do an action the message out put too slow, it takes about 5 to 10 seconds to appear at the chatbox.

    Can you guess to me from where that can be caused?

    Post the code.

  2. I want to check and see if a new player registered, how would I do it?

    Because I want to give money if it's a new player registered. But on my login, you register then it takes you back to login and press login.

    If anyone can help it'll be helpful!

    addEventHandler("onPlayerLogin", getRootElement(), 
       function (_, acc) 
          if getAccountData(acc, "wb") then 
             outputChatBox("Welcome back!") 
          else 
             setAccountData(acc, "wb", "test") 
             outputChatBox("Welcome new player!") 
        end 
    end) 
    

  3. I drew an image on my login screen but the image does not work for every resolution.
            local Width,Height = 350,350 
      
            local x, y = guiGetScreenSize() 
        local px, py = 1980, 1080 
        local sx, sy = (x/px), (x/py)    
      
            Image = guiCreateStaticImage( x/2-640, y/2-360, 1980, 1280, "login_bg.png", false) 
    

    Can anybody help me how do I make it work for every resolution?

    Try this but start in 800x600 resolution.

    x, y = guiGetScreenSize() 
    rx, ry = (x/800), (y/600) 
    image = guiCreateStaticImage(rx*640, ry*360, rx*1980, ry*1280, "login_bg.png",false) 
    

  4. It's marker not market.

    marker = createMarker( x, y, z, "cylinder", 1.5, 255, 255, 0, 170 ) 
           
    addCommandHandler("move", 
    function () 
    moveObject(marker, 1500, x, y, z) 
    end) 
    

  5. Instead of
    setAccountData(account,"cash",playerCash+betAmount+betAmount*2) 
    

    You can just use

    givePlayerMoney(thePlayer,playerCash+betAmount+betAmount*2) 
    

    He used in all setAccountData so why givePlayerMoney? and setAccountData data is saved in account.

  6. Try this:

    addEventHandler("onPlayerChat", getRootElement(), 
        function(msg, type) 
        if type == 0 then 
            cancelEvent() 
            local r, g, b = getPlayerNametagColor(source) 
            local msg = msg:gsub("#%x%x%x%x%x%x", "") 
            outputChatBox(string.gsub(getPlayerName(source),"#%x%x%x%x%x%x","")..": #FFFFFF"..msg, getRootElement(), r, g, b, true) 
            outputServerLog( "CHAT: " .. name .. ": " .. msg ) 
        end 
    end)) 
    

  7. Hello,

    I created bases and want to teleport to them by a simple command

    what can I do ?

    teleporting need to be per groups

    Thanks!!!

    addCommandHandler("go", function (source) 
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)),aclGetGroup("Group")) then 
    setElementPosition(x, y, z) 
    else 
    outputChatBox("text...", source, 255, 255, 255, true) 
    end) 
    

  8. You first have to get the account with getPlayerAccount. Then use getAccountName to get the account name from the account you got with getPlayerAccount.

    You can't use getAccountName with the player element because an account is required in that function.

    Where?

  9. Just use event parameter for get the account
    addEventHandler ("onPlayerLogin", getRootElement(), 
    function ( _, currentAccount ) 
        local account = getAccountName(currentAccount) 
        local searchForAPlayer = executeSQLQuery("SELECT TEST1, TEST2, TEST3 FROM Avengers WHERE Account = ?", account) 
        if #searchForAPlayer == 1 then 
            setElementData(source, "TEST1", searchForAPlayer["TEST1"]) 
            setElementData(source, "TEST2", searchForAPlayer["TEST2"]) 
            setElementData(source, "TEST3", searchForAPlayer["TEST3"]) 
        end 
    end) 
    

    i used this too but save or load not work :(

  10. Hello, i tried save and load with executeSQLQuery but idk why not work. :(

    Errors / Warnings:

    Warning: Bad argument @ 'getAccountName' [Expected account at argument 1, got player]

    Error: Database query failed: no such column: false

    addEventHandler("onPlayerQuit", getRootElement(), 
    function () 
        if isGuestAccount(getPlayerAccount(source)) then return end 
        local account = getAccountName(getPlayerAccount(source)) 
        local TEST1 = (getElementData(source, "TEST1") or 0) 
        local TEST2 = (getElementData(source, "TEST2") or 0) 
        local TEST3 = (getElementData(source, "TEST3") or 0) 
        local searchForAPlayer = executeSQLQuery("SELECT TEST1, TEST2, TEST3 FROM Avengers WHERE Account = ?", account) 
        if #searchForAPlayer == 0 then 
            executeSQLQuery("INSERT INTO Avengers (Account, TEST1, TEST2, TEST3) VALUES (?, ?, ?, ?)", account, TEST1, TEST2, TEST13) 
            else 
            executeSQLQuery("UPDATE Avengers SET TEST1 = ?, TEST2 = ?, TEST3 = ? WHERE Account = ?", TEST1, TEST2, TEST3, account) 
        end 
    end) 
      
    addEventHandler ("onPlayerLogin", getRootElement(), 
    function () 
        local account = getAccountName(source) 
        local searchForAPlayer = executeSQLQuery("SELECT TEST1, TEST2, TEST3 FROM Avengers WHERE Account = ?", account) 
        if #searchForAPlayer == 1 then 
            setElementData(source, "TEST1", searchForAPlayer["TEST1"]) 
            setElementData(source, "TEST2", searchForAPlayer["TEST2"]) 
            setElementData(source, "TEST3", searchForAPlayer["TEST3"]) 
        end 
    end) 
    

  11. function whenPlayerChangeNick(_, newNick) 
        local newNick = removeHexColorCode(newNick) 
        local serial = getPlayerSerial(source) 
        local q = dbQuery(database,"SELECT * FROM Nick WHERE Serial = ?", serial) 
        local result = dbPoll(q, -1) 
        if (result) then 
            local actualNicks = poll["Nicks"] 
            if string.find(actualNicks, newNick) then 
            else 
                local addNewNick = actualNicks .. ", " .. newNick 
                dbExec(database, "UPDATE Nick SET Nicks = ? WHERE Serial = ?", addNewNick, serial) 
            end 
        else 
            dbExec(database, "INSERT INTO Nick VALUES(?,?)", addNewNick, serial) 
        end 
    end 
    addEventHandler("onPlayerChangeNick", getRootElement(), whenPlayerChangeNick) 
    

    It's fixed.. and poll["Nicks"] ? where is poll?

  12. Hello, can anyone help me why i have this error? :(

    ERROR: attempt to index local 'q' (a userdata value)

    function whenPlayerChangeNick(_, newNick) 
        local newNick = removeHexColorCode(newNick) 
        local serial = getPlayerSerial(source) 
        local q = dbQuery(database,"SELECT * FROM Nick WHERE Serial = ?", serial) 
        local poll, rows = dbPoll(q, -1) 
        if (rows == 1) then 
            local actualNicks = q["Nicks"].nicks 
            if string.find(actualNicks, newNick) then 
            else 
                local addNewNick = actualNicks .. ", " .. newNick 
                dbExec(database, "UPDATE Nick SET Nicks = ? WHERE Serial = ?", addNewNick, serial) 
            end 
        end 
    end 
    addEventHandler("onPlayerChangeNick", getRootElement(), whenPlayerChangeNick) 
    

×
×
  • Create New...