-
Posts
70 -
Joined
-
Last visited
-
Days Won
1
Everything posted by JAY.ANN
-
Well, I used mED to get objects coordinates. It works with .IPL files Thank you, solved
-
Hi, I would like to get an original SA object's coordinates. Is it even possible? As I know, getElementsByType() and getElementPosition() is only for server-created elements.
-
That's a brilliant one! Exactly what I've been looking for! Thanks a lot This topic can be closed
-
Quite interesting but it doesn't fit
-
The ray will end at the weapon range maximum getPedTartgetEnd() "Returns three floats, x,y,z, representing the position where the ped's target ends according to his range, or false if it was unsuccessful". I need to continuous it or make it less I've tried all MTA functions and events that may help to me but nothing works correct. I guess it's all about the math or matrix I still think that the best solution is to use triangles similarity stuff
-
I already tried all the suggestions. Nothing works fine to me It still has no correct Z coordinate
-
That's what I used tho. That resource has a weapon range limitations and a collision one
-
I'm not going to create infinite ray from getPedTargetCollision() - that's the debug stuff in my script for now I'm going to use offset to create my ray, but the trouble is in Z coordinate
-
It will return false if there's no collision or if it's not loaded
-
ray = {} addEventHandler( "onClientPlayerWeaponFire", getRootElement(), function( _, tAmmo, cAmmo, hX, hY, hZ, hElement, sX, sY, sZ ) local rx, ry, rz = getElementRotation( source ) local muzzleX, muzzleY, muzzleZ = getPedWeaponMuzzlePosition( source ) local muzzle_eX, muzzle_eY, muzzle_eZ = getPedTargetEnd( source ) if not getPedTargetCollision( source ) then local offset = math.rad( rz + 90 ) local l_sX, l_sY, l_sZ = muzzleX, muzzleY, muzzleZ local l_eX, l_eY, l_eZ = ( muzzle_eX + 50 * math.cos( offset ) ), ( muzzle_eY + 50 * math.sin( offset ) ), muzzle_eZ table.insert( ray, { l_sX, l_sY, l_sZ, l_eX, l_eY, l_eZ } ) else local l_sX, l_sY, l_sZ = muzzleX, muzzleY, muzzleZ local l_eX, l_eY, l_eZ = getPedTargetCollision( source ) table.insert( ray, { l_sX, l_sY, l_sZ, l_eX, l_eY, l_eZ } ) end end) function drawRays() for i, v in ipairs( ray ) do dxDrawLine3D( v[ 1 ], v[ 2 ], v[ 3 ], v[ 4 ], v[ 5 ], v[ 6 ], tocolor( 255, 0, 0, 100 ), 2 ) end end addEventHandler( "onClientRender", root, drawRays ) That's the script. I want to draw a ray from weapon's muzzle XYZ to (XYZ + range) but if i use getPedTargetEnd() it has a weapon's range limitations and I can't change that correctly because of RenderWare engine and MTA limits
-
When I'll back from job, yes
-
I guess it won't work cuz there's no Z coordinate
-
It returns a face to face rotations, but I guess I can try this one The problem is a Z coordinate, not the XY or an angle I guess the solution is a similarity of triangles, but how can I implement that?
-
I don't need a ground position, the ray may end in the air What we've got: start XYZ, end X1Y1 found by random angle. We need to get Z1 from that angle, XY and X1Y1
-
Hello everybody. I need a help. I have a ray that casts from XY to X₁Y₁ with random angle. I need to get a Z₁ coordinate from X₁Y₁. How can I do it? Help me, please, I'll be very grateful for that!
-
But I prefer to use a bit modified version of that code: local modifiedHandling = { [412] = { --Engine ["numberOfGears"] = 5, ["maxVelocity"] = 320, ["engineAcceleration"] = 12, ["engineInertia"] = 240, ["driveType"] = "awd", ["steeringLock"] = 35, ["collisionDamageMultiplier"] = 0.4, --Body ["mass"] = 4000, ["turnMass"] = 5800, ["dragCoeff"] = 2, ["centerOfMass"] = { [1]=0, [2]=0, [3]=-0.3 }, ["percentSubmerged"] = 75, ["seatOffsetDistance"] = 0.25, --Wheels ["tractionMultiplier"] = 0.7, ["tractionLoss"] = 0.84, ["tractionBias"] = 0.42, ["brakeDeceleration"] = 6.2, ["brakeBias"] = 0.4, ["suspensionForceLevel"] = 1, ["suspensionDamping"] = 0.05, ["suspensionHighSpeedDamping"] = 0.5, ["suspensionUpperLimit"] = 0.4, ["suspensionLowerLimit"] = -0.3, ["suspensionAntiDiveMultiplier"] = 0.05, ["suspensionFrontRearBias"] = 0.5, --Vehicle Flags ["modelFlags"] = 0x220000, ["handlingFlags"] = 0x1000000, }, } function setServerVehicleModifiedHandling( vehicle ) if vehicle and modifiedHandling[ getElementModel( vehicle ) ] then -- Check if there is our vehicle and it has a modified handling for k, vl in pairs ( modifiedHandling[ getElementModel( vehicle ) ] ) do -- Create a loop through all our modified handlings if isElement( vehicle ) then -- Check if our vehicle exist setVehicleHandling( vehicle, k, vl ) -- Set vehicle handling end end end end function getServerVehicleModifiedHandling( modelID ) -- Function to get our new handling from modifiedHandling table local id = tonumber( modelID ) -- Set modelID tonumber to avoid some bugs if modelID then -- Check if there is a value of modelID local handlingTable = modifiedHandling[ modelID ] -- Set a local variable with our new handling of specific vehicle ID if handlingTable then -- Check if there is a variable return handlingTable -- Return modified handling from specific ID else return getOriginalHandling( modelID ) -- Return vehicle standart handling end end end local car = createVehicle( 412, 0, 0, 0 ) -- Create our test vehicle local car_handling = getServerVehicleModifiedHandling( getElementModel( car ) ) -- Get vehicle handling in cause of we need to send that handling to somewhere else setServerVehicleModifiedHandling( car ) -- Set vehicle modified handling
-
If you are talking about the spawning vehicle with already modified handling then there you go: https://wiki.multitheftauto.com/wiki/SetVehicleHandling (The last one server-side example, down of the page)
-
As I'd do that - I'd create a collision, then attach it to the object, and added addEventHandler( "onClientColshapeHit" ) into the code. https://wiki.multitheftauto.com/wiki/OnClientColShapeHit
-
Try out a "virtual machine" - an another computer system inside of your PC. Personally, I use VMware to test the stuff on my servers. You will need a med or semi-med PC to run it without critical lags and freezes.
-
Hello everybody! I'd like to introduce you my own-made systems based on internal.db for small gamemodes or simple servers. I was thinking about how good it'd be if we'd have an abillity to work with account's saved data better and faster only using standard MTA database. I've been looking for an information that could help me to put a lot of data (as player's position, skin, money and so on) in 1 key to internal.db account's data. As for me - this is the best way of using saveAccountData() for non-global servers because it reduces the amount of trash-files in database. I made some researches on that and found out that it doesn't affect the perfomance. Download: https://community.multitheftauto.com/index.php?p=resources&s=details&id=18786 Preview: ------------------------------- ----ACCOUNT ID SYSTEM UTILS---- ------------------------------- function getAccountDatabaseID( account ) if account and not isGuestAccount( account ) then accID = 0 -- Set account ID to default if getAccountData( account, "data" ) and getAccountData( account, "data" ) ~= nil then -- Check out for account's data table local data = fromJSON( getAccountData( account, "data" ) ) -- Get account's data table if data[ "ID" ] == nil then accID = 0 -- Set account ID to default in cause of ID == nil else accID = data[ "ID" ] -- Set account ID to account's data table ID end else accID = 0 -- Set account ID to default in cause of account's data table == nil end return accID -- Return account's ID end end function getFreeDatabaseID() local accounts = getAccounts() missedID = false -- Set an ID to default for operation for i, v in pairs( accounts ) do -- Start a loop for all server accounts if i ~= getAccountDatabaseID( v ) then missedID = i break end end if missedID ~= false then return missedID --[[ ETC: There were 5 accounts. The 3rd one have been deleted. To avoid dissolution of an ID after deleting account we look for the gap and fill it with new account. It means that new account, created afther the 5th, would get 3rd ID of deleted account. --]] else return #accounts + 1 -- There were no gaps in ID row, so we return ID as a count of all accounts + created one. end end ----------------------------------------- ----ACCOUNT ID SYSTEM UTILS ENDS HERE---- ----------------------------------------- -------------------------- ----ACCOUNT DATA TABLE---- -------------------------- function getAccountDataTable( account ) if account and not isGuestAccount( account ) then if getAccountData( account, "data" ) and getAccountData( account, "data" ) ~= nil then local data = fromJSON( getAccountData( account, "data" ) ) -- Get account data table local id = data[ "ID" ] -- Get account ID from data table local position = data[ "Position" ] -- Get account position from data table local skin = data[ "Skin" ] -- Get account skin from data table local money = data[ "Money" ] -- Get account money from data table return id, position, skin, money -- Return all collected data end end end function saveAccountDataTable( account, data ) if account and not isGuestAccount( account ) then setAccountData( account, "data", data ) end end addEvent( "saveAccountDataTable", true ) addEventHandler( "saveAccountDataTable", getRootElement(), saveAccountDataTable ) function getPlayerDataTable( player ) local x, y, z = getElementPosition( player ) -- Get player's position local rotx, roty, rotz = getElementRotation( player ) -- Get player's rotation local interior = getElementInterior( player ) -- Get player's current interior local dimension = getElementDimension( player ) -- Get player's current dimension local skin = getElementModel( player ) -- Get player's skin local money = getPlayerMoney( player ) -- Get player's money local accID = getElementData( player, "ID" ) or 0 -- Get player's account ID ---- local data = toJSON( { [ "ID" ] = accID, -- Prepare account ID to save [ "Position" ] = { x, y, z, rotz, interior, dimension }, -- Prepare player's position to save [ "Skin" ] = skin, -- Prepare skin to save [ "Money" ] = money, -- Prepare money to save } ) ---- return data -- Return all data that we've collected from the player end ------------------------------------ ----ACCOUNT DATA TABLE ENDS HERE---- ------------------------------------ ---------------------------------------- ----IMPLEMENT ALL STUFF THAT WE HAVE---- ---------------------------------------- addEventHandler( "onPlayerLogin", getRootElement(), function( _, account ) if account and not isGuestAccount( account ) then if getAccountData( account, "data" ) and getAccountData( account, "data" ) ~= nil then ---------------------------------------------------- ----Spawn player from saved account's data table---- ---------------------------------------------------- local ID, position, skin, money = getAccountDataTable( account ) spawnPlayer( source, position[ 1 ], position[ 2 ], position[ 3 ], position[ 4 ], skin, position[ 5 ], position[ 6 ] ) fadeCamera( source, true, 3 ) setCameraTarget( source, source ) setPlayerMoney( source, money, true ) setElementData( source, "ID", ID ) -- Apply player's ID outputChatBox( "Welcome back, "..getPlayerName( source ).."!", source, 255, 255, 255, true ) -- Output a welcome message outputChatBox( "Your ID: "..ID, source, 255, 255, 255, true ) -- Output a message to chat for logged player to make a sure that we've got the right ID else ------------------------------------------------------------------------------- ----Spawn player for the first time or in cause of data table reading error---- ------------------------------------------------------------------------------- local ID = getFreeDatabaseID() -- Get free ID for our player to apply it later spawnPlayer( source, 0, 0, 0, 0, 0, 0, 0 ) fadeCamera( source, true, 3 ) setCameraTarget( source, source ) setPlayerMoney( source, 0, true ) setElementData( source, "ID", ID ) -- Apply player's ID outputChatBox( "First time, "..getPlayerName( source ).."? Welcome!", source, 255, 255, 255, true ) -- Output a welcome message outputChatBox( "Your ID: "..ID, source, 255, 255, 255, true ) -- Output a message to chat for logged player to make a sure that we've got the right ID end end end) addEventHandler( "onPlayerLogout", getRootElement(), function( account, _ ) local data = getPlayerDataTable( source ) -- Get player's data to save it saveAccountDataTable( account, data ) -- Save player's data table on log out end) addEventHandler( "onPlayerQuit", getRootElement(), function() local account = getPlayerAccount( source ) local data = getPlayerDataTable( source ) -- Get player's data to save it saveAccountDataTable( account, data ) -- Save player's data table on exit end) P.S: I appreciate any opinion and advice, thank you!? You can use this script for any purpose - the code is opened! I've also tried to explain the whole script. I hope it'd help! Download: https://community.multitheftauto.com/index.php?p=resources&s=details&id=18786
-
Hello. I have some questions about "resetMapInfo". Does it reset all the maps that're running at the moment? Is it safe to execute it to unload one specific map that I've loaded via "loadMapFile"? I need two maps running at the same time, but one of them is a "global" one, and the other - is a specific "location" placed out of the SA map bounds. I'd be very grateful for any help!
-
The lights should to be turned on, it's not the way of fixing it. I need to disable object's light reflecting
-
Good night to ya all. I need to remove vehicle's lighting from the objects to prevent occurence of such bugs: https://imgur.com/a/ETmOUR4 Are there any shader stuff that could fix that?
-
If you can help to me with that - I'd be very grateful!
-
I'd like to create a system that gives a new player some money after their registration. But it needs to be attached to player's serial to avoid the money dump via creating new accounts and sending money from created account to the player's main account. Is that possible?