-
Posts
1,058 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Saml1er
-
I don't think there is an official "mta script editor". Maybe this: ?
-
I have a script that I worked on with a friend. It was for a radar that looked like GTA V. The code is not in proper format. There are several errors as I took the code out of some heavy lua files. Now, it's your job to make it work for yourself. The logic and everything is 100% fine. You'll just need to fix some errors which you can easily find by executing the command: "/debugscript 3". You must be logged in as admin for that. You have everything you need to make a working radar now, go ahead and do it. Also, you can see that code looks difficult to understand. Take my advice, divide the code into functions. I'd personally rewrite it in OOP if I wanted to use it anyway functions will make it look much better than current. local sX, sY = guiGetScreenSize() local hudScale = sX/1280 local scaleX = sX/1920 -- Used in deathlist local scaleY = sY/1080 -- Used in deathlist local settings = { ['radar'] = { ['width'] = 270 * hudScale, ['height'] = 170 * hudScale, ['xoffset'] = 16 * hudScale, ['yoffset'] = 60 * hudScale, }, ['speed'] = { ['font'] = dxCreateFont('fonts/rothman.ttf', 100), --custom font ['size'] = 0.5 * hudScale, ['xoffset'] = 16 * hudScale, ['yoffset'] = 60 * hudScale, ['shadow'] = 2, }, ['notifications'] = { ['duration'] = 8000, -- In milliseconds ['maxnot'] = 8, }, ['display'] = { ['width'] = 10 * hudScale, ['height'] = 700 * hudScale, ['xpos'] = sX - (26 * hudScale), ['ypos'] = sY/2 - (700 * hudScale)/2, }, } local function getCameraRotation () px, py, pz, lx, ly, lz = getCameraMatrix() local rotz = 6.2831853071796 - math.atan2 ( ( lx - px ), ( ly - py ) ) % 6.2831853071796 local rotx = math.atan2 ( lz - pz, getDistanceBetweenPoints2D ( lx, ly, px, py ) ) rotx = math.deg(rotx) rotz = math.deg(rotz) return rotz end function findRotation(x1,y1,x2,y2) local t = -math.deg(math.atan2(x2-x1,y2-y1)) if t < 0 then t = t + 360 end; return t; end function getPointFromDistanceRotation(x, y, dist, angle) local a = math.rad(90 - angle); local dx = math.cos(a) * dist; local dy = math.sin(a) * dist; return x+dx, y+dy; end local radarEnabled = true local speedEnabled = true local displayEnabled = false local lp = localPlayer local heliRotation = 0 addEventHandler ("onClientRender", root, function () -- Blips local px, py, pz = getElementPosition(lp) local pr = getPedRotation(lp) local cx, cy, _, tx, ty = getCameraMatrix() local north = findRotation(cx, cy, tx, ty) if not pteam then return end for _,player in pairs( getPlayersInArena ( pteam ) ) do local state = getElementData(player,"state") if state == "waiting" or state == "alive" or state == "aboutToRun" then -- used in race gamemode, you can remove this check local veh = getPedOccupiedVehicle(player) if isElement(veh) and player~=lp then local ex, ey, ez = getElementPosition(veh) local dist = getDistanceBetweenPoints2D(px, py, ex, ey) if dist > range then dist = range end local angle = 180 - north + findRotation(px, py, ex, ey) --local cblipx, cblipy = getDistanceRotation(0, 0, settings.radar.height*(dist/range)/2, angle) local cblipx, cblipy = getDistanceRotation(0, 0, settings.radar.width*(dist/range)/1.5, angle) local blipx = centerleft + cblipx - blipsize/2 local blipy = centertop + cblipy - blipsize/2 -- v -- more to do here later if blipx < (settings.radar.xoffset - blipsize/2) then blipx = settings.radar.xoffset - blipsize/2 elseif blipx > (settings.radar.xoffset + settings.radar.width) - blipsize/2 then blipx = settings.radar.xoffset + settings.radar.width - blipsize/2 end local bHeight = 183 * hudScale local boffY = 40 * hudScale if blipy < (sY - boffY - bHeight) - blipsize/2 then blipy = sY - boffY - bHeight - blipsize/2 elseif blipy > (sY - boffY*2) - blipsize/2 then blipy = sY - boffY*2 - blipsize/2 end -- ^ -- more to do here later local r, g, b, a = 255, 255, 255, 255 local pTeam = getPlayerTeam(source) if pTeam then r, g, b = getTeamColor ( pTeam ) end -- you can use local r,g,b,a = getPlayerTeamColor(player) if you want local blipRot = 45 + (north-getPedRotation(player)) local img = 'images/radar/blip.png' if (getElementModel(veh) == 425) then img = 'images/radar/hunter.png' end if (img == 'images/radar/hunter.png') then if math.abs ( pz-ez ) >= 20 then if pz > ez then img = "images/radar/bldown.png" elseif pz < ez then img ="images/radar/blup.png" end end local hlsize = ( (30 * hudScale)/ 3 ) local cblipx, cblipy = getDistanceRotation(0, 0, settings.radar.width*(dist/range)/1.5, angle) local hlx = centerleft + cblipx - hlsize/2 local hly = centertop + cblipy - hlsize/2 -- v -- more to do here later if hlx < (settings.radar.xoffset - hlsize/2) then hlx = settings.radar.xoffset - hlsize/2 elseif hlx > (settings.radar.xoffset + settings.radar.width) - hlsize/2 then hlx = settings.radar.xoffset + settings.radar.width - hlsize/2 end local hY = 40 * hudScale if hly < (sY - hY - (185 * hudScale)) - hlsize/2 then hly = sY - hY - (185 * hudScale) - hlsize/2 elseif hly > (sY - hY*2) - hlsize/2 then hly = sY - hY*2 - hlsize/2 end dxDrawImage(hlx, hly, scx*12, scy*12, img, 0, 0, 0, tocolor(r,g,b,a)) else dxDrawImage(blipx, blipy, blipsize, blipsize, img, blipRot, 0, 0, tocolor(r,g,b,a)) end end end end if vehicle then dxDrawImage(centerleft - lpsize/2, centertop - lpsize/2, lpsize,lpsize, 'images/radar/local.png', north-pr) end end )
-
You have to wait for 1-2 minutes at least for the server to startup.
-
In order to create a radar, you must understand how to calculate sizes in pixels. You can only do that if you understand basics. Firstly, you need you learn the difference between absolute and relative sizes. Also, I do not understand what you mean by a "cool radar". There are many things you can do for a radar. You can create 3D, you can create 2D and on top of that there are circular radars, hexagon radars, triangle radars, rectangular radars etc.
-
Nice.That makes sense.
- 3 replies
-
- freezing
- glitching out
-
(and 1 more)
Tagged with:
-
Quoting Dark Byte, It takes at least 6-24 months for a judge to come up with a final decision about a lawsuit but just imagine the ass loads of money one has to pay lawyers while they are fighting for their rights. Sucks, doesn't it? Even if you did absolutely nothing wrong, you will never want to get sued because if you run out of money, you lose the case. Don't get me wrong, I would love to see a GTA V multiplayer owned by MTA and I would love to contribute but I can guarantee you that it is never going to happen.
-
What command? Can you please provide more explanation?
- 3 replies
-
- freezing
- glitching out
-
(and 1 more)
Tagged with:
-
Good question but sadly no. I'll be free next week so I guess, I'll have to fix it then.
- 28 replies
-
- 1
-
- mtasa
- legacy build
- (and 6 more)
-
function spawn (plr, r,g,b, id, vr,vg,vb,vx,vy,vz,vrot, occ, team, group) if (isElement(vehicles[plr])) then destroyElement(vehicles[plr]) vehicles[plr] = createVehicle(id, vx,vy,vz+2, 0,0,vrot) if (isElement(vehicles[plr])) then outputChatBox ( "1: Vehicle created successfully") else outputChatBox ( "1: Failed to create vehicle") end if warpPedIntoVehicle(plr, vehicles[plr]) == true then outputChatBox ( "1: Successfully wrapped ped into vehicle") else outputChatBox ( "1: warpPedIntoVehicle failed") end setVehicleColor(vehicles[plr], vr,vg,vb) triggerClientEvent(plr, "CHGvehicles:close", plr) else vehicles[plr] = createVehicle(id, vx,vy,vz+2, 0,0,vrot) if (isElement( vehicles[plr])) then outputChatBox ( "2: Vehicle created successfully") else outputChatBox ( "2: Failed to create vehicle") end if warpPedIntoVehicle(plr, vehicles[plr]) == true then outputChatBox ( "2: Successfully wrapped ped into vehicle") else outputChatBox ( "2: warpPedIntoVehicle failed") end setVehicleColor(vehicles[plr], vr,vg,vb) triggerClientEvent(plr, "CHGvehicles:close", plr) end end addEvent("CHGvehicles:spawn", true) addEventHandler("CHGvehicles:spawn", root, spawn) Use this and tell us the output. You just need to learn debugging. You can do it yourself if you check return values of functions in wiki.
-
Hey, that's awesome. Thanks!
-
Just stop downloading porn! Jokes aside, I'd love to see this feature. I actually want to maximize download speed no matter what's running in the background and it would be only possible if we have options to adjust it.
-
Right. A simple visual representation after the testFunction returns: local newCreatedFunction = function () -- or local function newCreatedFunction () -- testVariable, firstFunctionInBlock, secondFunctionInBlock still exist here for newCreatedFunction only! firstFunctionInBlock() secondFunctionInBlock () end
-
What about your GPU and CPU fans? Are they running when you're playing MTA? I had this issue with AC4 when the game would make me lagg as hell and I later found out that it was my GPU getting heated up.
-
Nice! That's actually really interesting. For some reason, I was hoping testVariable might go out of scope when testFunction returns but then saw the results you posted and it was kinda surprising to me that it was not garbage-collected and remained in memory stack otherwise firstFunctionInBlock and secondFunctionInBlock would have failed to increment it.
-
The variable "text" does not exist as global so in order to access it as a global variable you must define it globally. To make the variable available for access inside this lua file only then all you need to do is simply define it at top. Put this in line 2. local text = "" -- Global within lua file only which means you can now access it via any function within lua file which has this defined. If you want to make it accessible all client lua files then define it like this text = "" -- Global to all client lua files within resource. Now, it is fully global and available for all client files. For more information, refer to https://www.lua.org/pil/14.html
-
I believe the variable filename return a table so you have to do something like this: fetchRemote("http://localhost/shadersqsdqs/"..filename[1]["key"]..".jpg", checkPlayerAlternateSkin) Keep in mind that key is the column name so better change it.
-
Use fetchRemote server side and send data to client using triggerLatentClientEvent.
-
thepng variable is an empty string, make sure it has the file name.
-
if getPlayerTeam ( source ) and allowedTeams[getTeamName(getPlayerTeam(source))] and getElementHealth(car) < 999 then
-
The data variable in callback function can be sent to client side using triggerClientEvent and then save it using: local f = fileCreate (":myResourceName/fileName") fileWrite ( f, data) fileClose ( f ) f = nil
-
https://wiki.multitheftauto.com/wiki/FindRotation
-
What do you want to save in DB? tell me exactly what you're trying to achieve.
-
You can use UPDATE. Check w3school sql tutorial. Google it. You will find everything you need to know.
-
You need to use dbQuery first. Please check the second post: https://forum.multitheftauto.com/viewtopic.php?f=148&t=38203 My skype is: majid.sheikh95 Keep in mind, I'll only reply when I'm free.