Players in zone list/table (user = nil error)

17 views
Skip to first unread message

Clifford

unread,
Feb 27, 2011, 5:37:00 PM2/27/11
to Kaneva 3D Apps
Whats the best way to get a list/table of the players currently in the
zone?

Currently, the script is using the player table template that is in
the template script 18.lua in all new apps, although its giving A LOT
of problems.

I also noticed that sometimes the kgp_arrive and kgp_depart functions
are returning "user" as nil, so I added an if user ~= nil before
adding and removing players from the table...

function kgp_arrive(user)
if user ~= nil then
addPlayer(user)
end
end
function kgp_depart(user) --when a player departs
if user ~= nil then
removePlayer(user)
end
end

My problem now though is that it doesn't always remove the players
from the table when they leave, when then means that when something
like kgp_playergetlocation is done for all users in the table, and
they are not in the zone anymore yet still in the table, it causes the
script to crash. (example below)

function kgp_timer(tick)
local x, y, z, rx, ry, rz = kgp.playergetlocation( v.id )
if y ~= nil then
if y < 0.3 then
ChangeEmoteOn(v.id)
else
ChangeEmotesOff(v.id)
end
end
end


I also tried using the example script for kgp.gamegetinstanceinfo on
the docs page, but I cant get it to returns the userID's... I am not
sure what I am doing wrong... yet I also noticed the default
"GameZone_ChooseInstance.xml" menu also doesnt work correctly
anymore... so I think it may be a bug or part of the API changed since
that menu and the documentation was done.
http://docs.kaneva.com/mediawiki/index.php/3DAPP:gamegetinstanceinfo

I then created a verification script in which the main script has to
send an object a message every 90seconds, if the object doesnt get
that message, it uses a independently created player table, like the
one in the base script, to send all the players to a temp zone... in
the temp zone there is a countdown script when then sends them back to
the main zone, which would let the scripts reset. (The problem with
this is that it doesn't always have a full list of all the players,
which means some get left behind at times, which puts the scripts in a
teleport loop... sending you from one zone to other back and forth non-
stop....)

I am at wits end, and it feels like every change I try to make to
avoid the script from crashing is one step forward and two steps
backwards. :|
Reply all
Reply to author
Forward
0 new messages