Jump to content

Mkl

Members
  • Posts

    51
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by Mkl

  1. Mkl

    DGS

    Could be possible with properties, not sure. https://wiki.multitheftauto.com/wiki/Dgs-dxedit https://wiki.multitheftauto.com/wiki/Dgs-dxbutton
  2. Hi, Here is a fast test I did to create shade and stack effects, I don't really know if it's a proper way but it works : -- Some parametrable values local max_lines = 5 -- max lines (max stack) local timeToFade = 500 -- time to appear and disappear fade-effect (in ms) local timeToShow = 2000 -- time to plainly show the text local gap = 20 -- vertical gap between texts -- A variable to store texts local texts = {} function addText() -- in case we are in the column bottom, we don't reset the table until everything ended his display, -- including if we keep repeating the last one local is_last = true for _, v in ipairs(texts) do if not v.ended then is_last = false break end end -- nothing still displayed, we reset the table if is_last then texts = {} end -- if it's the last line, we stop the previous text if #texts == max_lines then removeEventHandler("onClientRender", root, texts[#texts].displayText) table.remove(texts, #texts) end -- New entry in the table, and local variable for short syntax texts[#texts + 1] = {} local text = texts[#texts] text.alpha = 0 -- alpha set to 0 text.firstCount = getTickCount() -- time reference text.state = 1 -- state use to situate the effect (1/2/3) (appearing/showing/vanishing) text.pos = #texts -- store his position -- function for onClientRenderEvent function text.displayText() if (text.state == 1) then -- showing fade effect text.count = getTickCount() - text.firstCount -- ratio between time and alpha value text.alpha = (text.count * 255) / timeToFade elseif (text.state == 2) then -- opac state text.alpha = 255 elseif (text.state == 3) then -- vanish fade effect text.count = timeToFade - (getTickCount() - text.firstCount) -- ratio between time and alpha value text.alpha = (text.count * 255) / timeToFade end text.y = 500 + (text.pos * gap) text.color = tocolor(255, 255, 255, text.alpha) dxDrawText("This is a test", 500, text.y, _, _, text.color) end addEventHandler("onClientRender", root, text.displayText) setTimer(function() -- first timer to opac state text.alpha = 255 text.state = 2 end, timeToFade, 1) setTimer(function() -- second timer to vanish fade effect text.state = 3 text.firstCount = getTickCount() end, timeToFade + timeToShow, 1) setTimer(function() -- last timer to the end removeEventHandler("onClientRender", root, text.displayText) text.ended = true -- bool to know this text finished to be displayed end, (timeToFade * 2) + timeToShow, 1) end addCommandHandler("somecmd", addText)
  3. Hi, I imagine you can begin that way : 1 - create a command associated to your function that'll do the job : -> addCommandHandler("foodtruck", theFunction) 2 - Inside your function, check if the player is in a vehicle -> getPedOccupiedVehicle ( thePlayer ) return vehicle element or isPlayerInVehicle(thePlayer) 3 - If the vehicle exist, check if the player has the driver seat -> getPedOccupiedVehicleSeat( thePlayer ) return int 0 for driver 4 - Then, take vehice's position-> getElementPosition(theVehicle) return 3 int x, y, z 5 - Finally, create a marker aside the vehicle by using vehicle's position -> like createMarker(x+5, y+5, z)
  4. Hi, could you use code blocks because it is unreadable. Like a tag in the nickname ? [TAG]Nickname ? You can check if the name of the player contains the tag by using string.find and then create markers.
  5. Would not be easier to use a Marker / onMarkerHit or a Colspahe / onColShapeHit ?
  6. Hi, I'm not sure to understand. Do you want, when a player starts a "lobby", a timeleft which stops the game when it reaches 0? If yes, why don't you use setTimer ? To display the time, I would have use getTickCount() instead of using getElementData everyframe. Check the second example of https://wiki.multitheftauto.com/wiki/GetTickCount that counts time, same logic can be used to create a timeleft to diplay.
  7. Should be function tpPlayerZ() Without source. You are overwriting the predefined source variable of the event with totalAmmo, first paramater of onPlayerWasted.
  8. I found out you can do something like this : addEventHandler("onClientPlayerDamage", root, function(attacker, damage) local health = getElementHealth(localPlayer) if (health - damage) < 1 then cancelEvent() setElementHealth(localPlayer, 1) -- your stuff (setElementFrozen() etc...) end end ) tested in-game. When the player recieves damage, if damage set health below 1, you cancel the event and you set 1 health point to the player. After this you can freeze him and set an animation. To really kill him, just need to use setElementHealth(localPlayer, 0).
  9. Hello, First I think you should use prefix local for health variable to make it working only in the scope of your function. I'm wondering if you could use onPlayerWasted instead, cancel the event (if it's cancellable) and set a custom animation ?
  10. For example like this : addEventHandler("onClientRender", root, function() local pos = {getElementPosition(localPlayer)} local tl, tr, br, bl = get_billboard_vertices(pos[1], pos[2], pos[3], 2, 2) primitive = { {tl[1], tl[2], tl[3], tocolor(255,0,0)}, {bl[1], bl[2], bl[3], tocolor(0,255,0)}, {tr[1], tr[2], tr[3], tocolor(0,255,0)}, {br[1], br[2], br[3], tocolor(0,0,255)}, } dxDrawPrimitive3D("trianglestrip", false, unpack(primitive)) end ) I used trianglestrip to draw a rectangle https://wiki.multitheftauto.com/wiki/File:MTAsa_primitives.png
  11. The_GTA example works perfectly I have tested in-game and there is only a little mistake : local vx, vy, vz = ( ox - cx ), ( oy - cy ), ( oz - cz ); -- instead of local vx, vy, vz = ( ox - vx ), ( oy - vy ), ( oz - vz );
  12. If you prefer it follows the camera instead the player do : _, _, rot = getElementRotation(getCamera())
  13. I'm not sure , but you could try to use the useful function getPointFromDistanceRotation ? https://wiki.multitheftauto.com/wiki/GetPointFromDistanceRotation For example, I made it work with this test : local primitive = {} local pos = {} local rot = 0 addEventHandler("onClientRender", root, function() pos = {getElementPosition(localPlayer)} _, _, rot = getElementRotation(localPlayer) local x1, y1 = getPointFromDistanceRotation(pos[1], pos[2], 1, -rot+90) local x2, y2 = getPointFromDistanceRotation(pos[1], pos[2], -1, -rot+90) primitive = { {x1, y1, pos[3], tocolor(255,0,0)}, {x2, y2, pos[3], tocolor(0,255,0)}, {pos[1], pos[2], pos[3]+2, tocolor(0,0,255)} } dxDrawPrimitive3D("trianglefan", false, unpack(primitive)) 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
  14. Hello, here a little test I just made to draw a triangle on the ped : local primitive = {} local pos = {} addEventHandler("onClientRender", root, function() pos = {getElementPosition(localPlayer)} primitive = { {pos[1]-2, pos[2], pos[3], tocolor(255,0,0)}, {pos[1]+2, pos[2], pos[3], tocolor(0,255,0)}, {pos[1], pos[2], pos[3]+2, tocolor(0,0,255)} } dxDrawPrimitive3D("trianglefan", false, unpack(primitive)) end ) Hope it can help
  15. There is probably a problem with the meta.xml of your resource.
  16. Hello, Here the documentation that can help you https://wiki.multitheftauto.com/wiki/Resource:Race. To distinguish Race from DD you can use info table from onMapStarting race event. Here an example how we could use it : local mapmode = nil addEventHandler("onMapStarting", root, function(info) mapmode = info.modename end ) function giveRacePrice(rank) if (mapmode == 'Sprint') then -- if mode is race for _,v in ipairs(Ranks) do if(rank == v[1] )then payToPlayer[source] = v[2]; end end end end addEventHandler("onPlayerFinish", root, giveRacePrice) -- event from Race function giveDDPrice(rank) if (mapmode == 'Destruction derby') then -- if mode is DD for _,v in ipairs(Ranks) do local rank = (#getAlivePlayers() + 1) -- or exports["race"]:getPlayerRank(source) ? if(rank == v[1] )then payToPlayer[source] = v[2]; end end end end addEventHandler("onPlayerWasted", root, giveDDPrice)
  17. I'm not sure to understand but here a site where you can encrypt models https://mtaclub.eu/pcrypt
  18. Hello, maybe you are trying to edit your downloaded resources instead of server resources ?. Be sure you are not trying to edit a file located in mods\deathmatch\resources instead of server\mods\deathmatch\resources (it happened to me ??).
  19. Hello, I think the interest to use table is to loop them so I wonder if it's more optimized to do for example that way : Hydra answer is totally fine, I just wanted to contribute. I did not test the script, hope I did not make any mistakes. local models = { [3356] = "mod1", [3357] = "mod2", [3358] = "mod3" -- [model id] = "name of files" (In this example, txd, col and dff need to have the same name !) -- you just need to add lines here to change models } -- when client resource is starting addEventHandler("onClientResourceStart", resourceRoot, function() for id, name in ipairs(models) do local txd = engineLoadTXD(name..".txd") engineImportTXD(txd, id) local dff = engineLoadDFF(name..".dff") engineReplaceModel(dff, id) local col = engineLoadCOL(name..".col") engineReplaceCOL(col, id) end end ) -- to restore default models when client resource is stopping addEventHandler("onClientResourceStop", resourceRoot, function() for id, _ in ipairs(models) do engineRestoreModel(id) engineRestoreCOL(id) end end )
  20. Mkl

    [REL] Ball

    Nice, Imo, would be nice to add : a kick the ball animation of the ped; a power bar (you keep pressing B for more power); a way to guide the ball while running (± like football). If I am not wrong you are planning to add the possibility to take the ball by hands ? (pickup function) nice idea. Keep it up Also, why don't you share your ressource on the mta community ?
  21. Include the variables inside the functiun and not outside (and inside the condition). -- local hour = ... -- will get values when the script starts addEventHandler("onClientKey", root, function(button,press) -- local hour = ... -- will get values everytime a player press on a key if press and (button == getKeyBoundToCommand("screenshot")) then -- local hour = ... -- will get values when the key is the screenshot command outputChatBox("You have taken a screenshot ! mta-screen_"..year.."-"..month.."-"..day.."_"..hour.."-"..minute.."-"..second..".png", 255, 0, 0, true) end end)
  22. Apparently what I said is a big mistake, please do not consider my previous message
  23. It speaks for itself, you can't compile a compiled script. Nothing much can be done about it. x) Check ACL, did you add your account name to admin ACL group ? I suggest you to use admin resource from mta resources pack. Why do you need another one ?
  24. Hello You can use this script client side : addEventHandler("onClientKey", root, function(button,press) if press and (button == getKeyBoundToCommand("screenshot")) then outputChatBox("You have taken a screenshot !") end end)
  25. Here my idea : You could store informations, the login and the hashed passeword in a client side file. See File functions in the wiki. And you could use JSON as a file format : see toJSON / fromJSON functions.
×
×
  • Create New...