GrubaS Posted May 3, 2015 Posted May 3, 2015 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)
3B00DG4MER Posted May 3, 2015 Posted May 3, 2015 remove veh = getPedOccupiedVehicle(v) cuz it's already an Parameter
GrubaS Posted May 3, 2015 Author Posted May 3, 2015 now, server.lua:5: Bad argument @ 'getElementModel' [Expected element at argument 1, got number '49.5']
Walid Posted May 3, 2015 Posted May 3, 2015 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)
3B00DG4MER Posted May 3, 2015 Posted May 3, 2015 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 ..
Walid Posted May 3, 2015 Posted May 3, 2015 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 )
3B00DG4MER Posted May 3, 2015 Posted May 3, 2015 aha so he's trying to get player that his vehicle got damage ...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now