Jump to content

Debug Problem


Recommended Posts

Posted

Hello,

I have problem bcz when someone is dead then spaming in debugscript 3

server.lua:5: Bad argument @ 'getElementModel' [Expected element at argument 1, got boolean] 

function cheetah(veh) 
  
for i ,v in ipairs (getElementsByType("player")) do 
veh = getPedOccupiedVehicle(v) 
local id = getElementModel ( veh ) 
if id == 415 then 
if getElementData(v,"state") == "alive" then 
local handling = getVehicleHandling(veh) 
if handling["mass"] ~= 1200 or handling["turnMass"] ~= 3000 then 
outputChatBox(getPlayerName(v).."#FA6400's mass: #FFBF961200 #FA6400/ #780000"..handling["mass"], root, 255,100,0,true) 
outputChatBox(getPlayerName(v).."#FA6400's turn mass: #FFBF963000 #FA6400/ #780000"..handling["turnMass"], root, 255,100,0,true) 
end 
end 
end 
end 
end 
addEventHandler("onVehicleDamage", getRootElement(), cheetah) 

Posted
now,
server.lua:5: Bad argument @ 'getElementModel' [Expected element at argument 1, got number '49.5'] 

Simply because you are trying to check loss model ???

loss: A float representing the amount of health the vehicle lost. so what 3B00DG4MER said is wrong

try this

function cheetah() 
    for i ,v in ipairs (getElementsByType("player")) do 
        local veh = getPedOccupiedVehicle(v) 
        if veh then  
            if veh == source then  
            local id = getElementModel ( source ) 
                if tonumber(id) == 415 then 
                    if getElementData(v,"state") == "alive" then 
                    local handling = getVehicleHandling(source) 
                        if handling["mass"] ~= 1200 or handling["turnMass"] ~= 3000 then 
                        outputChatBox(getPlayerName(v).."#FA6400's mass: #FFBF961200 #FA6400/ #780000"..handling["mass"], root, 255,100,0,true) 
                        outputChatBox(getPlayerName(v).."#FA6400's turn mass: #FFBF963000 #FA6400/ #780000"..handling["turnMass"], root, 255,100,0,true) 
                        end 
                    end 
                end 
            end 
        end 
    end  
end  
addEventHandler("onVehicleDamage", getRootElement(), cheetah) 

Note: instead of using getPedOccupiedVehicle() use getVehicleOccupant ().

Example:

function cheetah() 
    local driver = getVehicleOccupant ( source ) 
        if driver then    
            local id = getElementModel ( source ) 
                if tonumber(id) == 415 then 
                    if getElementData(driver,"state") == "alive" then 
                    local handling = getVehicleHandling(source) 
                    if handling["mass"] ~= 1200 or handling["turnMass"] ~= 3000 then 
                    outputChatBox(getPlayerName(driver).."#FA6400's mass: #FFBF961200 #FA6400/ #780000"..handling["mass"], root, 255,100,0,true) 
                    outputChatBox(getPlayerName(driver).."#FA6400's turn mass: #FFBF963000 #FA6400/ #780000"..handling["turnMass"], root, 255,100,0,true) 
                end 
            end 
        end 
    end 
end  
addEventHandler("onVehicleDamage", getRootElement(), cheetah) 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

the source of the event onVehicleDamage is the Vehicle that got damage, Why you've to define it two times ! (By Using getVehicleOccupant ().)

instead of it use source, I was wrong i thought it's a parameter but it's the source ..

SAF/SAO - 30%

Skype: Themerzoug2020

in-game name:3B00DG4MER

xOG7h1J.png

Posted
the source of the event onVehicleDamage is the Vehicle that got damage, Why you've to define it two times ! (By Using getVehicleOccupant ().)

instead of it use source, I was wrong i thought it's a parameter but it's the source ..

I think you must read the code again and again because as i can see he is trying to get the player name (line9 ; line10) more than that he is trying to check the player state "getElementData(driver,"state") " so he need to use :

Driver = getVehicleOccupant ( source ) 
or  
Driver = getVehicleController ( source ) 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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