Jump to content

TheNightRider

Members
  • Posts

    180
  • Joined

  • Last visited

Everything posted by TheNightRider

  1. I am trying to set the interiors dimension for my bank which was done by 50p however i cannot get it to work:( eg. its not setting the dimension to 3 Could anyone help me with this pls? Thanks
  2. Hey guys am running a VPS ive been using wine and Wines Tricks to run my Servers, I found the following link:-https://wiki.multitheftauto.com/wiki/Building_MTASA_Server_on_GNU_Linux to install a Linux version of MTA but am not able to get it to start and idk where my resources would go Anyone got any idea's?
  3. C++ is like Lua? It's -nothing- like Lua. More alike PHP.
  4. If your referring to me I would tell you but simply ive got no clue myself ive looked up about the #idtable in the mta wikki but couldn't find anything, sorry couldn't help. What I meant like C++ was how your doing your code I know the difference between script coding and program coding.
  5. Try to explain more what your code is meant to do like break it down exactly what should be expected from it during each part or something. The way you wrote it almost looks like you've done C++ or something
  6. I would say Castillo's script looks a lot more professional. and am not sure on your script.
  7. Okay cool and I looked at the code you wrote the debugger said bad argument at line 77 expected string got table the other problem I found it isn't creating any tables etc. in the db file. addEventHandler( "onResourceStart", resourceRoot, function( ) local key = dbConnect( "sqlite", "Storedinfo.db" ) dbExec( key, "CREATE TABLE IF NOT EXISTS teleports ( teleportID INT, aX FLOAT, aY FLOAT,aZ FLOAT, aInterior INT, aDimension INT, bX FLOAT, bY FLOAT, bZ FLOAT,bInterior INT, bDimension INT )" ) local result = dbPoll ( dbQuery( key, "SELECT * FROM teleports" ),-1 ) end )
  8. I have made it has serverside but am stuck on writing the function which will use the table and show content in a gridlist
  9. OKay mate and thanks again.
  10. ok Of course am using debugscript 3
  11. Okay no worries local addCommandHandler_ = addCommandHandler addCommandHandler = function( commandName, fn, restricted, caseSensitive ) -- add the default command handlers if type( commandName ) ~= "table" then commandName = { commandName } end for key, value in ipairs( commandName ) do if key == 1 then addCommandHandler_( value, fn, restricted, caseSensitive ) else addCommandHandler_( value, function( player, ... ) -- check if he has permissions to execute the command, default is not restricted (aka if the command is restricted - will default to no permission; otherwise okay) if hasObjectPermissionTo( player, "command." .. commandName[ 1 ], not restricted ) then fn( player, ... ) end end ) end end -- check for alternative handlers, such as createinterior = createint for k, v in ipairs( commandName ) do if v:find( "teleport" ) then for key, value in pairs( { "tp" } ) do local newCommand = v:gsub( "teleport", value ) if newCommand ~= v then -- add a second (replaced) command handler addCommandHandler_( newCommand, function( player, ... ) -- check if he has permissions to execute the command, default is not restricted (aka if the command is restricted - will default to no permission; otherwise okay) if hasObjectPermissionTo( player, "command." .. commandName[ 1 ], not restricted ) then fn( player, ... ) end end ) end end end end end -- local colspheres = { } local teleports = { } local function loadTeleport( id, aX, aY, aZ, aInterior, aDimension, bX, bY, bZ, bInterior, bDimension ) local a = createColSphere( aX, aY, aZ, 1 ) setElementInterior( a, aInterior ) setElementDimension( a, aDimension ) local b = createColSphere( bX, bY, bZ, 1 ) setElementInterior( b, bInterior ) setElementDimension( b, bDimension ) -- save for further reference colspheres[ a ] = { id = id, other = b } colspheres[ b ] = { id = id, other = a } teleports[ id ] = { a = a, b = b } end local key = dbConnect( "sqlite", "Storedinfo.db" ) addEventHandler( "onResourceStart", resourceRoot, function( ) local key = dbConnect( "sqlite", "Storedinfo.db" ) dbFree ( dbQuery ( key, "CREATE TABLE IF NOT EXISTS teleports ( teleportID INT, aX FLOAT, aY FLOAT,aZ FLOAT, aInterior INT, aDimension INT, bX FLOAT, bY FLOAT, bZ FLOAT,bInterior INT, bDimension INT )" ) ) local returnedData = dbPoll ( dbQuery ( key , "SELECT * FROM table" ), -1 )-- this 1 has syntax error local result = dbPoll ( dbQuery( key, "SELECT * FROM teleports" ),-1 ) end ) --for key, value in ipairs( result ) do -- dbQuery( value,"(teleportID, value.aX, value.aY, value.aZ, value.aInterior, value.aDimension, value.bX, value.bY, value.bZ, value.bInterior, value.bDimension)" ) local p = { } addEventHandler( "onPlayerQuit", root, function( ) p[ source ] = nil end ) addCommandHandler( "marktele", function( player ) -- this command only makes sense if used with /createteleport if hasObjectPermissionTo( player, "command.createteleport", false ) then -- get all properties we need local x, y, z = getElementPosition( player ) x = math.ceil( x * 100 ) / 100 y = math.ceil( y * 100 ) / 100 z = math.ceil( z * 100 ) / 100 local interior = getElementInterior( player ) local dimension = getElementDimension( player ) -- save them if not p[ player ] then p[ player ] = { } end p[ player ].mark = { x = x, y = y, z = z, interior = interior, dimension = dimension } -- outputChatBox( "Marked teleport position. [" .. table.concat( { "x=" .. x, "y=" .. y, "z=" .. z, "i=" .. interior, "d=" .. dimension }, ", " ) .. "]", player, 0, 255, 153 ) end end ) addCommandHandler( "createtele", function( player, commandName ) local a = p[ player ] and p[ player ].mark if a then local x, y, z = getElementPosition( player ) x = math.ceil( x * 100 ) / 100 y = math.ceil( y * 100 ) / 100 z = math.ceil( z * 100 ) / 100 local interior = getElementInterior( player ) local dimension = getElementDimension( player ) local insertid, e = dbQuery( "INSERT INTO teleports (`aX`, `aY`, `aZ`, `aInterior`, `aDimension`, `bX`, `bY`, `bZ`, `bInterior`, `bDimension`) VALUES (" .. table.concat( { a.x, a.y, a.z, a.interior, a.dimension, x, y, z, interior, dimension }, ", " ) .. ")" ) if insertid then loadTeleport( insertid, a.x, a.y, a.z, a.interior, a.dimension, x, y, z, interior, dimension) outputChatBox( "Teleport created. (ID " .. insertid .. ")", player, 0, 255, 0 ) -- delete the marked position p[ player ].mark = nil else outputChatBox( "SQL-Query failed.", player, 255, 0, 0 ) end else outputChatBox( "You need to set the opposite spot with /markteleport first.", player, 255, 0, 0 ) end end, true ) addCommandHandler( { "deleteteleport", "delteleport" }, function( player, commandName, teleportID ) teleportID = tonumber( teleportID ) if teleportID then local teleport = teleports[ teleportID ] if teleport then if dbQuery ("DELETE FROM teleports WHERE teleportID = " .. teleportID ) then outputChatBox( "You deleted teleport " .. teleportID .. ".", player, 0, 255, 153 ) -- delete the markers colspheres[ teleport.a ] = nil destroyElement( teleport.a ) colspheres[ teleport.b ] = nil destroyElement( teleport.b ) else outputChatBox( "DB-Query failed.", player, 255, 0, 0 ) end else outputChatBox( "Teleport not found.", player, 255, 0, 0 ) end else outputChatBox( "Syntax: /" .. commandName .. " [id]", player, 255, 255, 255 ) end end, true ) addCommandHandler( "nearbyteleports", function( player, commandName ) if hasObjectPermissionTo( player, "command.createteleport", false ) or hasObjectPermissionTo( player, "command.deleteteleport", false ) then local x, y, z = getElementPosition( player ) local dimension = getElementDimension( player ) local interior = getElementInterior( player ) outputChatBox( "Nearby Teleports:", player, 255, 255, 0 ) for key, value in pairs( colspheres ) do if getElementDimension( key ) == dimension and getElementInterior( key ) == interior then local distance = getDistanceBetweenPoints3D( x, y, z, getElementPosition( key ) ) if distance < 20 then outputChatBox( " Teleport " .. value.id .. ".", player, 255, 255, 0 ) end end end end end ) -- local function useTeleport( player, key, state, colShape ) local data = colspheres[ colShape ] if data then local other = data.other if other then triggerEvent( "onColShapeLeave", colShape, player, true ) -- teleport the player setElementDimension( player, getElementDimension( other ) ) setElementInterior( player, getElementInterior( other ) ) setCameraInterior( player, getElementInterior( other ) ) setElementPosition( player, getElementPosition( other ) ) setCameraTarget( player, player ) triggerEvent( "onColShapeHit", other, player, true ) end end end addEventHandler( "onColShapeHit", resourceRoot, function( element, matching ) if matching and getElementType( element ) == "player" then if not p[ element ] then p[ element ] = { } elseif p[ element ].tp then unbindKey( element, "enter_exit", "down", useTeleport, p[ element ].tp ) end p[ element ].tp = source bindKey( element, "enter_exit", "down", useTeleport, p[ element ].tp ) setElementData( element, "interiorMarker", true, false ) end end ) addEventHandler( "onColShapeLeave", resourceRoot, function( element, matching ) if getElementType( element ) == "player" and p[ element ].tp then unbindKey( element, "enter_exit", "down", useTeleport, p[ element ].tp ) removeElementData( element, "interiorMarker", true, false ) p[ element ].tp = nil end end )
  12. I know it is but that's bit off topic
  13. I used too but thought it was best to use db etc. instead Edit:- Last 1 he posted, debugger cry's like a baby at it lol
  14. The code you posted is full of syntax errors
  15. Thanks man it passes debugger hope its gonna work PS no you don't have to specify fields for it do something.
  16. Ok should it be like this mate? function( ) local key = dbConnect( "sqlite", "Storedinfo.db" ) dbFree ( dbQuery ( key, "CREATE TABLE IF NOT EXISTS teleports ( teleportID, aX, aY, aZ, aInterior, aDimension, bX, bY, bZ,bInterior, bDimension )")) local returnedData = dbPoll ( queryHandler , -1 ) local queryHandler = dbQuery ( key , "SELECT * FROM table") local result = dbPoll(dbQuery(key, "SELECT * FROM teleports" ),-1)
  17. Okay budy but could you show me how i should do the dbPoll pls?
  18. Sorry guys am still noob in many area's of LUA lol I am learning it but its taking time and a lot of practice lol
  19. I have been re doing a Spawn GUI since its existing system is not very good so a friend of mine advised me to base it on XML Have added the information required for spawning etc. into an XML file however I cannot see what ive gone wrong as the debugger saying xmlNodeGetChildren is a bad argument. function AddLoc() function datainfo () local xml = xmlLoadFile("Data.xml"); local xmlNodes = xmlNodeGetChildren(xml); for i,node in ipairs(xmlNodes) do Locs[tonumber(xmlNodeGetAttribute(node,'location'))] = tonumber(xmlNodeGetAttribute(node,'id')); Locs = guiGridListAddRow(Location) end xmlUnloadFile(xml); end end
  20. Thank you another problem sorted I think its time for bed for me lol
  21. For some reason am getting table exspected got userdata I have no clue where ive gone wrong on this 1 lol addEventHandler( "onResourceStart", resourceRoot, function( ) local key = dbConnect( "sqlite", "Storedinfo.db" ) dbFree ( dbQuery ( key, "CREATE TABLE IF NOT EXISTS vehicles ( teleportID, aX, aY, aZ, aInterior, aDimension, bX, bY, bZ,bInterior, bDimension )")) local result = dbQuery(key, "SELECT * FROM teleports" ) for key, value in ipairs( result ) do dbQuery( value,"(teleportID, value.aX, value.aY, value.aZ, value.aInterior, value.aDimension, value.bX, value.bY, value.bZ, value.bInterior, value.bDimension)" ) end end )
  22. That did the trick thanks again budy
  23. checked script over and ive noticed its not creating the table to start with, so the next part of the scripts returns with no table Edit: for got to state yes it is defined local fuelRoot = createElement( "fuelpoint" ) If fuelRoot wasn't defined or set as an int as they say in VB C++ whatever it would return false but that is not the case here.
  24. Hello guys am working on a database script the trouble am having is a silly syntax error which I cannot seem to find the issue. The debugger tells me , is expected before DO but when I add it it says unexpected symbol near DO lol. Any idea's? PS don't say look at wikki cos I do that as a prime objective when am stuck but its not always giving me what am looking for to a certain extent. addEventHandler( "onResourceStart", resourceRoot, function( ) local server = dbConnect( "sqlite", "Storedinfo.db" ) local qh = dbQuery(server, "SELECT * FROM fuelpoints") if not dbFree ( dbQuery ( server,"CREATE TABLE IF NOT EXISTS vehicles ( fuelpointID, posX, posY, posZ, name)")) --then fuelpointID = type = ('int(10) unsigned', auto_increment = true, primary_key = true) then cancelEvent( ) return end -- local result = dbConnect( "sqlite", "Storedinfo.db" ) if result then for qh = (dbQuery (server, "SELECT * FROM fuelpoints")), do data in ipairs( result ) do local colshape = createColSphere( data.posX, data.posY, data.posZ, 2 ) setElementParent( colshape, fuelRoot ) setElementData( colshape, "name", tonumber( data.name ) or data.name ) end end end end )
  25. Thank you for your advise and I do use Wikki etc. and i did have the code working before you posted the code you modified. I have it working 100% as expected and again thank you for your input. PS you cannot expect someone to learn by just doing the Wikki thing getting input from other fellow human beings goes much further i.e. discussions brings more light to the subject
×
×
  • Create New...