Jump to content

Bad argument @ 'getElementData'


saluta

Recommended Posts

Please help ! ! !

autosalon resource
client.lua
function onClientMarkerHit (hit)
    if not getElementData(source, "byri") or getElementType(hit) ~= "player" and not isPedInVehicle(hit) then return end
    guiSetVisible(Window_CHK, true)
end
addEventHandler("onClientMarkerHit", getRootElement(), onClientMarkerHit)
Toner resource
client.lua
function MarkerHit(hitPlayer, matchingDimension)
	if getElementData (source, "isToner") == true and hitPlayer == getLocalPlayer() and isPedInVehicle(hitPlayer) then
		if getVehicleController ( getPedOccupiedVehicle(hitPlayer) ) == getLocalPlayer() and isLegalVehicle(getPedOccupiedVehicle(hitPlayer)) then
            local veh = getPedOccupiedVehicle(hitPlayer)
            if not veh then return end
            if getPedOccupiedVehicleSeat(hitPlayer) ~= 0 then return end
            triggerServerEvent("removePeds",hitPlayer, veh)
            guiSetVisible(wndToner, true)
            showCursor(true) 
            tmpDimension = getElementDimension (hitPlayer)
            tmpPosition[1],tmpPosition[2],tmpPosition[3] = getElementPosition(getPedOccupiedVehicle(hitPlayer))
            tmpPosition[4],tmpPosition[5],tmpPosition[6] = getElementRotation(getPedOccupiedVehicle(hitPlayer))
            vehicleDimensionUpdate(hitPlayer,0)
            setElementPosition (getPedOccupiedVehicle(hitPlayer),Point[1],Point[2],Point[3])
            setElementRotation (getPedOccupiedVehicle(hitPlayer),Point[4],Point[5],Point[6])
            triggerServerEvent("SES", getPedOccupiedVehicle(hitPlayer), false)
            outputChatBox("", 0, 191, 255, true)
            outputChatBox("", 0, 191, 255, true)
            outputChatBox("", 0, 191, 255, true)
            outputChatBox("", 0, 191, 255, true)
            outputChatBox("", 0, 191, 255, true)
            outputChatBox("", 0, 191, 255, true)
            outputChatBox("", 0, 191, 255, true)
            outputChatBox("", 0, 191, 255, true)
            outputChatBox("#FFFFFFRU: Добро пожаловать в тонировочный центр.", 0, 191, 255, true)
			outputChatBox("#FFFFFFEN: Welcome to the tinting center.", 0, 191, 255, true)
            outputChatBox("#FFFFFFRU: Нажмите ПКМ, чтобы скрыть/показать курсор.", 0, 191, 255, true)
			outputChatBox("#FFFFFFEN: Press RMB to hide/show cursor.", 0, 191, 255, true)
            mouseToner = true
			local gc = getElementData(localPlayer,"numToner")
			if not gc then setElementData(localPlayer,"numToner",1) end 
		end
	end
end
addEventHandler("onClientMarkerHit", getRootElement(), MarkerHit)
fuel resource
cl_gas.lua
addEventHandler ( "onClientMarkerHit", getRootElement(), function(ply)
	if ply == localPlayer then
		if getElementData(source,"fuelstation") then
			local veh = getPedOccupiedVehicle(ply)
			if veh and getVehicleController(veh) == ply	then
                if getElementData(ply,"mechanic_works") then
                    outputChatBox("RU: Введите команду /acceptfill для залива топлива",0,255,0,true)
					outputChatBox("EN: Enter the /acceptfill command to fill fuel",0,255,0,true)
                elseif getElementData(ply,"gasoline_works") then
                    for k,m in pairs(getElementsByType("marker")) do
                        if getElementData(m,"fuel:capacity") and isElementWithinMarker(veh, m) then
                            setElementData(m,"fuel:capacity",10000)
                        end
                    end
                else
                    initFuelWindow()
                end
			end
		end
	end
end)

Photo debugscript 3

