error in function, help!

Runbu73

Участник
Автор темы
75
2
this is the error:

Ícone Verificada pela comunidade




[ML] (error) Scarllet Rage: ...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua:926: attempt to call global 'GetBodyPartCoordinates' (a nil value)
stack traceback:
...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua: in function 'whiledo'
...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua:403: in function <...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua:245>
[ML] (error) Scarllet Rage: Script died due to an error. (2660072C)

this is code:

if vxfullped.v then
local whpos = {GetBodyPartCoordinates(8, handlePed)}
local x1, y1 = convert3DCoordsToScreen(pos[1], pos[2], pos[3])
local x2, y2 = convert3DCoordsToScreen(whpos[1], whpos[2], whpos[3])
local _, id = sampGetPlayerIdByCharHandle(handlePed)
local nick = sampGetPlayerNickname(id)
renderFontDrawText(font, nick.." | ID ["..id.."]" , x2, y2 - 50, color, -1)
end

Ícone Verificada pela comunidade
 

ChromiusJ

PARΛDIGM ΛSS
Друг
4,917
3,202
getbodypart is not built-in function,maybe you forget to add code of function?
Lua:
local ffi = require('ffi')
function getBodyPartCoordinates(id, handle)
  local pedptr = getCharPointer(handle)
  local vec = ffi.new("float[3]")
  getBonePosition(ffi.cast("void*", pedptr), vec, id, true)
  return vec[0], vec[1], vec[2]
end
 

Runbu73

Участник
Автор темы
75
2
[ML] (error) Scarllet Rage: ...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua:926: attempt to index global 'pos' (a nil value)
stack traceback:
...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua: in function 'whiledo'
...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua:403: in function <...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua:245>
[ML] (error) Scarllet Rage: Script died due to an error. (2660072C)

getbodypart não é uma função integrada, talvez você tenha esquecido de adicionar o código da função?
Lua:
local ffi = require('ffi')
função getBodyPartCoordenadas(id, identificador)
  pedptr local = getCharPointer(handle)
  local vec = ffi.new("float[3]")
  getBonePosition(ffi.cast("void*", pedptr), vec, id, true)
  retornar vec[0], vec[1], vec[2]
fim
erro
 

ChromiusJ

PARΛDIGM ΛSS
Друг
4,917
3,202
[ML] (error) Scarllet Rage: ...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua:926: attempt to index global 'pos' (a nil value)
stack traceback:
...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua: in function 'whiledo'
...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua:403: in function <...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua:245>
[ML] (error) Scarllet Rage: Script died due to an error. (2660072C)


erro
friend, translate the errors in the code, it is clear that you do not have such a variable, and therefore replace such an error with the variable in which you receive the coordinates(in your situation - whpos)
 

ChromiusJ

PARΛDIGM ΛSS
Друг
4,917
3,202
JUST rename your variable
Lua:
local pos = {GetBodyPartCoordinates(8, handlePed)} -- the previous variable was called "wh pos", as a result of which the functions did not see the variable "pos", and an error appeared
local x1, y1 = convert3DCoordsToScreen(pos[1], pos[2], pos[3])
local x2, y2 = convert3DCoordsToScreen(whpos[1], whpos[2], whpos[3])
-- Other code...
 

Runbu73

Участник
Автор темы
75
2
JUST rename your variable
Lua:
local pos = {GetBodyPartCoordinates(8, handlePed)} -- the previous variable was called "wh pos", as a result of which the functions did not see the variable "pos", and an error appeared
local x1, y1 = convert3DCoordsToScreen(pos[1], pos[2], pos[3])
local x2, y2 = convert3DCoordsToScreen(whpos[1], whpos[2], whpos[3])
-- Other code...
like this? I'm sorry.. I'm new to Lua

Ícone Verificada pela comunidade

if vxfullped.v then
local pos = {GetBodyPartCoordinates(8, handlePed)}
local x1, y1 = convert3DCoordsToScreen(pos[1], pos[2], pos[3])
local x2, y2 = convert3DCoordsToScreen(whpos[1], whpos[2], whpos[3])
local _, id = sampGetPlayerIdByCharHandle(handlePed)
local nick = sampGetPlayerNickname(id)
renderFontDrawText(font, nick.." | ID ["..id.."]" , x2, y2 - 50, color, -1)
end
 

ChromiusJ

PARΛDIGM ΛSS
Друг
4,917
3,202
Lua:
local x2, y2 = convert3DCoordsToScreen(whpos[1], whpos[2], whpos[3])
-- new variant
local x2, y2 = convert3DCoordsToScreen(pos[1], pos[2], pos[3])
like this? I'm sorry.. I'm new to Lua

Посмотреть вложение 232529
if vxfullped.v then
local pos = {GetBodyPartCoordinates(8, handlePed)}
local x1, y1 = convert3DCoordsToScreen(pos[1], pos[2], pos[3])
local x2, y2 = convert3DCoordsToScreen(whpos[1], whpos[2], whpos[3])
local _, id = sampGetPlayerIdByCharHandle(handlePed)
local nick = sampGetPlayerNickname(id)
renderFontDrawText(font, nick.." | ID ["..id.."]" , x2, y2 - 50, color, -1)
end
You forgot about this too:

Lua:
local x2, y2 = convert3DCoordsToScreen(whpos[1], whpos[2], whpos[3])
local x2, y2 = convert3DCoordsToScreen(pos[1], pos[2], pos[3]) -- NEW variant
 

Runbu73

