[Lua] Script not working

6jorn_

Member
Joined
Jun 4, 2018
Messages
13
Reaction score
0
Location
Netherlands
Code:
function main()
  wait(5000)
  SampRegisterChatCommand("search",cmd)
end

function cmd(arg)
  if #arg == 0 then
      sampAddChatMessage(string.format("/search id"),FF0000)
  else
      ped = sampGetCharHandleBySampPlayerId(arg)
      positionX, positionY, positionZ = getCharCoordinates(ped)
      sampAddChatMessage(string.format("Coordinates are: ",positionX,positionY,positionZ),FF0000)
  end
end



What have I done wrong?


moonloader.log

it loads fine untill me getting the chars of an ID

Code:
[18:47:53.947799] (error)	PlayerFinder: opcode '00A0' call caused an unhandled exception
stack traceback:
	[C]: in function 'getCharCoordinates'
	...ckstar Games\GTA San Andreas\moonloader\playerFinder.lua:21: in function <...ckstar Games\GTA San Andreas\moonloader\playerFinder.lua:16>
[18:47:53.948812] (error)	PlayerFinder: Script died due to an error. (078B1F3C)
 

6jorn_

Member
Joined
Jun 4, 2018
Messages
13
Reaction score
0
Location
Netherlands
Made a few key changes to the program that fixed this specific issue - such as

checks if the player is online
check if charExists
adding sampGetStreamedOutPlayerPos instead of getCharCoordinates
added else to that and if result of sampGetStreamedOutPlayerPos fails try getCharCoordinates instead

EDIT: removed charExists from exclusive disjunction and is now working fully functional
 
Top