Jump to content

Aibo

Retired Staff
  • Posts

    1,105
  • Joined

  • Last visited

Everything posted by Aibo

  1. Aibo

    createPed

    local ped = createPed(92, 2464, -1697, 1013) setElementInterior(ped, 2, 2464, -1697, 1013)
  2. because aclGetGroup returns ACL group, getting it by group name. right now your use of this function is just random.
  3. Aibo

    GUI Welcome Screen

    guiEditor_Label is not GUIEditor_Label. names are case-sensitive in Lua.
  4. Jaysds1, please stop posting nonsense with syntax errors in almost every line. maskatchi, there's was a topic about projectiles just the other day.
  5. Aibo

    Object

    1. use local variable for vehicle (since it can change and player can be not in a vehicle at all) 2. you may want to use some vehicle entry event, to attach a rocket to the current vehicle. 3. you dont need to know vehicle rotation or set rotation in createObject, because when you'll attach the rocket to the car it will recieve the same position and rotation as the car anyway 4. offsets should be relative to the parent element. function onResourceStart() local vehicle = getPedOccupiedVehicle(g_P) if vehicle then local x, y, z = getElementPosition(vehicle) rocket = createObject(3786, x, y, z) attachElements(rocket, vehicle, 0, 0, 2, 0, 0, 0) end end addEventHandler("onClientResourceStart", resourceRoot, onResourceStart) if the rocket is not in the right direction, you'll have to change rotation offsets in attachElements (last 3 zeros), usually by 90 or 180 degrees on some axis.
  6. occupiedVehicle is nil. use /debugscript 3 also g_p is not g_P g_P = getLocalPlayer() rocketTimer = false function rocket() if not rocketTimer and isPedInVehicle(g_P) then local occupiedVehicle = getPedOccupiedVehicle(g_P) local rotX,rotY,rotZ = getElementRotation(occupiedVehicle) local x, y, z = getElementPosition(occupiedVehicle) local matrix = getElementMatrix(occupiedVehicle) local offX = 0 * matrix[1][1] + 1 * matrix[2][1] + 0 * matrix[3][1] + 1 * matrix[4][1] local offY = 0 * matrix[1][2] + 1 * matrix[2][2] + 0 * matrix[3][2] + 1 * matrix[4][2] local offZ = 0 * matrix[1][3] + 1 * matrix[2][3] + 0 * matrix[3][3] + 1 * matrix[4][3] local vx = offX - x local vy = offY - y local vz = offZ - z x = 0 * matrix[1][1] + 3 * matrix[2][1] + 0 * matrix[3][1] + 1 * matrix[4][1] y = 0 * matrix[1][2] + 3 * matrix[2][2] + 0 * matrix[3][2] + 1 * matrix[4][2] z = 0 * matrix[1][3] + 3 * matrix[2][3] + 0 * matrix[3][3] + 1 * matrix[4][3] createProjectile(g_P, 19, x, y, z, 200, nil, 0, 0, 360 - rotZ, vx, vy, vz) rocketTimer = setTimer(function() rocketTimer = false end, 3000, 1) else outputChatBox("You must wait 3 seconds to fire again", 0, 255, 0, true) end end function onResourceStart() bindKey("lctrl", "down", rocket) end addEventHandler("onClientResourceStart", resourceRoot, onResourceStart)
  7. actually i wouldnt recommend editing getPlayerName() in _common.lua (you can break something by bringing back color codes). better use _getPlayerName() when you want a name with color.
  8. 1. this dxDrawColorText does not support text alignment (you should search, i posted a fixed version somewhere with centering etc) 2. as i recall race resource strips color tags from player names. (see _common.lua where getPlayerName is redefined to strip color codes) you can try using _getPlayerName()
  9. also there is no "ctrl" key name, it "lctrl" for left and "rctrl" for right ctrl keys. also i'd ditched element data and used timer variable to check if player is allowed to shoot: g_P = getLocalPlayer() rocketTimer = false function rocket() if not rocketTimer then createProjectile(g_P, 19, getElementPosition(g_P), 200) rocketTimer = setTimer(function() rocketTimer = false end, 3000, 1) else outputChatBox("You must wait 3 seconds to fire again", 0, 255, 0, true) end end function onResourceStart() bindKey("lctrl", "down", rocket) end addEventHandler("onClientResourceStart", resourceRoot, onResourceStart) PS: since you want this on a vehicle, you should check if player is in a vehicle and get vehicle positions for projectile.
  10. local manual = 0 function switchManualAuto(command) if command == "manual" then manual = 1 elseif command == "auto" then manual = 0 end end addCommandHandler("auto", switchManualAuto) addCommandHandler("manual", switchManualAuto) also read about addCommandHandler on the wiki. ps: if your manual variable has only 2 states (1 and 0) imo it's better to use boolean (true/false)
  11. showPlayerHudComponent(player, "clock", false) https://wiki.multitheftauto.com/wiki/Sho ... dComponent
  12. though you can concatenate your table into a string, and then split it back again into a table. but that is not a very efficient way of storing data, imo. PS: there's no need to create another topic.
  13. no https://wiki.multitheftauto.com/wiki/SetAccountData
  14. alpha = alpha == 255 and 0 or 255 basically if statement (alpha == 255) is true, it sets alpha = 0 (and 0) else it sets alpha = 255 (or 255) is pretty much the same as: if alpha == 255 then alpha = 0 else alpha = 255 end
  15. this is overkill, you are creating new timers every frame. X,Y = guiGetScreenSize() X = X * (1/5.5) Y = Y * (1/3) alpha = 255 function firstAppear() dxDrawText("Slaineeed!", X, Y, X, Y, tocolor(255, 64, 64, alpha), 5) end function hideAlert() removeEventHandler("onClientRender", getRootElement(), firstAppear) end addEvent("alertRadar",true) function showAlertAdvice() addEventHandler("onClientRender", getRootElement(), firstAppear) setTimer(function() alpha = alpha == 255 and 0 or 255 end, 500, 3) setTimer(hideAlert, 1500, 1) end addEventHandler("alertRadar", getRootElement(), showAlertAdvice) edited*
  16. Aibo

    Moving objects

    MTA is not a map editor for SA:MP.
  17. probably because 2.5 gets rounded to 2, so 40*2 is only 80. you can try this, see if it helps: guiProgressBarSetProgress(bar1, 0) setTimer(function() guiProgressBarSetProgress(bar1, guiProgressBarGetProgress(bar1)+4) end, 80, 25)
  18. it was freezing at 2.5% because guiProgressBarGetProgress(bar1) + 2.5 is calculated only once, on timer initialization, so it sets progress to 2.5 all 40 times.
  19. well currently you create 98 (because you havent specified your step for incrementing, and default is +1, not 2.5) timers right away, they all run almost simultaneously. that's why your bar fills so fast. should be something like this: guiProgressBarSetProgress(bar1, 0) setTimer(function() guiProgressBarSetProgress(bar1, guiProgressBarGetProgress(bar1)+2.5) end, 50, 40)
  20. i'm talking about MTA/GTA object limit. every block will be an object. you can't create objects «without limit».
  21. what about element/object limit? can't have enough blocks for proper minecraft, imo.
  22. stop inventing the bicycle and use scrollbar. progress bar stops being a progress bar when you want to "move arrow with mouse".
  23. wouldn't that be a scrollbar. progress bars usually do not require user input.
  24. Hmm, i am not sure but i think that won't work # returns table length if used with a table (numeric indexed) and string length if used with a string
  25. because those are magic characters (like in a pattern [ and ] denote a set) and therefore must be escaped if you want to search for them in a string. not "|" though, as i recall, but i escaped it just in case. by the way, your string.gsub(playerName, '[FP]', '') will leave [ and ] in the name for the reason above, [FP] is a pattern here. same applies to the previous string.find. it will just find/replace any F or P letters in the name. either use plain search option, or escape [ and ]. testName = '[FP]FatPony' newName = string.gsub(testName, '[FP]', '') -- and the name now is: []atony
×
×
  • Create New...