Link to comment
15 hours ago, Dutchman101 said:

Please read the Advice paragraph (bottom part) in the Scripting forum guidelines topic, or else i doubt anyone can help you. We need corresponding line numbers (from debugscript to code) and the full script.

--Autosalon resource client.lua:578 line
  if not getElementData(source, "byri") or getElementType(hit) ~= "player" and not isPedInVehicle(hit) then return end
  
  --Toner client.lua:312 line
if getElementData (source, "isToner") == true and hitPlayer == getLocalPlayer() and isPedInVehicle(hitPlayer) then
    
    --Fuel resource cl_gas:44 line
if getElementData(source,"fuelstation") then

 

Link to comment
  • MTA Anti-Cheat Team

Bad argument @ 'getElementData' [Expected element at argument 1, got boolean]

In this context, (boolean) means the element which you're checking isn't valid, as it's false (which is a boolean value). Apparently you are using elementdata on markers (bad practise itself) and since you're checking element data of source (in onClientMarkerHit that is the marker itself) it probably means the marker is no longer there when the check executes.

So, most likely another piece of code (in that resource, or another) is interfering, such as destroying markers as soon it gets the chance, e.g when player enters it. This is why we still cannot help you, as you haven't posted full scripts including any other relevant ones that handle your marker stuff. For entire gamemodes or many potential culprits that is understandable though, and the reason why first learning basic scripting & debugging for yourself is a very good idea. Otherwise, you will need to put some effort in and come up with the most likely culprit to ask for further help on, if you cannot immediately spot the bug.

I guess that rather this whole thing is effort related - this type of issue is 1 of the easiest to debug, why don't you follow the leads yourself? As going this route so far isn't going anywhere, you should look at either what you tell us (or how so) in this topic or the reason you're not digging into your script. Think about the script's logic, like i described a part of it.

Link to comment
2 hours ago, Dutchman101 said:

Неверный аргумент @ 'getElementData' [ожидаемый элемент в аргументе 1, получил логическое значение]

В этом контексте (логическое) означает, что проверяемый элемент недействителен, поскольку он ложен (что является логическим значением). По-видимому, вы используете elementdata на маркерах (сама плохая практика), и поскольку вы проверяете данные элемента источникаonClientMarkerHit, который является самим маркером), это, вероятно, означает, что маркер больше не существует при выполнении проверки.

Так что, скорее всего, вмешивается другой фрагмент кода (в том или другом ресурсе), например, уничтожение маркеров, как только появляется возможность, например, когда игрок вводит его. Вот почему мы по-прежнему не можем вам помочь, поскольку вы не опубликовали полные скрипты, включая любые другие соответствующие сценарии, которые обрабатывают ваши маркеры. Для целых игровых режимов или многих потенциальных виновников это понятно, и причина, по которой сначала изучить основы написания сценариев и отладку для себя, является очень хорошей идеей. В противном случае вам нужно будет приложить некоторые усилия и найти наиболее вероятного виновника, чтобы попросить о дальнейшей помощи, если вы не можете сразу обнаружить ошибку.

Я предполагаю, что все это скорее связано с усилиями - этот тип проблемы является одной из самых простых для отладки, почему вы сами не следите за подсказками? Поскольку этот путь пока никуда не денется, вам следует взглянуть либо на то, что вы нам рассказываете (или как так) в этой теме, либо на причину, по которой вы не копаетесь в своем скрипте. Подумайте о логике сценария, как будто я описал ее часть.

That's right, I agree with you. Another resource called Vinyl Studio interferes, in general, it is to change the images on the car body. I'll strip off the vinyl code right now.

Here is the code.

Link to comment
  • MTA Anti-Cheat Team
1 hour ago, saluta said:

Help pleeease!!

This is where you should continue debugging by yourself, as i have hinted at before. It's almost becoming the same case as here (your other scripting help topic), so locked.

All you are doing is pushing the code in our face, you're not making any effort to do something by yourself with the given guidance..

  • Like 1
Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...