Author Topic: Telling if the player hasn't spawned/exists or doesn't  (Read 363 times)

Here is my code:

Code: [Select]
function serverCmdFlashKill(%client,%input)
{
if(%client.isSuperAdmin)
{
%targ = findClientByName(%input);
%targ.player.setwhiteout("9");
%targ.player.setVelocity("0 0 10");
%targ.player.kill();
%client.chatMessage("\c4You have flash killed \c3"@%targ.name@"\c4.");
}
else
{
%client.chatMessage("You must be an admin to do this command!");
}
if(!isObject(%targ.player))
{
%client.chatMessage("The player hasn't spawned yet!");
}
}
What I am trying to do is make it so that it tells whether or not they exist or
have/haven't spawned. Whenever I look at another code I just get really confused
and decide it's not worth trying to figure it out just by looking at it. Can anyone
help me out?

EDIT:
Oh, sorry for not mentioning what happens when I try this code:
It kills the player, but then it also says that the player doesn't exist.
« Last Edit: March 24, 2013, 06:37:59 PM by NAT3 »

if(isObject(%client.player))

If the playerobject exists this will return true.

Edit;

Read your code, you defined %targ inside an if statement, do it before the first if

You should do object checks before trying to run any code.

Code: [Select]
function serverCmdFlashKill(%client,%input)
{
%player = findClientByName(%input).player;

if(!isObject(%player))
{
//no player
return false;
}
else
{
//logic
}
}