Jump to content

Wojak

Members
  • Posts

    321
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Wojak

  1. i've checked this interior using my teleporteditor script, and there is no problem with geting in and out (there is a floor) my script sets player position clientside, than trigger the server event to change the interior (i also set a diferent dimention using my resource settings) anyway, if you want to hardcode youre teleports in a script, set the destynation z position higher, it may help
  2. getVehicleOccupant(hitElement,1) should be getVehicleOccupant(hitElement,0) 0 is a driver, 1 is a pasanger
  3. dont assume that hitelement is a vehicle - check it, also i think you cant set the player position if he is in vehicle, so use: removePedFromVehicle
  4. Wojak

    Table FTW??

    i tested the code here (with a little edition): http://www.lua.org/cgi-bin/demo and it works fine: newTable = { "1st value", "2nd value" } -- loop from your code works fine (print instead of outputChatBox to run it in demo) for i,v in ipairs(newTable) do print(tostring(newTable[i])) end --this also works, I think its better for i,v in ipairs(newTable) do print(v) end
  5. o ile dobrze pamiętam to tym się da edytować: https://addons.mozilla.org/en-US/firefo ... e-manager/
  6. you don't need to create all markers at once, you need to add the event after you create the marker (events can be added inside functions)
  7. there are 3 errors when you start the resource - bad argument at line 21,32,43 (C2, C3 and CP do not contain marker element at the yime you add the event) also this is a client script, so "onClientMarkerHit" not "onMarkerHit" and GetLocalPlayer() should be getLocalPlayer() you will not se client errors in server console use /debugscript 3 in game
  8. onResourceStart is triggered only once onClientResourceStart is triggered every time a player downloads the resource clientside file (but only once per client unlill disconect, it will be triggered again after reconnect ) so if you want to replace the startup code "onResourceStart" and run it with a custom event triggered by "onClientResourceStart" it will be like starting a new resource every time a player join the server (you will eventually run out of memory, and same stuff will be run multiple times) but "onClientResourceStart" may be used for detecting if it's safe to trigger client events to a specyfic client
  9. yes, that's exactly the problem here... i always add triggerServerEvent("onResourcenameClientFileDownload", getLocalPlayer()) at the end of the clientside file, if its triggered you can safely trigger client events from the server, DarkLink you may use it instead of "onPlayerJoin"
  10. my teleporteditor script also freeze the vehicle for 50ms, the only diference is that i'm using the anonymus function (i do a lot more then just unfreeze after the timer) and there are no problems... if(total >= 1) then local vehicle=getPedOccupiedVehicle(player) setVehicleFrozen(vehicle,true) setElementPosition (vehicle, -441.2646484375, -2218.306640625, 84.912033081055) setTimer(function() setVehicleFrozen(vehicle,false) end,50,1) end you may also try unfreezing the vehicle several times
  11. There are no such limits in lua, you made a typo somewhere (as you know one misplaced letter can change much). You did not see the error in the server console, becouse client scriprs are runed by client, not the server... Use "/debugscript 3" command in game, you can also check the debug log ".../MTA San Anderas/MTA/clientscript.text" - the file collects errors from all servers you visited - it will be very large
  12. createProjectile(getLocalPlayer(), 19, offX, offY, offZ+0.5, 5000, nil, 0, 0, 360 - rotz, vx, vy, vz) this should do it, but if the vehicle is too long, you will need to calculate a larger ofset (this code should create the rocket 1m in front of the vehicle center of mass)
  13. code : for x,y in ipairs(getElementsByType("player")) do setPlayerMuted(player, true) end will run without any problems on resource start, also if you want a function so much you can do: function gMute() for x,y in ipairs(getElementsByType("player")) do setPlayerMuted(player, true) end end gMute() and it still will run on resource start with no need of events that means 99,9% of scripters use this event for no reason, ass they don't use the resource parameter... also code: function resStartFunc(startedRes) doSomething(startedRes) end addEventHandler("onResourceStart", resourceRoot, resStartFunc) function doSomething(res) outputChatBox(getResourceName(res).." started!") end shourd have same efect as: outputChatBox(getResourceName(getThisResource()).." started!") My theory is that using this event has its origin in copying examples from MTA wiki.
  14. addCommandHandler("boom",function() local occupiedVehicle = getPedOccupiedVehicle(getLocalPlayer()) 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] vx = offX - x vy = offY - y vz = offZ - z local rotx, roty, rotz = getElementRotation(occupiedVehicle) createProjectile(getLocalPlayer(), 19, x, y, z+1, 500, nil, 0, 0, 360 - rotz, vx, vy, vz) end) tested in game, and works
  15. no one should notice the FPS drop with one text, but try to debug your code anyway
  16. @CowTurbo do you even know what is a rootElement? @DjSt3rios as I said the order of vehicle rotation components are inverted... also I wrongly assumed that you know what you setting the vehicle velocity as projectile velocity... this code will calculate a correct vector direction (at lest it should) local occupiedVehicle = getPedOccupiedVehicle(getLocalPlayer()) 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] vx = offX– x vy = offY – y vz = offZ - z local rotx, roty, rotz = getElementRotation(occupiedVehicle) -- experiment with rotx, roty, rotz order createProjectile(getLocalPlayer(), 19, x, y, z, 500, nil, 0, 0, rotz, vx, vy, vz)
  17. I don't think that getElementRotation(occupiedVehicle) will return the rotations with x,y,z order, try different configurations (y,x,z or z,x,y), also you only setting the z rotation on the Projectile, you should set all 3 components. Also make sure that the projectal is created only on one client at the time (projectal is the only type of element that will exist on all clients even created on one)
  18. if you have any doubt that the part of the code is not running, add some output lines, you can also output variables to check it they have corect values when they ate neede't. If you can not make removeEventHandler to work, set the segundos as empty string after 0 segundos = ""
  19. Subject: The point of using “on(Client)ResourceStart” event for "this" (current) resource. Lets consider the fallowing examples: function chatbox() outputChatBox("Starting resource x")-- this line is a example and represents many things... end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()),chatbox) and outputChatBox("Starting resource x") both codes will have the exact same effect, the only difference is the memory usage (first calls 3 more functions: addEventHandler, getThisResource and getResourceRootElement) so why everybody are using the first method?
  20. a jednak mimo oż podałem ci wszystkie potrzebne informacje, nie potrafisz poskładać tego 5-linijkowego skryptu w całość... addEventHandler ( "onClientGUIClick", twójPrzycisk, function(button, state) if button == "left" and state== "down" then setControlState ( "enter_exit", true ) end end) z tym że z odległości którą pokazałeś na filmiku może nie zadziałać, jeśli zależy ci na tej odległości to: -za pomocą odpowiedniej funkcji pozyskujesz pozycje gracza i samochodu -uzyskane dane wykorzystujesz do obliczenia kąta, pod którym należy ustawić gracza -odcinasz sterowanie graczowi żeby się nie wyrywał -ustawiasz graczowi animację chodzenia (pobaw się panelem freeroam to znajdziesz id) -co 50ms będzie trzeba sprawdzać jak daleko jest gracz od pojazdu -jeśli jest dostatecznie blisko to zmieniasz animację na otwieranie drzwi (w tej chwili otwarcie drzwi przez skrypt nie jest możliwe - dopiero w MTA 1.1 będzie) -używasz warpPedIntoVehicle jak na filmiku -przywracasz sterowanie graczowi a na serwerze byłem, i niestety muszę stwierdzić że poziom intelektualno - emocjonalny co niektórych adminów pozostawia wiele do życzenia
  21. te małe słówko "gui" zmienia sens zdania zakładając że wiesz jak stworzyć ten przycisk, dodam tylko że aby przypisać go do funkcji używasz eventu: https://wiki.multitheftauto.com/wiki/OnClientGUIClick ponieważ skrypt z gui musi być po stronie clienta (no chyba że chce ci się tworzyć własne eventy by wysłać dane do servera) w funkcji "setControlState" nie będzie potrzebny parametr "jakiśTamGracz" (wstawienie tego parametru wywoła błąd "bad argument") aby wszystko działało w chwili kliknięcia na przycysk gracz musi być blisko pojazdu, dobrze by było też dodać jakiś tekst wychodzący (np na czat - outputChatBox)
  22. Zanim zwrócisz komuś uwagę na to że nie potrafi czytać ze zrozumieniem, lepiej sam naucz się tej trudnej techniki... wyrażenie: przekłada się na język lua w postaci (zakładając że piszemy skrypt servera): setControlState ( jakiśTamGracz, "enter_exit", true ) -- dla przycisku f lub enter setControlState ( jakiśTamGracz, "enter_passenger", true ) -- dla przycisku g
  23. https://wiki.multitheftauto.com/wiki/SetControlState https://wiki.multitheftauto.com/wiki/Control_names
  24. addEvent("onClientElementCreate",true) addEventHandler("onClientElementCreate", root, function() if getElementType(source) == "vehicle" then local vehicles = getElementsByType(vehicle) if table.getn(vehicles) > 4 then exports.editor_main:destroySelectedElement() -- client only function outputChatBox("gamemode doesnt permit more than 4 cars") end end end) not tested, but should work save it in a file called edf.lua, and add to your resource edf file
×
×
  • Create New...