View Issue Details

IDProjectCategoryView StatusLast Update
0008252Multi Theft Auto : San AndreasServerpublic2014-06-20 14:46
ReporterarranTunaAssigned Tosbx320 
PrioritynormalSeverityminorReproducibilityrandom
Status resolvedResolutionfixed 
Product Version 
Target Version1.4Fixed in Version1.4 
Summary0008252: getAccountPlayer can sometimes return an invalid element
Description

Same issue as #8230 but about accounts instead of teams.

Steps To Reproduce

function accPlayerDebugTest()
for i, acc in ipairs(getAccounts()) do
local plr = getAccountPlayer(acc)
if (plr and getElementDimension(plr)) then
end
end
end
setTimer(accPlayerDebugTest, 50, 20)

Spamming getAccountPlayer on a busy server and you'll get debug warnings from getElementDimension

TagsNo tags attached.

Activities

qaisjp

2014-06-04 13:37

administrator   ~~0020960

whatif you replace that line with:
if (isElement(plr) and getElementDimension(plr)) then

arranTuna

2014-06-04 14:08

manager   ~~0020961

Then it won't debug but the point is that we shouldn't have to cover our scripts with inefficient, unnecessary isElement checks. That encourages poor scripting practices like not dereferencing destroyed elements because you can just cover your scripts in isElement checks instead of actually dereferencing which means when element and timer IDs eventually get re-used your server becomes riddled with randomly occurring bugs.

Grafu

2014-06-04 19:15

viewer   ~~0020962

Same thing about getAttachedElements, getVehicleOccupants

sbx320

2014-06-07 19:18

administrator   ~~0020976

Test again with https://code.google.com/p/mtasa-blue/source/detail?r=6523 please.

Issue History

Date Modified Username Field Change