Followup to the previous commit.
// Do it
const char *name = luaL_checkstring(L, 1);
RemotePlayer *player = env->getPlayer(name);
- if (player == NULL){
- lua_pushnil(L);
- return 1;
- }
+ if (!player || player->getPeerId() == PEER_ID_INEXISTENT)
+ return 0;
PlayerSAO *sao = player->getPlayerSAO();
- if(sao == NULL){
- lua_pushnil(L);
- return 1;
- }
+ if (!sao || sao->isGone())
+ return 0;
// Put player on stack
getScriptApiBase(L)->objectrefGetOrCreate(L, sao);
return 1;