Jump to content

JAY.ANN

Members
  • Posts

    70
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by JAY.ANN

  1. --FUNCTIONS BELOW GETTING ON CLIENT RENDER EVENT WHEN THE PLAYER ENTERS SPECIFIED MARKER function drawActionButton() local action_button = dxDrawImage( 1080 * sW, actionButtonHeight * sH, 64 * sW, 64 * sH, action_image, 0, 0, 0, tocolor( 255, 255, 255, actionButtonAlpha ) ) dxDrawText( actionButton[ 1 ], 1099 * sW, ( actionButtonHeight + 1 ) * sH, 20 * sW, 45 * sH, tocolor( 25, 25, 25, actionButtonAlpha ), 1, gilroyActionButton ) dxDrawText( actionButtonTitle, 1155 * sW, actionButtonHeight * sH, 20 * sW, 45 * sH, tocolor( 255, 255, 255, actionButtonAlpha ), 1, segoeBold20 ) dxDrawText( actionButtonDescription, 1155 * sW, ( actionButtonHeight + 25 ) * sH, 20 * sW, 45 * sH, tocolor( 255, 255, 255, actionButtonAlpha ), 1, segoeSemiLight16 ) end addEventHandler( "onClientKey", root, function( button, state ) if button == actionButton[ 1 ] then if state == true then action_image = "files/btn_unactive.png" else action_image = "files/btn_active.png" end end end) Solved, xd - that was my problem. I didn't figure out that actionButton[ 1 ] is "E" and not "e". That's why my code couldn't read it correctly. Thank you!
  2. I tried to do something like that but it didn't worked
  3. Hey, guys. I would like to get some help with a small issue - i need to change one dxDrawImage to another and I don't know how to realise it. I need to change my image From this: https://imgur.com/OtxXaRZ To this: https://imgur.com/YxegjYL I would be very grateful for any help!
  4. That's the information i was looking for. Thank you!
  5. This one works fine, thank you so much! Solved
  6. It doesn't work correctly. It outputs 26.67 sec at the Admiral but my stopwatch says that it's 6.35 sec. I guess it may be because of Drag Multiplier and Interia values
  7. I thought about this way, but it seems too complicated Thank you, I gonna test it and answer about the results!
  8. Is there a way to count vehicle acceleration from 0 to 100 km/h using vehicle handling data?
  9. Anyway, I've updated my code and it still have that wierd bug so the deal is not with getVehicleDataFromTable() addCommandHandler( "gveh", function( pl, cmd, login, vehID ) if pl and cmd and login and vehID then addPlayerVehicle( login, vehID, cost, { 255, 255, 255, 255, 255, 255 }, { 255, 255, 255 } ) end end) MARKER WAY { 1, "YeadSeven", 402, "[ [ 2514.5166015625, 2363.5485839844, 3.8178160190582, 0, 0, 90 ] ]", "255,255,255,255,255,255", 250000, 1000, "TRANZIT", '[ { "suspensionLowerLimit": -0.239999994635582, "engineInertia": 5, "suspensionHighSpeedDamping": 0, "collisionDamageMultiplier": 0.5, "suspensionDamping": 0.119999997317791, "seatOffsetDistance": 0.25, "headLight": "small", "dragCoeff": 2, "centerOfMass": [ 0, 0, -0.1000000014901161 ], "steeringLock": 30, "suspensionUpperLimit": 0.2800000011920929, "suspensionAntiDiveMultiplier": 0.4000000059604645, "turnMass": 4000, "brakeBias": 0.449999988079071, "tractionLoss": 0.8999999761581421, "monetary": 35000, "ABS": false, "suspensionFrontRearBias": 0.5, "percentSubmerged": 85, "tractionBias": 0.5, "numberOfGears": 5, "suspensionForceLevel": 1.200000047683716, "animGroup": 0, "engineAcceleration": 11.19999980926514, "maxVelocity": 200, "mass": 1500, "driveType": "rwd", "modelFlags": 10240, "brakeDeceleration": 11, "handlingFlags": 270532608, "tractionMultiplier": 0.699999988079071, "engineType": "petrol", "tailLight": "small" } ]', "[ [ 0, 0, 0, 0, 0, 0 ] ]", "[ [ 0, 0, 0, 0, 0, 0, 0 ] ]", "[ [ 0, 0, 0, 0 ] ]", "255,255,255" } COMMAND WAY: { 1, "YeadSeven", "402", "[ [ 2514.5166015625, 2363.5485839844, 3.8178160190582, 0, 0, 90 ] ]", "255,255,255,255,255,255", 250000, 1000, "TRANZIT", '[ { "suspensionLowerLimit": -0.239999994635582, "engineInertia": 5, "suspensionHighSpeedDamping": 0, "collisionDamageMultiplier": 0.5, "suspensionDamping": 0.119999997317791, "seatOffsetDistance": 0.25, "headLight": "small", "dragCoeff": 2, "centerOfMass": [ 0, 0, -0.1000000014901161 ], "steeringLock": 30, "suspensionUpperLimit": 0.2800000011920929, "suspensionAntiDiveMultiplier": 0.4000000059604645, "turnMass": 4000, "brakeBias": 0.449999988079071, "tractionLoss": 0.8999999761581421, "monetary": 35000, "ABS": false, "suspensionFrontRearBias": 0.5, "percentSubmerged": 85, "tractionBias": 0.5, "numberOfGears": 5, "suspensionForceLevel": 1.200000047683716, "animGroup": 0, "engineAcceleration": 11.19999980926514, "maxVelocity": 200, "mass": 1500, "driveType": "rwd", "modelFlags": 10240, "brakeDeceleration": 11, "handlingFlags": 270532608, "tractionMultiplier": 0.699999988079071, "engineType": "petrol", "tailLight": "small" } ]', "[ [ 0, 0, 0, 0, 0, 0 ] ]", "[ [ 0, 0, 0, 0, 0, 0, 0 ] ]", "[ [ 0, 0, 0, 0 ] ]", "255,255,255" } Solved - there were an vehicle ID as a string Thanks a lot for your attention and knowledge!
  10. Thank you for the advice! It returns 2 values from my table. nameveh is a string and cost is a number. serverVehicleTable = { [402] = { name = "Nissan 300ZX", cost = 250000 } } function getVehicleDataFromTable( id ) local id = tonumber(id) if id then local vehicleTable = serverVehicleTable[ id ] if vehicleTable then local nameveh = vehicleTable.name local cost = vehicleTable.cost return nameveh, cost else local nameveh = getVehicleNameFromModel( id ) local cost = 100000 return nameveh, cost end end end
  11. I have a function that gives a vehicle to player and saves it's data to the vehicle database. When I call this function from "onPlayerMarkerHit" - it works correctly but if i try to call it from "addCommandHandler" - it doesn't work. Somehow data isn't saving and I don't know why. Here's my video about this problem on youtube: buy_marker = createMarker( 1036.7772216797, -1133.2785644531, 22, "cylinder", 2 ) addEventHandler( "onPlayerMarkerHit", getRootElement(), function( marker ) if marker == buy_marker then local account = getPlayerAccount( source ) local account_name = getAccountName( account ) addPlayerVehicle( account_name, 402, 250000, {255, 255, 255, 255, 255, 255}, {255, 255, 255} ) end end) addCommandHandler( "gveh", function( pl, cmd, login, vehID ) if pl and cmd and login and vehID then if getAccount( login ) then local nameveh, cost = getVehicleDataFromTable( vehID ) addPlayerVehicle( login, vehID, cost, { 255, 255, 255, 255, 255, 255 }, { 255, 255, 255 } ) end end end) function addPlayerVehicle( login, vehID, cost, color, light ) local account = getAccount( login ) if account then local rnd = math.random( #boughtVehicleParking ) positionVeh = toJSON( { boughtVehicleParking[ rnd ][ 1 ], boughtVehicleParking[ rnd ][ 2 ], boughtVehicleParking[ rnd ][ 3 ], boughtVehicleParking[ rnd ][ 4 ], boughtVehicleParking[ rnd ][ 5 ], boughtVehicleParking[ rnd ][ 6 ] } ) local r1 = color[ 1 ] or 255 local g1 = color[ 2 ] or 255 local b1 = color[ 3 ] or 255 local r2 = color[ 4 ] or 255 local g2 = color[ 5 ] or 255 local b2 = color[ 6 ] or 255 local vehcolor = r1..","..g1..","..b1..","..r2..","..g2..","..b2 local rhl = light[ 1 ] or 255 local ghl = light[ 2 ] or 255 local bhl = light[ 3 ] or 255 local lights = rhl..","..ghl..","..bhl freeID = getFreeVehID() local nameveh, vehcost = getVehicleDataFromTable( vehID ) local handlings = toJSON( getServerVehicleHandling( vehID ) ) local door = {} for i = 1, 6 do door[ i ] = 0 end local panel = {} for i = 1, 7 do panel[ i ] = 0 end doors = toJSON( door ) panels = toJSON( panel ) wheels = toJSON( { 0, 0, 0, 0 } ) local accountPlayer = getAccountPlayer( account ) if accountPlayer ~= nil and accountPlayer ~= false and getElementType( accountPlayer ) == "player" then local xr, yr, zr = getElementRotation( accountPlayer ) local px, py, pz = getElementPosition( accountPlayer ) local prot = getPedRotation( accountPlayer ) local offsetRot = math.rad( prot + 90 ) local vx = px + 5 * math.cos( offsetRot ) local vy = py + 5 * math.sin( offsetRot ) local vz = pz + 5 local vrot = prot + 90 veh = createVehicle( vehID, 0, 0, 1000 ) setElementPosition( veh, vx, vy, pz + 0.5 ) positionVeh = toJSON( { vx, vy, pz + 0.5, 0, 0, vrot } ) setElementRotation( veh, xr, yr, vrot ) setVehicleColor( veh, r1, g1, b1, r2, g2, b2 ) setVehicleHeadLightColor( veh, rhl, ghl, bhl ) setVehiclePlateText( veh, "TRANZIT" ) setServerVehicleHandling( veh ) setElementData( veh, "Owner", accountPlayer ) setElementData( veh, "ID", freeID ) local frontLeft, rearLeft, frontRight, rearRight = getVehicleWheelStates( veh ) wheels = toJSON( { frontLeft, rearLeft, frontRight, rearRight } ) local door = {} for i = 1, 6 do door[ i ] = getVehicleDoorState( veh, i - 1 ) end local panel = {} for i = 1, 7 do panel[ i ] = getVehiclePanelState( veh, i - 1 ) end doors = toJSON( door ) panels = toJSON( panel ) end dbExec( dbVehicle, "INSERT INTO VehicleList VALUES( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )", freeID, login, vehID, positionVeh, vehcolor, cost, 1000, "TRANZIT", handlings, doors, panels, wheels, lights ) if accountPlayer ~= nil and getElementType( accountPlayer ) == "player" then updateVehicleInfo( accountPlayer ) end end end addEvent( "addPlayerVehicle", true ) addEventHandler( "addPlayerVehicle", root, addPlayerVehicle )
  12. ----SHARED SCRIPT---- customVehicleTable = { [558] = {name = "Mitsubishi Eclipse GS-T", cost = 25000}, } ----SERVER SIDE SCRIPT---- local nameveh, cost = customVehicleTable( 558 ) ----DEBUGSCRIPT---- server.lua:30: attempt to call global 'customVehicleTable' (a table value) Solved, thank you?
  13. It's pretty comfortable to use standard MTA accounts databases but does it have performance issues as setElementData or smth?
  14. What's better to use? setaccountdata and internal.db or to create own database and execute it?
  15. I cannot implement the above, I don't know why It works incorrect - the speed sets only while the vehicle at moving. I guess I did something wrong. local speedX, speedY = getElementSpeed( veh ) local speed = Vector2( speedX, speedY ).length setElementSpeed( veh, 1, tonumber( speed - 0.1 ) )
  16. JAY.ANN

    ERROR

    When you're trying to trigger that event? Isn't it "onResourceStop/Start"? It may cause errors like that
  17. Is there a way to calculate vehicle's speed along it's X or Y local axis? I would like to make a recoil system for transport. Thank you for your attention!
  18. I made a HUD for my server and now I have no idea how to make it work, because I've never had a deal with rendering. Link to the Image: https://imgur.com/a/bVdH1Id I need to fill the ellipses at the down of the screen with colors, but there's a trouble with their shapes. I would be very glad of any advice
  19. It's not the answer - player won't stand on the ground correctly
  20. Is it real to make player rotate with his camera as it realized in GTA VC and GTA III? I tried to use getCameraRotation() but it didn't give a good result - player had a right rotation, but his animations were broken and inverted. I guess it's all about the game engine's features. I noticed that while the player is on ground and uses camera rotation as rotZ coordinate he bugs himself.
  21. Hello everyone. I need some help with my script. Somehow when I use (for ... do) it reads a half of a table(?), lol. requestDeleteAdminVeh is a function that gets selected element of MTA gridlist what's the part of my admin panel. veh - selected gridlist element which has vehicle element as a data; deleteAll - boolean for deleting all admin vehicles; submitDeleteAdminVeh is a function that destroys the vehicle element, removes it from table and refreshes the gridlist with number plates. I have a trouble with the first function, I guess. When I delete all vehicles there is always lefts one. It's kinda strange, lmao, because as for me - the script is OK. local TableAdmVehicle = {} function requestDeleteAdminVeh( veh, deleteAll ) if deleteAll == true then for i, v in pairs( TableAdmVehicle ) do submitDeleteAdminVeh( v ) end else if isElement( veh ) then submitDeleteAdminVeh( veh ) end end end addEvent( "requestDeleteAdminVeh", true ) addEventHandler( "requestDeleteAdminVeh", getRootElement(), requestDeleteAdminVeh ) function submitDeleteAdminVeh( veh ) for i, v in ipairs( TableAdmVehicle ) do destroyElement( veh ) table.remove( TableAdmVehicle, i ) end for i, v in ipairs( TableAdmVehicle ) do updateAdminVehiclePlate( i, v ) end refreshAdmVehicleTabServer( ) end SOLVED - Used a timer to relieve the script
  22. This code is in the "server.lua". And it doesn't matter if I have OOP turned on - I've already tested that.
×
×
  • Create New...