Jump to content

Ihnify

Members
  • Posts

    22
  • Joined

  • Last visited

Everything posted by Ihnify

  1. Sorry, but I didn't understand I'm really stupid, you can use an example with creating a blip for an vehicle, and deleting it on the server, please, if it's not difficult
  2. this client side local vehicleBlipRoot = createElement("vehicleBlipRoot", "vehicleBlipRoot") local function streamIn() if getElementType(source) ~= "vehicle" then return end for _, blip in ipairs(getElementChildren(vehicleBlipRoot)) do if getElementAttachedTo(blip) == source then return end end if source == getPedOccupiedVehicle(localPlayer) then return end local blip = createBlipAttachedTo(source, 0, 1, 150, 150, 150, 255, 1) setElementParent(blip, vehicleBlipRoot) end addEventHandler("onClientElementStreamIn", root, streamIn) local function streamOut() if getElementType(source) ~= "vehicle" then return end for _, blip in ipairs(getElementChildren(vehicleBlipRoot)) do if getElementAttachedTo(blip) == source then destroyElement(blip) break end end end addEventHandler("onClientElementStreamOut", root, streamOut) I need to delete blip on the server but I need to delete the blip created on the client
  3. but blip is created only when a player gets into the transport stream zone, then blip is created, and I want to make sure that blip is not created if the player is in the car, and if the transport is already in the player's stream zone and another player got into the car, blip was deleted
  4. Hi how to send information about the created element to the server from the client example : vehicleBlip = createElement('vehicleBlip', 'vehicleBlip') I need to send vehicleBlip to the server I want the blip to be deleted when the player gets in the car how?)
  5. what is the difference example #1 Fuel = { id = { }; -- object = { {611.23419189453, 1694.9637451172, 6.5105047225952}, {607.91522216797, 1699.8511962891, 6.5105137825012}, {2210.05859375, 2474.6975097656, 10.33863067627}, {2200.486328125, 2476.20703125, 10.338635444641}, {2114.7475585938, 928.62805175781, 10.338633537292}, {2114.5134277344, 911.67749023438, 10.33864402771}, {1382.2032470703, 461.80364990234, 19.623880386353}, {-98.42310333252, -1166.6186523438, 2.0666558742523}, {-85.406776428223, -1171.2337646484, 1.7744096517563}, {1005.0834350586, -933.74597167969, 41.69800567627}, {1004.5383300781, -940.85437011719, 41.665897369385}, {1938.9345703125, -1772.6749267578, 12.904432296753}, {1945.3464355469, -1772.1834716797, 12.906016349792}, }; init = function ( ) addEventHandler("onPlayerVehicleEnter", root, Fuel.playerVehicleEnterFuel) addEventHandler("onPlayerVehicleExit", root, Fuel.playerVehicleExitFuel) addEventHandler("setVehicleFuel", root, Fuel.setVehicleFuel) for index in pairs(Fuel.object) do Fuel.id[index] = createMarker( ) end end; getID = function ( theVehicle ) -- code end; setVehicleFuel = function ( theVehicle, fuel ) -- code end; playerVehicleExitFuel = function ( theVehicle, seat ) -- code end; playerVehicleExitFuel = function ( theVehicle, seat ) -- code end } addEventHandler('onResourceStart', resourceRoot, Fuel.init) and use example Fuel.getID(theVehicle) in another server file for example, as I understand it, the global variable fuel is created, is it good or bad? If used like this often or example #2 and here a local variable is created getID(theVehicle) in another server file local fuel = { id = { }, object = { {611.23419189453, 1694.9637451172, 6.5105047225952}, {607.91522216797, 1699.8511962891, 6.5105137825012}, {2210.05859375, 2474.6975097656, 10.33863067627}, {2200.486328125, 2476.20703125, 10.338635444641}, {2114.7475585938, 928.62805175781, 10.338633537292}, {2114.5134277344, 911.67749023438, 10.33864402771}, {1382.2032470703, 461.80364990234, 19.623880386353}, {-98.42310333252, -1166.6186523438, 2.0666558742523}, {-85.406776428223, -1171.2337646484, 1.7744096517563}, {1005.0834350586, -933.74597167969, 41.69800567627}, {1004.5383300781, -940.85437011719, 41.665897369385}, {1938.9345703125, -1772.6749267578, 12.904432296753}, {1945.3464355469, -1772.1834716797, 12.906016349792}, } } function initFuel ( ) for index in pairs(fuel.object) do fuel.id[index] = createMarker() end end addEventHandler( "onResourceStart", resourceRoot, initFuel) function getID ( theVehicle ) return fuel.id[number] -- example end function setVehicleFuel ( theVehicle, fuel ) -- code end addEventHandler("setVehicleFuel", root, setVehicleFuel) function playerVehicleEnterFuel ( theVehicle, seat ) -- code end addEventHandler("onPlayerVehicleEnter", root, playerVehicleEnterFuel) function playerVehicleExitFuel ( theVehicle, seat ) -- code end addEventHandler("onPlayerVehicleExit", root, playerVehicleExitFuel)
  6. that is, if I encrypt via https://luac.mtasa.com/, the scripts will not decrypt in any way?
  7. how can I protect my scripts, if possible in more detail
  8. Is there a difference in performance if the entire mod is in 1 resource, or consists of several. Or who is comfortable? And how relevant is it https://luac.mtasa.com/
  9. Hi! Tell me how to use/make the function globally. For example, find out the ID of the connected database. In addition to the export function
  10. Ihnify

    [help] example

    An example of the spawn system
  11. Hi! Please show an example of a good code so that I can continue to work with it approximately (or also)
  12. Please tell me that it is better to use map manager, or mysql/sql database, if possible, show an example.
  13. Ihnify

    Tips, examples

    understand, thanks. if you are Russian, it was possible in Russian)
  14. Ihnify

    Tips, examples

    I understand, and is it ok to use it? Or better element data?
  15. Ihnify

    Tips, examples

    for example, if I do this tiggerClientEvent ( source, "fuel", source, Vehicle.fuel [ vehicle ] ) client local vehicleFuel addEvent ( "fuel", true ) addEventHandler ( "fuel", root, function ( fuel ) vehicleFuel = fuel end ) and use vehicleFuel on speedometer, or element data this is normal?
  16. Ihnify

    Tips, examples

    there are no errors as such, I just need to know how to usually work server-client, take data from the server, or client
  17. Ihnify

    Tips, examples

    init = function() for index in pairs ( Vehicle.vehicles ) do Vehicle.vehicleObject [ index ] = createVehicle( Vehicle.vehicles[index][1], Vector3( Vehicle.vehicles[index][2], Vehicle.vehicles[index][3] , Vehicle.vehicles [ index ] [ 4 ] ), 0, 0, Vehicle.vehicles [ index ] [ 5 ] ) Vehicle.fuel [ index ] = 1.5 end end; addEventHandler ( "onResourceStart", resourceRoot, Vehicle.init ) Did I make a good script "fuel system"? I load the cars and set them a certain amount of fuel. Then I take the fuel data, and use it on the client, in the speedometer. Are there standards for writing systems, or give an example of how to use it correctly in the future. I appreciate that. Learn language lua +- month
  18. How well did the script "fuel system" that is is, download auto download auto install Qty benzyl Then I take this gasoline and show on the client, if there are tips on how to do better, or as an example of how to further make such scripts - write, I will be glad Study lua +- month server local timer = {} addEventHandler("onPlayerVehicleEnter", root, function ( theVehicle, seat ) if seat == 0 then for i = 1, #Vehicle.vehicles do if theVehicle == Vehicle.vehicleObject [ i ] then if(Vehicle.fuel [ i ] <= 0.1) then return outputChatBox ( "В авто закончился бензин", source ) end outputChatBox ( "enter ok", source ) local thePlayer = source timer [ source ] = setTimer ( function () if ( Vehicle.fuel [ i ] <= 0.1 ) then outputChatBox ( "В авто закончился бензин", thePlayer ) setVehicleEngineState ( theVehicle, false ) if isTimer ( sourceTimer ) then killTimer ( sourceTimer ) end end speedVehicle = getElementSpeed ( theVehicle ) kmhFloor = math.floor ( speedVehicle ) Vehicle.fuel [ i ] = Vehicle.fuel[ i ] - ( speedVehicle + 1 ) / 15000; setElementData ( theVehicle, "Fuel", Vehicle.fuel [ i ] ) end, 300, 0 ) end end end end)
  19. Насколько хорошо сделал скрипт "система бензина", то есть есть загрузка авто, в загрузке авто устанавливаем кол-во бенза Потом я беру данный бензина и показываю на клиенте, если есть советы как сделать лучше, или как пример как в дальнейшем делать подобные скрипты - пишите, буду рад Изучаю ЯП +- месяц ServerSide : local timer = {} addEventHandler("onPlayerVehicleEnter", root, function ( theVehicle, seat ) if seat == 0 then for i = 1, #Vehicle.vehicles do if theVehicle == Vehicle.vehicleObject [ i ] then if(Vehicle.fuel [ i ] <= 0.1) then return outputChatBox ( "В авто закончился бензин", source ) end outputChatBox ( "enter ok", source ) local thePlayer = source timer [ source ] = setTimer ( function () if ( Vehicle.fuel [ i ] <= 0.1 ) then outputChatBox ( "В авто закончился бензин", thePlayer ) setVehicleEngineState ( theVehicle, false ) if isTimer ( sourceTimer ) then killTimer ( sourceTimer ) end end speedVehicle = getElementSpeed ( theVehicle ) kmhFloor = math.floor ( speedVehicle ) Vehicle.fuel [ i ] = Vehicle.fuel[ i ] - ( speedVehicle + 1 ) / 15000; setElementData ( theVehicle, "Fuel", Vehicle.fuel [ i ] ) end, 300, 0 ) end end end end)
×
×
  • Create New...