Ihnify
-
Posts
22 -
Joined
-
Last visited
Posts posted by Ihnify
-
-
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
14 minutes ago, IIYAMA said:- Server created elements are available clientside.
- Client created elements are NOT available on serverside.
But there is 1 trick you can use to delete clientside elements by serverside.
Start the following example when you are not downloading other resources, clientside must have been started before 10 seconds.
Server
local serverSideElement = createElement("exampleElement", "id:3563454hasduy3685dsfs") setTimer(function () -- destroy the element over 10 seconds destroyElement(serverSideElement) end, 10000, 1)
Client
local clientSideElement = createElement("exampleExample") -- get the serverside element local serverSideElement = getElementByID("id:3563454hasduy3685dsfs") if isElement(serverSideElement) then setElementParent(clientSideElement, serverSideElement) -- set the clientside element as child of the serverside element end addEventHandler("onClientElementDestroy", clientSideElement, function () iprint("onClientElementDestroy") end, false)
***
Fixed the wrong ID value.
but I need to delete the blip created on the client
-
1 minute ago, Rakashy said:
use destroyElement
type
destroyElement (element)
example:
let's assume that the created blip is called BlipCarro, then insert the function to execute when the player enters the car
destroyElement (BlipCarro)
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
-
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?)
-
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 exampleFuel.getID(theVehicle) in another server filefor example, as I understand it, the global variable fuel is created, is it good or bad? If used like this oftenor example #2and here a local variable is createdgetID(theVehicle) in another server filelocal 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)
-
thanks
- 1
-
3 minutes ago, majqq said:
Just compile them with highest level of obfuscation. For client-side scripts use cache="false" in meta.xml aswell.
that is, if I encrypt via https://luac.multitheftauto.com/, the scripts will not decrypt in any way?
-
16 minutes ago, majqq said:
One resource:
No need for use exports (which are slow) or triggers.
Direct access to functions.
If you want to introduce/change something - you need to restart whole mod.
Several resources:
In order to have all functionality exports are needed or triggers.
Using functions through exports/triggers (if function is in other resource).
If you want to introduce/change something - you just restart desired resource.
In other words, one resource for best performance, or several resources for elasticity.
LUAC compiles (and obfuscates code if selected), compiling script converts it directly to Lua bytecode, therefore client/server doesn't need to do that.
how can I protect my scripts, if possible in more detail
-
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.multitheftauto.com/
-
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
-
An example of the spawn system
-
Hi!
Please show an example of a good code so that I can continue to work with it approximately (or also)
-
Please tell me that it is better to use map manager, or mysql/sql database, if possible, show an example.
-
understand, thanks. if you are Russian, it was possible in Russian)
-
I understand, and is it ok to use it? Or better element data?
-
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?
-
there are no errors as such, I just need to know how to usually work server-client, take data from the server, or client
-
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
-
13 minutes ago, stPatrick said:
-
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)
-
-
Насколько хорошо сделал скрипт "система бензина", то есть есть загрузка авто, в загрузке авто устанавливаем кол-во бенза
Потом я беру данный бензина и показываю на клиенте, если есть советы как сделать лучше, или как пример как в дальнейшем делать подобные скрипты - пишите, буду рад
Изучаю ЯП +- месяц
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)
-
Код скинуть хотябы
triggerServerEvent
in Scripting
Posted · Edited by Ihnify
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