Участник
Автор темы
75
2
You forgot about this too:

Lua:
local x2, y2 = convert3DCoordsToScreen(whpos[1], whpos[2], whpos[3])
local x2, y2 = convert3DCoordsToScreen(pos[1], pos[2], pos[3]) -- NEW variant
I'm using this:

if vxfullped.v then
local pos = {GetBodyPartCoordinates(8, handlePed)}
local x1, y1 = convert3DCoordsToScreen(pos[1], pos[2], pos[3])
local x2, y2 = convert3DCoordsToScreen(whpos[1], whpos[2], whpos[3])
local x2, y2 = convert3DCoordsToScreen(pos[1], pos[2], pos[3]) -- NEW variant
local _, id = sampGetPlayerIdByCharHandle(handlePed)
local nick = sampGetPlayerNickname(id)
renderFontDrawText(font, nick.." | ID ["..id.."]" , x2, y2 - 50, color, -1)
end

Ícone Verificada pela comunidade
 

ChromiusJ

PARΛDIGM ΛSS
Друг
4,917
3,202
I'm using this:

if vxfullped.v then
local pos = {GetBodyPartCoordinates(8, handlePed)}
local x1, y1 = convert3DCoordsToScreen(pos[1], pos[2], pos[3])
local x2, y2 = convert3DCoordsToScreen(whpos[1], whpos[2], whpos[3])
local x2, y2 = convert3DCoordsToScreen(pos[1], pos[2], pos[3]) -- NEW variant
local _, id = sampGetPlayerIdByCharHandle(handlePed)
local nick = sampGetPlayerNickname(id)
renderFontDrawText(font, nick.." | ID ["..id.."]" , x2, y2 - 50, color, -1)
end

Посмотреть вложение 232530
no, in this case you are still calling a non-existent variable, and the error will still occur
Lua:
if vxfullped.v then
local pos = {GetBodyPartCoordinates(8, handlePed)}
local x1, y1 = convert3DCoordsToScreen(pos[1], pos[2], pos[3])
local x2, y2 = convert3DCoordsToScreen(pos[1], pos[2], pos[3]) -- NEW variant
local _, id = sampGetPlayerIdByCharHandle(handlePed)
local nick = sampGetPlayerNickname(id)
renderFontDrawText(font, nick.." | ID ["..id.."]" , x2, y2 - 50, color, -1)
end
 

Runbu73

Участник
Автор темы
75
2
no, in this case you are still calling a non-existent variable, and the error will still occur
Lua:
if vxfullped.v then
local pos = {GetBodyPartCoordinates(8, handlePed)}
local x1, y1 = convert3DCoordsToScreen(pos[1], pos[2], pos[3])
local x2, y2 = convert3DCoordsToScreen(pos[1], pos[2], pos[3]) -- NEW variant
local _, id = sampGetPlayerIdByCharHandle(handlePed)
local nick = sampGetPlayerNickname(id)
renderFontDrawText(font, nick.." | ID ["..id.."]" , x2, y2 - 50, color, -1)
end
[ML] (error) Scarllet Rage: ...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua:926: attempt to call global 'GetBodyPartCoordinates' (a nil value)
stack traceback:
...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua: in function 'whiledo'
...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua:403: in function <...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua:245>
[ML] (error) Scarllet Rage: Script died due to an error. (26600BC4)

no, in this case you are still calling a non-existent variable, and the error will still occur
Lua:
if vxfullped.v then
local pos = {GetBodyPartCoordinates(8, handlePed)}
local x1, y1 = convert3DCoordsToScreen(pos[1], pos[2], pos[3])
local x2, y2 = convert3DCoordsToScreen(pos[1], pos[2], pos[3]) -- NEW variant
local _, id = sampGetPlayerIdByCharHandle(handlePed)
local nick = sampGetPlayerNickname(id)
renderFontDrawText(font, nick.." | ID ["..id.."]" , x2, y2 - 50, color, -1)
end
local ffi = require('ffi')
function getBodyPartCoordinates(id, handle)
local pedptr = getCharPointer(handle)
local vec = ffi.new("float[3]")
getBonePosition(ffi.cast("void*", pedptr), vec, id, true)
return vec[0], vec[1], vec[2]
end

Do I need to use this function?

Ícone Verificada pela comunidade
 

ChromiusJ

PARΛDIGM ΛSS
Друг
4,917
3,202
[ML] (error) Scarllet Rage: ...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua:926: attempt to call global 'GetBodyPartCoordinates' (a nil value)
stack traceback:
...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua: in function 'whiledo'
...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua:403: in function <...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua:245>
[ML] (error) Scarllet Rage: Script died due to an error. (26600BC4)


local ffi = require('ffi')
function getBodyPartCoordinates(id, handle)
local pedptr = getCharPointer(handle)
local vec = ffi.new("float[3]")
getBonePosition(ffi.cast("void*", pedptr), vec, id, true)
return vec[0], vec[1], vec[2]
end

Do I need to use this function?

Посмотреть вложение 232531
sure
 

kyrtion

Известный
660
242

Runbu73

Участник
Автор темы
75
2
[ML] (error) Scarllet Rage: ...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua:926: attempt to call global 'GetBodyPartCoordinates' (a nil value)
stack traceback:
...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua: in function 'whiledo'
...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua:403: in function <...\comed\Downloads\GTA SA\moonloader\Scarllet Rage (8).lua:245>
[ML] (error) Scarllet Rage: Script died due to an error. (26600BC4)

this error occurred

Ícone Verificada pela comunidade