Jump to content

pro-mos

Members
  • Posts

    84
  • Joined

  • Last visited

Posts posted by pro-mos

  1. 3 hours ago, pa3ck said:

    There are other components which can be changed on individual vehicles like paintjobs, rims, glass etc and that is when targetElement comes in to play.

    The thing is there's servers that use custom under-vehicle neon, and custom nitro colors which is unique for each player, it just confuses me.

  2. 12 minutes ago, Psychotic_OZ said:

    oh oops somehow i removed that but i cant get a car to spawn using the /greet

    createvehicle is the command, not greet.

    greet, in that case, is the command name. which is (greet = "createvehicle")

  3. On 6/20/2017 at 04:28, MIKI785 said:

    You can't. The nitro texture is global, it's not tied to vehicle elements. Hence you can't change it for only one vehicle, it's either all of them or none.

    "smoke" and "shad_car" also can't be tied to one vehicle as i've tried and failed.

    But what's the point of `targetElement` then ?!

    engineApplyShaderToWorldTexture ( shader, textureName [, element targetElement)

    On 6/20/2017 at 19:24, Hale said:

    What would be the best way to create custom nitro colors for everyone then? My first thought was to create marker but that'd look ugly as hell, there must be a better way.

    did you find an alternative?

  4. Im trying to use ultra thing mod, but it doesn't work anymore, i think it worked before, but now it only works with normal GTA SA.exe

    i have the mod files in the GTA directory, and mta warns me about d3d9.dll file, but i press continue and no mod works... what could be the problem?

  5. 16 minutes ago, Bonsai said:

    What do you mean with "reload two scripts"?

    If you make it a seperate resource that only handles script loading there shouldn't be any problems, and I assume its safer too.

    Also, that script back then was pretty messy. :(

    And very important, don't use that for server side scripts.

    Hi :D

    i would like it to be on the same resource, so when im testing, i /restart only 1 resource, i tried to insert the modified functions into 'env' like

    env.addEventHandler = ...

    env.outputChatbox = ...

    everytime the  environment is created. but that doesn't work :( 

  6. I don't think function cook will ever be executed, since it's undefined in the scope of the addCommandHandler, cook should be next to the handler.
     

    function cook(...)
      -- do stuff
    end
    addCommandHandler("cookmeth", cook)

    but then, this would allow anyone to use the command, so do it like this:

    local playersInCookingTruck = {}
    function giveoptions( thePlayer, seat, jacked)
      if (getElementModel (source) == 508) then
        playersInCookingTruck[thePlayer] = true
        -- rest of the function ...
      end
    end
    addEventHandler('onVehicleEnter', root, giveoptions)

    then you check if player in cooking truck, in function cook

    function cook(player)
      if not playersInCookingTruck[player] then return end -- stop, dont do the code below
      -- check for inventory
      setElementFrozen(player, true)
      -- ....
    end

    For the timer, no, it wont wait until the timer is done to execute the code below it, if you want it to wait, then

    setTimer(function()
      -- after 18 seconds, do all this
      -- start client timer
      outputChatBox('You've got your meth', player)
      -- give him some meth
    end, 18000, 1)

     

  7. First, use onVehicleEnter handler and bind it to a function that does the checks like getElementModel (check if the vehicle id == 508)

    If yes, he can try to cook so do something like this

    canCook =[]

    canCook[player] = true

    Then, addCommandHandler that triggers the cooking if player can cook only

    If yes, check the inventory of the player.

    I assume you have an inventory system, if not,

    inventory = {}
    addCommandHandler('getStuff', function (player)
     inventory[player] = {}
     inventory[player]['Gas Can'] = 2
     inventory[player]['Mask'] = 1
    
     outputChatBox('You got some stuff', player, 255,255,255)
    )
    
      

    Ok now you can check if a player has an item like this

    if inventory[player]['Gas Mask'] >= 2 and inventory[player]['Mask'] >= 1 then
      -- can cook
      -- triggerClientEvent todisplay a timer and on screen gui
    end
    
      

     

  8. addEventHandler("onResourceStart", resourceRoot,
      function ()
        exports.scoreboard:scoreboardAddColumn('Vehicle:')
      end
    )
    
    setTimer(function ()
      local players = getElementsByType "player"
      for k, v in ipairs ( players ) do
        if ( isPedInVehicle(v) ) then
          local vehicle =  getPedOccupiedVehicle(v)
          local carname = getVehicleName(vehicle)
          setElementData ( v, "Vehicle:", tostring(carname) )
        else
          setElementData ( v, "Vehicle:", "On foot")
        end
      end
    end, 2500, 0)

    You had the function name wrong

    • Like 1
  9. 4 hours ago, MIKI785 said:

    Ok then. But just a bit of advice, dont use triggerClientEvent to transfer large amount of data as it could stall the server. Use triggerLatentClientEvent instead.

    i tried this latent event now, and it seems a lot slower than the normal triggerClientEvent, i've tested it on local server

  10. I've edited bonsai's script wrapper and using it, it looks like this:

    local env = {}
    local _createObject = createObject
    local _setTimer = setTimer
    local _addEventHandler = addEventHandler
    
    outputChatBox = function() end
    triggerServerEvent = function() end
    createObject = function(...)
    	local object = _createObject(...)
    	setElementDimension(object, dimension)
    	table.insert(wrapper.objects, object)
    	return object
    end
    
    function newClientEnvironment()
    	env = table.copy(_G, true)
    
    	local metatable = {
    		__index = function(self, index)
    			return rawget(_G, index)
    		end,
    
    		__newindex = function(_G, index, value)
    			rawset(_G, index, value)
    		end
    	}
    
    	setmetatable(env, metatable)
      _outputChatBox('created new Environment')
    end

    and this is how a script is loaded:

    function loadScript(scriptData)	
      local loaded = loadstring(scriptData)
      setfenv(loaded, env)
      local ex = pcall(loaded)
    end

    The problem is the functions re-defined above interfere with my main script that is using this wrapper. i can just use this wrapper as a separate script but then i'll have to reload two scripts rather than 1, and i dont want that.

    any ideas? and thank you for reading

  11. i use triggerClientEvent to send the files, and i write them with fileWrite, and then close the files with fileClose, the files are fine, i can see them downloaded in deathmatch/resources/script/cache/water.fx

    i think it might be a file path error, since im getting confused of how MTA's file path works

    EDIT: i've found the problem was the files download with a script and i try to use them with another script.. i've added ':scriptname' to the file path and now it works, sorry for your time.

  12. 11 minutes ago, MIKI785 said:

    Obviously you have to finish downloading them before you run the dx functions. How do you actually download them?

    the server sends the file data and i write them client side with

    fileCreate('cache/'..filename)

    after creating and writing the file, i try to load it right away.

  13. addCommandHandler('paytoll',
    function(player)
    local x,y,z = getElementPosition(player)
    -- x2, y2, z2 = toll position
    local d = getDistanceBetweenPoints3D(x,y,z,x2,y2,z2)
    if d <= 50 then
      -- open toll
    end
    end)

    Something like this, sorry i wrote it on my phone

×
×
  • Create New...