Jump to content

Deddalt

Members
  • Posts

    31
  • Joined

  • Last visited

Posts posted by Deddalt

  1. A few of things that I would love to see:

    • Creating a new lua inside a resource
      Saving new lua files into resources
      Possibly when you create a new file, if you want it to be in an existing resource, it would automatically add it to the meta.xml
      Right-clicking on functions to add them to the meta.xml with

    But as soon as I can create a new lua file in a resource & save it, I'll start using this as my main method of editing / creating scripts in MTA. You've done a great job :)

  2. I have a command to check how much money you have in your wallet (/wallet) and I want to have it do:

    local wallet =  getElementData( sourcePlayer, "wallet" ) 
    outputChatBox( " * You have $"..wallet.." in your wallet.", sourcePlayer, 200, 200, 200 ) 
    

    But it's giving me a weird string, something along the lines of

    * You have $1e+06 in your wallet.

    I have a feeling that this is due to the data being an integer, but if that's the case, how do I make that data into a readable string?

  3. I'm not planning on releasing the script to anyone, I just want to make this script work. It's unfortunate that the two things that I was hoping on using have to not work. setAccountData and SQL...

    Is there a MySQL plugin for MTA, then? I suppose I'll have to stop using SQLite and learn how to use MySQL instead...

    This is so annoying...

  4. Well I know that, but I need an example as to how to check if it's empty... like...

      
    local badtablevar = "{ 
      
        { firstname=' ', lastname=' ' }, 
        { username=' ', password=' ' }, 
      
    }" 
      
    if( check == badtablevar ) then 
            triggerClientEvent( source, "register", getRootElement(), firstname, lastname ) 
    else 
            triggerClientEvent( source, "login", getRootElement(), firstname, lastname ) 
    end 
      
    

    Or something like that, I don't know what to do, so could someone please tell me how to check for an empty cell?

  5. I take that back. Now I need to know how to check if it doesn't give me anything, because it apparently isn't returning false.

      
            local check = executeSQLQuery( "SELECT lastname, firstname FROM player WHERE lastname='"..lastname.."' AND firstname='"..firstname.."'" ) 
            if( check == false ) then 
                username[source].firstname = firstname 
                username[source].lastname = lastname 
                triggerClientEvent( source, "2register", getRootElement(), firstname.."_"..lastname ) 
            else 
                triggerClientEvent( source, "2login", getRootElement() ) 
                username[source].lastname = lastname 
                username[source].firstname = firstname 
            end 
    end 
    

    I need something to replace:

      
                   if( check == false ) then 
      
    

  6. resRoot = getResourceRootElement(getThisResource()) 
      
    function createSQLTable( ) 
            executeSQLCreateTable( "table", "username BLOB, password BLOB, lastname TEXT, firstname TEXT, wallet REAL, bank REAL, faction BLOB, admin INTEGER, phours INTEGER, skin INTEGER, pos_x INTEGER, pos_y INTEGER, pos_z INTEGER"..string1..", "..string2..", "..string3 ) 
    end 
      
    function Connect( ) 
            username = { } 
            username[source] = { } 
            fadeCamera( source, true ) 
            username[source].log = 0 
            setCameraPosition( source, -2642.8926, 1927.8561, 224.3582 ) 
            setCameraLookAt( source, 1481.1476, -1750.8605, 15.4453 ) 
            setCameraMode( source, "fixed" ) 
            local name = getClientName( source ) 
            local firstname = gettok( name, 1, string.byte( "_" ) ) 
            local lastname = gettok( name, 2, string.byte( "_" ) ) 
            local check = executeSQLQuery( "SELECT lastname, firstname FROM table WHERE lastname = '"..lastname.."'" ) 
            if( not check == false ) then 
                triggerClientEvent( source, "2login", getRootElement() ) 
                username[source].lastname = lastname 
                username[source].firstname = firstname 
            else 
                username[source].firstname = firstname 
                username[source].lastname = lastname 
                triggerClientEvent( source, "2register", getRootElement(), firstname.."_"..lastname ) 
            end 
    end 
      
    addEventHandler( "onResourceStart", resRoot, createSQLTable ) 
      
    

    It is returning the error:

    ERROR: Database query failed: near "table": syntax error (SELECT lastname, firstname FROM table WHERE lastname == 'Tokudaiji' ) 
    

  7. I want to make all of my vehicles in a .map, but I want to be able to handle them individually. Also, I want to have a /start and /stop command for turning vehicles on and off. What would be the shortest way to do this?

  8. Alright, now I've changed a LOT of things, mainly by changing the "AccountData" things to that player database that was released in the scripting forum.

    Now I get an error (mind you the fadeCamera error is probably still there) that won't let the script start anymore. Here is the script: http://pastebin.com/d23357fae

    The error is supposedly on line 352, it says:

    blargherrorsiz5.jpg

  9. I'm currently stumped with my script, I've written a lot for it, and it doesn't seem to have any errors. The only problem is: I tried to use fadeCamera(source, true) when they join the server, but when I join my test server, it doesn't fade the camera in.

    http://pastebin.com/f52b7dacf < There's the link to the script, if you could help, that would be great. This camera business is doing my head in.

  10. local chatRadius = 20 --units 
      
    function chat( message, messageType ) 
        if messageType == 0 then 
            local posX, posY, posZ = getElementPosition( source ) 
            local chatSphere = createColSphere( posX, posY, posZ, chatRadius ) 
            local nearbyPlayers = getElementsWithinColShape( chatSphere, "player" ) 
            destroyElement( chatSphere ) 
            for index, nearbyPlayer in ipairs( nearbyPlayers ) do 
                outputChatBox( message, nearbyPlayer ) 
            end 
        if messageType == 1 then 
            if message ~= "" and message ~= nil then 
                local posX, posY, posZ = getElementPosition(source) 
                local chatSphere = createColSphere(posX,posY,posZ, chatRadius) 
                local nearbyPlayers = getElementsWithinColShape(chatSphere, "player") 
                destroyElement(chatSphere) 
                for index, nearbyPlayer in ipairs(nearbyPlayers) do 
                    outputChatBox("*  "message, nearbyPlayer,255,0,255) 
                end 
            else 
                outputChatBox("USE: /me [action]",source,255,255,0) 
            end 
        end 
    end 
      
    addEventHandler('onPlayerChat', getRootElement(), chat) 
    

    I ended up with this when I was looking around on the wiki. However, thanks for the help!

  11. function slashMe(commandName, action) 
        for key, value in ipairs(players) do 
            if(action ~= "" and action ~= nil)then 
                local x,y,z = getElementPos(source) 
                local x2,y2,z2 = getElementPos(players) 
                if(x2 <= x + 5 and y2 <= y + 5 and z2 <= z + 5)then 
                    local name = getClientName(source) 
                    outputChatBox("*  "..name.." "..action,players,255,0,255) -- I HAVE A FEELING THIS WON'T WORK RIGHT 
                    outputChatBox("*  "..name.." "..action,source,255,0,255) 
                end 
            else 
                outputChatBox("USE: /me [action]",source,255,255,0) 
            end 
     end 
    

    EDIT: Alright, I've figured it out and fixed all of the problems. I used createColSphere(x,y,z,rad) instead.

  12. Thank god, I was going to cry if I had to rewrite the script. Also, is it possible for the player to modify their account info? I have some understanding that the account data is saved on THEIR computer, which could mean that they can edit it. If that's true, I need to find a way to write their account data to my server.

  13. Alright, I was going to ask this question in IRC, but I can't manage to find GTAnet. But anyway:

    Again, this is a PAWN example, but on SA-MP you can use a loop to get information from all the players in the server. Something like:

    for(new i=0;i) 
    

    So if you did:

    if(PlayerInfo[i][pStat] == value) 
        doesthisstuff 
    

    I'm trying to make a /me command, so it will check every player in the server:

    function slashMe(commandName, action) 
            for(new i=0;i) -- I NEED TO REPLACE THIS WITH AN LUA EQUIVALENT 
            local x,y,z = getElementPos(source) 
            local name = getClientName(source) 
            local x2,y2,z2 = getElementPos(i) 
            if(x2 <= x + 5 and y2 <= y + 5 and z2 <= z + 5)then 
                    outputChatBox("*  "name.." "..action,i,255,0,255) -- So it sends a message to anyone within a certain vicinity, for example "John_Appleseed makes cans." (in purple) 
                    outputChatBox("*  "name.." "..action,source,255,0,255) -- Sends the same message to the player who wrote it so they can be sure of what they wrote. 
            else 
                    outputChatBox("*  "name.." "..action,source,255,0,255) -- Sends the message only to the player. 
            end 
    end 
    

    So I really need to have an equivalent to the "player loop" from PAWN coding. Thanks for the help.

×
×
  • Create New...