Jump to content

Z4Zy

Members
  • Posts

    215
  • Joined

  • Last visited

  • Days Won

    3

Posts posted by Z4Zy

  1. Hello!

          I created a very basic script of vehicle door control with cursor. When press "1", driver's door open/close according to the cursor move. When press "2" that event will remove.

     

    Meta.xml

    <meta>
    	<script src="client.lua" type="client" />
    </meta>

     

    Client.lua

    
    local dState = false
    
    function moveDoor()
    
      local vehicle = getPedOccupiedVehicle(localPlayer)
      
    	if (getVehicleDoorOpenRatio(vehicle, 2) >= 1) then
    		dState = "close"
    	elseif (getVehicleDoorOpenRatio(vehicle, 2) <= 0) then
    		dState = "open"
    	end
      
    	if (dState == "open") then
    		setVehicleDoorOpenRatio(vehicle, 2, getVehicleDoorOpenRatio(vehicle, 2) + 0.01 )
    		
    	elseif (dState == "close") then
    		setVehicleDoorOpenRatio(vehicle, 2, getVehicleDoorOpenRatio(vehicle, 2) - 0.01 )
    	end
    	
    end
    
    
    bindKey("1", "up",
    function ()
    	addEventHandler("onClientCursorMove", root, moveDoor)
    end)
    
    bindKey("2", "up",
    function ()
    	removeEventHandler("onClientCursorMove", root, moveDoor)
    end)

     

     

    I need your help with two problems.

     

    Problem - 01

    The door should move only if player move the cursor left and right on the screen. Not for moving up and down.

     


     

    Problem - 02

    Door movement direction (open/close) need to be depend on players view position.

    Meaning, If player's camera at the front of the vehicle, then when player move the cursor to right, door will open.

    If player's camera at the back of the vehicle, then when player move the cursor to right, door will close.

    This will apply vice versa to left.

     

    • Simple Image Demonstration
    Spoiler

     

      Front

    7sXBFt9.png

     

       Back

    kmJyQkp.png

     

     

    Appreciate any help.

    Thank In Advance !!

     

  2. I noticed that in client code, you added the event "onClientElementDataChange" inside "onClientColShapeHit" event. so, each time when player enter the colshape new "onClientElementDataChange" event is created. This will cause the trigger server event each time +1.

  3. Hello everyone !

    When I use following piece of code to set the animation and get what animation the ped is doing, I've noticed that 'getPedAnimation' function doesn't return the correct animation when 'setPedAnimation' function's loop argument set to false. When loop argument set to true, 'getPedAnimation' function return the correct block and animation.

    I used IFP_Demo resource's parkour.ifp file.

    Client Side :

    local ifp = engineLoadIFP("parkour.ifp", "parkour")
    
    setPedAnimation(localPlayer, "parkour", "HandPlant", -1, false) -- set false argument to true when testing
    
    setTimer(
    function ()
      local block, anim = getPedAnimation(localPlayer)
    	outputDebugString("Block : "..block..", Anim : "..anim)
    end, 1000, 1
    )

     

    When 'setPedAnimation' function's loop argument set to false,

    Spoiler

    bifujaqsyzch4kjzg.jpg

    INFO message has return the wrong block and animation.

     

    When 'setPedAnimation' function's loop argument set to true,

    Spoiler

    sv25df36ojnp4ufzg.jpg

    INFO message has return the correct block and animation.

     

  4. I've installed MTA:SA on a PC and it also had the suitable GTA:SA version installed and that GTA:SA is working fine without any problem. The problem is on MTA:SA which is, when double click on icon and run the game, screen goes usually. As soon as it comes to the main screen with quick connect, connect, .. etc menu, MTA will stuck with not responding status on task manager. Below is the text generated by 'MTADiag' in that PC. Please help to resolve this and to make MTA work fine.

    https://pastebin.mtasa.com/352889836

  5. Hello dear !

              I'm trying to play some musics with the function 'playSound3D'. The sound URLs are provided to the function [ not files ]. So, that this musics are started to play according to the internet speed of the client. Some will start earlier than others.

              My problem is in stopping the sound. When current music ends, the next one should play. For that I need to know how long that the current sound will play. Therefore, how to return the left playtime of the sound?

  6. Hello @Burak5312 !

                       First, I thing it should better if you add following ped into a table giving unique variable as that ped created on server side. if boomer = your following ped, then if I command to spawn a follower, then 'boomer' refers to my follower. Not yours from then. so, it may get confused to the follower !! So, I suggest you to create a table and get the nick name / account name of the command user and store it in a table. Then under that account name variable, create the follower. [ These are told according to my opinion. ]

  7. function DeleteVIP (command, accountName)
    local result = dbQuery(database,"SELECT * FROM vip")
    local poll = dbPoll(result, -1)
    for i,v in ipairs(poll) do
    local time = getRealTime()
    if (tonumber(v["viptime"]) < tonumber(time.timestamp)) and (tonumber(v["viptime"]) > 0) then
    dbExec(database, "DELETE FROM vip WHERE id = ?", tonumber(v["id"]))
    local account = getAccount(accountName)
    if getAccountPlayer(account) == tostring(v["acc"]) then
    local player = getAccountPlayer(account)
    outputChatBox("VIP: " .. accountName .. " ", player, 255, 255, 255, true)
    		end
    	end
    end
    dbFree(result)
    end
    setTimer(DeleteVIP, 6000000, 0)

    In line 8 you had to define the 'accountName' variable. Got it ?

    • Thanks 1
  8. 6 hours ago, Sendy said:

     

    
    function DeleteVIP (command, accountName)
    local result = dbQuery(database,"SELECT * FROM vip")
    local poll = dbPoll(result, -1)
    for i,v in ipairs(poll) do
    local time = getRealTime()
    if (tonumber(v["viptime"]) < tonumber(time.timestamp)) and (tonumber(v["viptime"]) > 0) then
    dbExec(database, "DELETE FROM vip WHERE id = ?", tonumber(v["id"]))
    local account = getAccount(accountName)
    if getAccountPlayer(account) == tostring(v["acc"]) then
    local player = getAccountPlayer(account)
    outputChatBox("VIP: " .. accountName .. " ", player, 255, 255, 255, true)
    		end
    	end
    end
    dbFree(result)
    end
    setTimer(DeleteVIP, 6000000, 1)
    

     

    If that peace of code run according to the timer, you can't add accountName as a handler function argument of DeleteVIP. You had to discover accountName variable before started running the line 8.

    • Thanks 1
  9. can you test below peace of code separately from your resource ? and tell what you think about it related to your code ? after command as /walk

    function checkPlayerMovementStyle()
        setTimer(
    	function ()
    	    value = {}
    	    value[1] = true
    	    value[2] = false
    	    setTimer(setPedControlState,50,2,getLocalPlayer(), "walk", value[1])
    	    toggleControl("walk", value[2])
    	    toggleControl("sprint", value[2])
    	    toggleControl("jump", value[2])
    	end,500,1)
    end
    addCommandHandler("walk",checkPlayerMovementStyle)

     

    • Thanks 1
  10. Try this out :

    function SETVIP (source, command, accountName)
      local account1 = getAccountName(getPlayerAccount(source))
      local serial = serial
      local nick = nick
      local time = time
      local time2 = time2
      local VIP = vip
    	local account = getAccount(accountName)
    	if getAccountPlayer(account) then
    	  local player = getAccountPlayer(account)
    		givePlayerMoney(player, 500000)
    		outputChatBox("VIP: " .. accountName, player, 255, 255, 255, true)	
    	end
    end
    addCommandHandler("setvip", SETVIP)

     

    • Thanks 1
  11. 7 hours ago, Hugo_Almeidowski said:

    It returns these:

    Bad argument @ outputChatBox Expected string at argument 1, got nil

    Bad argument @ getElementPosition Expected element at argument 1, got string 462

    Bad argument @ getElementPosition Expected element at argument 1, got string 462 (I changed the code a bit)

    Bad argument @ outputChatBox Expected string at argument 1, got nil

    Bad argument @ triggerClientEvent Expected element at argument 2, got string 462

    According to the way I think, that errors looks not received from the function that I gave you. check that carefully

  12. 1 hour ago, Hugo_Almeidowski said:

    SERVER:

    
    function createVehicleForPlayer(player, command, model)
        local x, y, z = getElementPosition(player)
        outputChatBox(model)
        y = y + 5
        if model then
            outputChatBox("Ola2")
            local veiculoCriado = createVehicle(model, x, y, z)
            local nomeVeiculo = getVehicleName(veiculoCriado)
            if veiculoCriado then
            outputChatBox(horaJ.. "Criaste um " ..corVeiculo.. nomeVeiculo.. corMJ.. " (modelo: "..corVeiculo.. model.. corMJ.. ") com sucesso.", player, isR, isG, isB, true)
            addEventHandler("onVehicleExplode", getRootElement(), notifyAboutExplosion)
            else
                outputChatBox(horaE.. corErro.. "Uso: /cv [" ..corVeiculo.. "400" ..corErro.. "-" ..corVeiculo.. "611" ..corErro.. "].", player, isR, isG, isB, true)
            end
        else
            triggerClientEvent("veiculoJanela", player)
            outputChatBox("Feito")
        end
    end
    
     addCommandHandler('cv', createVehicleForPlayer)
     addCommandHandler('criarveiculo', createVehicleForPlayer)
     addEvent("criarVeiculo", true)
     addEventHandler("criarVeiculo", resourceRoot, createVehicleForPlayer)

    If at the addEventHandler("criarVeiculo") I change resourceRoot to localPlayer, it returns this error:

    Bad argument @ 'addEventHandler' [Expected element at argument 2, got nil]

     

    In 'addEventHandler' on line 24 [ or 25 :3 ] of that code, change argument 2 from 'resourceRoot' to 'getRootElement()'.

    And try some edits like below to the function;

    function createVehicleForPlayer(player, command, model)
        if model then
          local x, y, z = getElementPosition(player)
            outputChatBox(model,player)
            y = y + 5
            outputChatBox("Ola2",player)
          local veiculoCriado = createVehicle(tonumber(model), x, y, z)
          local nomeVeiculo = getVehicleName(veiculoCriado)
            if veiculoCriado then
                outputChatBox(horaJ.. "Criaste um " ..corVeiculo.. nomeVeiculo.. corMJ.. " (modelo: "..corVeiculo.. model.. corMJ.. ") com sucesso.", player, isR, isG, isB, true)
            else
                outputChatBox(horaE.. corErro.. "Uso: /cv [" ..corVeiculo.. "400" ..corErro.. "-" ..corVeiculo.. "611" ..corErro.. "].", player, isR, isG, isB, true)
            end
        else
            triggerClientEvent(player, "veiculoJanela", player)
            outputChatBox("Feito")
        end
    end
    addEventHandler("onVehicleExplode", getRootElement(), notifyAboutExplosion)

     

  13. 19 hours ago, Overkillz said:

    mtaserver.conf

    At the end of the file

    
    <resource src="admin" startup="1" protected="0" />
        <resource src="defaultstats" startup="1" protected="0" />
        <resource src="helpmanager" startup="1" protected="0" />
        <resource src="joinquit" startup="1" protected="0" />
        <resource src="mapcycler" startup="1" protected="0" />
        <resource src="mapmanager" startup="1" protected="0" />
        <resource src="parachute" startup="1" protected="0" />
        <resource src="performancebrowser" startup="1" protected="0" />
        <resource src="reload" startup="1" protected="0" />
        <resource src="resourcebrowser" startup="1" protected="1" default="true" />
        <resource src="resourcemanager" startup="1" protected="1" />
        <resource src="scoreboard" startup="1" protected="0" />
    
    ....
    

     

    exactly that is ! But the problem is I want to get the resource names currently running on the server to add there...

  14. Hello !

              Actually the problem is, I had to restart the server. And there are number of resources running on the server now. After restarting the server, I had to start them one by one to come into the previous position :shock: Are there any scripting solution [ or another method ] that I can obtain as a solution in this occasion ?

  15. Hello !

    I suggest you to download the default admin resource and replace it with current one if you done anything to resource.

    And make sure to add your account name in Admin group of acl.xml [ <object name="user.account_name"></object>].

    Then try it again. 

    • Thanks 1
×
×
  • Create New...