Jump to content

Lloyd Logan

Members
  • Posts

    642
  • Joined

  • Last visited

Posts posted by Lloyd Logan

  1. Why doesn't this set the matrix of the camera? (CLIENT)

    function cmatrix() 
        setCameraMatrix(2056.1774902344,1181.1239013672,56.897701263428,2057.064453125,1180.6881103516,56.744400024414,0,70) 
    end 
    addEventHandler("onClientPlayerJoin", cmatrix) 
    

  2. What do you mean by "save the serial as nil"? the setMoney function is meant to load the money, so how can it "save the serial"?

    Sorry there was some blatant mistakes in that code!

    I'm now able to save the money when the player quits, and load it when they join, so now I am stuck on how to update it if their info is already in the table!

    function submitReg() 
        firstserial = getPlayerSerial(source) 
        moneys = getPlayerMoney(source) 
        local data = dbPoll(dbQuery(server, "SELECT money FROM accounts WHERE serial = ?", firstserial), -1) 
        if data and type (data) == "table" and #data > 0 then 
        dbExec( server, "UPDATE accounts SET money=`"..moneys.."` WHERE serial = '"..firstserial.."'"   ) 
        else 
        dbQuery ( server, "INSERT INTO accounts (serial, money) VALUES (?, ?)", tostring (firstserial), tostring (moneys) ) 
        end 
    end 
    addEventHandler( "onPlayerQuit", root, submitReg ) 
    

  3. server = dbConnect ( "mysql", "dbname=servermta;host=127.0.0.1","root")

    dbExec(server, "CREATE TABLE IF NOT EXISTS accounts (serial TEXT NOT NULL, money INT NOT NULL)")

      
    function submitReg() 
        firstserial = getPlayerSerial(source) 
        moneys = getPlayerMoney(source) 
        local data = dbPoll(dbQuery(server, "SELECT money FROM accounts WHERE serial = ?", firstserial), -1) 
        if data and type (data) == "table" and #data > 0 then 
        dbExec( server, "UPDATE `accounts` SET `money`=`"..moneys.."`"  ) 
        else 
        dbQuery ( server, "INSERT INTO accounts (serial, money) VALUES (?, ?)", tostring (theserial), tostring (themoney) ) 
        end 
    end 
    addEventHandler( "onPlayerQuit", root, submitReg ) 
         
         
    exports.scoreboard:addScoreboardColumn("Money") 
      
    function setMoney() 
        local Serial = getPlayerSerial(source) 
        local data = dbPoll(dbQuery(server, "SELECT money FROM accounts WHERE serial = ?", Serial), -1) 
        if data and type(data) == "table" then 
            setPlayerMoney(source, data[1]["money"]) 
            setElementData(source, "Money", data[1]["money"]) 
        else 
        outputChatBox("You have not previously logged in!", getRootElement(), 255, 0, 0) 
        end 
     end 
    addEventHandler("onPlayerJoin", root, setMoney)Why does this save the serial as nil and money as 0? 
      
    

  4. No, When you select the row there might be more than one row so we select the first row in the table which [1].

    Oh Thanks, but what happens now is, everytime the player joins, a new row is created instead of checking for previous log ins and updating them! So far is this

    checkforserial = dbQuery (server, "ALTER TABLE accounts, ADD CHECK ('"..theserial.."'>0)") 
        if (checkforserial == false) then 
        dbQuery ( server, "INSERT INTO accounts (serial, money) VALUES (?, ?)", tostring (theserial), tostring (themoney) ) 
        else 
      
    

  5. That's my code

        function setMoney() 
        serial = getPlayerSerial(source) 
         local data = dbPoll(dbQuery(server, "SELECT 'money' FROM 'accounts' WHERE serial = '"..serial.."' "), -1) 
            setPlayerMoney(player, data[1]["money"]) 
            if data then 
         local curmoney = getPlayerMoney(source) 
         exports.scoreboard:addScoreboardColumn("Money") 
         setElementData(thePlayer,"Money",curmoney,true) 
        end 
     end 
    addEventHandler("onPlayerJoin", root, setMoney) 
         
    

    It gives the error; attempt to index local 'data' "a boolean value"

  6. You can use WHERE clause to select specific row.

    http://www.w3schools.com/sql/sql_where.asp

    So how would i setPlayerMoney when retrieving this information?

    local playermoney = dbQuery ( server, "SELECT 'money' FROM 'accounts' WHERE serial = '"..serial.."' " ) 
    

    local query = dbQuery ( handler, "SQL STRING HERE" ) 
    local data = dbPoll  ( query, - 1 ) -- -1 = wait for the result, freezes server until it has the result. 
    if ( type ( data ) == "table" ) then 
        print ( data [ 1 ].myColumnName ) 
    end 
    

    I honestly don't understand at all, surely once I retrieved the info from the money index

    local playermoney = dbQuery ( server, "SELECT 'money' FROM 'accounts' WHERE serial = '"..serial.."' " ) 
    

    I can simply apply it to setPlayerMoney

  7. I don't understand, can you post your code?

    I'll try again, if not i'll post my code

    I have multiple rows in mySQL such as money position etc

    But how do I select money from a specific say, account name or serial?

  8. I don't understand, can you post your code?

    I'll try again, if not i'll post my code

    I have multiple rows in mySQL such as money position etc

    But how do I select money from a specific say, account name or serial?

  9. If you are using it without a loop, then you need to include the [ 1 ] before the column name from which you wish to obtain it's value, this "1" represents the index.

    I'm totally stuck, i'm only trying to get some values from mySQL, maybe i'm going about it wrong? I stored it in mySQL, now i'm trying to take a certain value (money ) out.

  10. local query = dbQuery ( handler, "SQL STRING HERE" ) 
    local data = dbPoll  ( query, - 1 ) -- -1 = wait for the result, freezes server until it has the result. 
    if ( type ( data ) == "table" ) then 
        print ( data [ 1 ].myColumnName ) 
    end 
    

    So how would I use this in terms of

    setPlayerMoney(something.somthing?)

    Thanks also!

  11. I was looking at someones script and saw this;

    local result = mysql_query ( database ,"SELECT * FROM `accounts` WHERE `serial` = '"..serial.."'") 
        if result then 
            while true do 
                local row = mysql_fetch_assoc(result) 
                if not row then break end 
                setElementPosition ( source, row.x, row.y, row.z) 
    

    So in order for him to use row.blah blah, he used mysql_query then local row = mysql_fetch_assoc

    My problem is, i'm using dbQuery, so how would i create one equal to

      
    local row = mysql_fetch_assoc(result) 
                if not row then break end 
                setElementPosition ( source, row.x, row.y, row.z) 
    

    except for dbQuery

    Thanks!

  12. Why is this creating an account row and password row, but its putting in blank values e.g. accounts || Password

    both just equal blank!

    CLIENT

    function checkRegField() 
        local inputusernamereg = guiGetText(GUIEditor.edituserreg) 
        local inputpasswordreg = guiGetText(GUIEditor.editpassreg) 
           triggerServerEvent("submitRegister", localPlayer, inputusernamereg, inputpasswordreg) 
    end 
    

    SERVER

    function submitReg() 
        dbExec(server, "CREATE TABLE IF NOT EXISTS accounts (accountname TEXT NOT NULL, password TEXT NOT NULL)") 
        new = dbExec(server, "INSERT INTO accounts (accountname, password) VALUES (?,?)", inputusernamereg, inputpasswordreg) 
        output = outputChatBox("You have successfully created an account!") 
        triggerClientEvent("closedok", getRootElement()) 
        triggerClientEvent("onclose", getRootElement()) 
    end 
    

  13. Try this;

    function spawnOnDeath () 
        setTimer ( function() 
        spawnPlayer (source, 0, 0, 5) 
        fadeCamera (source, true) 
        setCameraTarget (source, source) 
        end, 5000, 1 ) 
         
    end 
    addEventHandler("onPlayerWasted", getRootElement(), spawnOnDeath) 
    

    Though remember, 'play' is the default game mode, so you may have to disable it in order for this to work!

  14. I've downloaded a GateMaker or something like that, and I've gotten to know it and stuff, now I've experienced two bugs that ruin that resource, and I beg all of you to help me.

    Now here's the drill; When I add the gate for "GroveRefuge" it doesn't even add gate, even when I reload the resource/restart server. When I don't add for team, the gate itself, opens, but does not close.

    I beg all of you help me, please!

    Any errors from console/chat?

  15. I don't mean command.

    I mean when i click ex. "B" button on the keyboard, flashlight will be turn on/off.

    In this script first i must type /flashlight command to enable.

    You type in the chat box

    /bind b flashlight

    After this, when you click "b" the flashlight will turn on and off

  16. Hey all, today I got a problem.

    I was mapping in my local server, when I got crashed (IDK why) but the problem is, when I open my map how with race mode, all the things work fine, but when I open with editor, Many of that things are missing.

    I reinstalled the server and still ocurring the same problem.

    Things I tried.

    - Change the name of folder and .map (Editing the meta.xml too)

    - Send to my friend the map (persist the problem)

    I need help please, I need help please.

    My Skype: dani-bolivia.

    Regards.

    Any Errors?

×
×
  • Create New...