majqq

Members
  • Content Count

    497
  • Joined

  • Last visited

Community Reputation

111 Excellent

4 Followers

About majqq

  • Rank
    Hustler

Recent Profile Visitors

1,547 profile views
  1. attachElements expect object. Create object with model 1097, save it to variable, and then pass it as 1st argument.
  2. local colshape = createColSphere(tonumber(x), tonumber(y), tonumber(z), tonumber(radius)) If you create colshape, and not delete it it will stay on map until resource restart, wanna see? After using your command follow steps below. Execute this command in admin panel (Resources > Execute command) setDevelopmentMode(true) for client & server. And then, simply write: /showcol in chat. I've added additional element data check, so if vehicle doesn't have such element data, it wouldn't compare number with boolean. Besides, my version of code is somewhat faster, because of integer loop (you can't really see difference, but it's better to use it anyways) Source: https://springrts.com/wiki/Lua_Performance Why after all people use ipairs without sensible reason? I don't know, maybe because some of them lazy, or they don't even know that you can use int loop.
  3. function lockCar(player, cmd) local radius = 3 local x, y, z = getElementPosition(player) local vehiclesAround = getElementsWithinRange(x, y, z, radius, "vehicle") local vehicleElement = false if #vehiclesAround == 0 then outputChatBox("no vehicles around", player, 220, 220, 0) return end for i = 1, #vehiclesAround do vehicleElement = vehiclesAround[i] if getElementData(vehicleElement, "uid") and getElementData(vehicleElement, "uid") == 0 then setVehicleLocked(vehicleElement, true) outputChatBox("lock", player, 220, 220, 0) break end end end addCommandHandler("wv", lockCar) Here you go, i also changed loop to faster, and we don't need colshape to get vehicles around. (+problem is that, that you create colshape and never delete it)
  4. setPlayerHudComponentVisible("area_name", false) setPlayerHudComponentVisible("vehicle_name", false)
  5. Those are private files, as Tut said, someone didn't wish that his files would be used on other servers.
  6. That's correct, it's either true or false. p isn't defined in your code. Test this piece of example code, you should understand after typing /testcmd (server-side code) function myCommand(player, cmd) outputChatBox("player: "..inspect(player).." cmd: "..inspect(cmd)) end addCommandHandler("testcmd", myCommand)
  7. Due of error codes, it's easy. Function expects element (mostly stored in variable or as parameter), your p is nil. Similar case, but this time you got boolean (false), let's check what returns getPlayerAccount: Your variable p was nil, and therefore function returned false on it's failure.
  8. Impact at server will only exists during sync events, if you gonna create healthy triggers everything should be alright.
  9. Can you share your solution so others might find it and do not create other topics for that?
  10. majqq

    [Help] Functions

    Server-side functions doesn't exist on client-side.
  11. If you gonna use variables inside render scope, it is better to reuse them (declare it in main scope), so they are not recreating every frame. local x, y, z = 0, 0, 0 addEventHandler("onClientPreRender", root, function() for i = 1, table.size(spawnedItem_ID), 1 do x, y, z = getElementPosition(localPlayer) if(getDistanceBetweenPoints3D(x, y, z, spawnedItem_X[i], spawnedItem_Y[i], spawnedItem_Z[i]) <= 5) then triggerEvent("onPlayerEnterItemArea", root, spawnedItem_ELEMENTO[i]) -- Draw the image and the text end end end) However colshape solution it's better. (if you not gonna reach thousands of them for client/server)
  12. Thanks for suggestion, but i already tested isElementOnScreen, it would cause object stay for a moment when not looking on it. However this was so far ago, so i might did something incorrect. Whatsoever performance in render can be improved by declaring variables out of rendering scope (so basically in main one), and reusing them. I will rewrite bone attach once again to apply some tricks what i've learnt since this topic (to gain even more than 50% performance boost), and let you know about results in this topic
  13. Maybe because of: Serverside commands can only be executed by the server. The same applies to the client side This is how you kill your server network. local players = getElementsWithinRange(x, y, z, 50, "player") for i,player in ipairs(players) do triggerClientEvent(player, "chat:box", root, thePlayer, set, first) end You trigger this event separately per player. Very bad solution. You know you can use table of players instead as first argument? Which is players in your case. Also using ipairs is bad, since this is worst type of loop. I'm kinda repeating myself - https://forum.mtasa.com/topic/121808-doubts-if-you-can-improve-performance/
  14. Hey, as topic title says, i'm offering scripting services in MTA:SA. My adventure with Lua started a little bit later than year ago, during that time i've learnt quite more than I wanted, so starting from today i'm ready to complete some - or even all of your tasks. In case, if you have problems with communicating in English, i also know Russian - so feel free to speak with me po-russki My possibilites with scripts: ▪ Creating new, on your request. ▪ Editing already existing ones. ▪ Fixing bugs/issues. ▪ Optimising. I provide: ▪ Error/warning free code. ▪ Element data free code (unless you really need that, i love to work with triggers & tables instead) ▪ Support after receiving services, in case of any problems. If you are interested, contact with me: via Discord: SERIOUSLY?#4654 (Also describe your request as well as you can, so I will know if i can handle it)