Poll

How are you?

GREAT
Good
okay
I'm ugly
lovey

Author Topic: Command Help  (Read 1259 times)

I started making a force kill script and I wanted to make it say a message when the player isn't spawned yet. And for some reason I get a syntax and the error halt is as so

Code: [Select]
^messageClient(%client, '', '\c6That player hasn't ##s##pawned yet!', %user);

I want to know whats up, I'll post the whole script here. Also, I want to know if I got the if(!isObject(%target.player)) part right so that it references the fact that they are spawned or not. Please post help if I got that wrong!

Code: [Select]
package kill
{
function servercmdkill(%client, %user)
{
if(%client.isSuperAdmin == false)
{

messageClient(%client, '', '\c6You must be a super admin to use this command.');

return;
}
if(!isObject(%target.player))
{

messageClient(%client, '', '\c6That player hasn't spawned yet!', %user);

return;
}
if(%user !$= "")
{
%target = findClientByName(%user).player;
%targetC = findClientByName(%user);
%target.kill();
messageAll("",'\c3%1 \c6was force killed by \c3%2', %targetC.name, %client.name);
messageClient(%targetC, '', '\c3%1 \c6has force killed you.', %client.name);
}
}
};
ActivatePackage(kill);

IIRC you can't put a ' in the middle of a string. I forget the little snippet to put one in.

Also, you haven't defined %target at that point. Your %target = thing down further looks fine, but you need to put it in the spawn check to make that work.

Also, you haven't defined %target at that point. Your %target = thing down further looks fine, but you need to put it in the spawn check to make that work.

So I should put the spawn check further down the line? After the %target = part?


It isn't syntaxing so that might've worked but I haven't tested it yet. Thanks so far.

I wanted to also get rid of this when I type in a players name that doesn't exist:

 was force killed by AGlass0fMilk
That player hasn't spawned yet!

Have any idea how I could fix that?

Even when they haven't spawned yet, it still does the messageAll: "(player) has been force killed by (player)

How could I cancel that?

Did you take out the return;? If there's no return then it'll just keep going through.

Oh, you want the death check in front of the actual kill, too

It says that they haven't spawned when they have... can you please help me make it so that it says "That player hasn't spawned yet" and not the message to all when they haven't spawned and when they have spawned that it doesn't say that they haven't. GAHH... It's kinda hard to explain. Please edit my script and re-post it.
« Last Edit: March 05, 2009, 09:22:18 PM by AGlass0fMilk »

Well, I'm gonna go practice guitar then go to bed, I'll continue this tomorrow if I can. Please keep posting! Good night!

Oh.

If you're going %target = findClientByName(whatever).player and later you go %target.player that might cause a problem. You're just mixing and matching two different parts here.

Code: [Select]
function servercmdkill(%client, %user)
{
if(%client.isSuperAdmin == false)
{
messageClient(%client, '', '\c6You must be a super admin to use this command.');
return;
}
if(%user !$= "")
{
%target = findClientByName(%user).player;
%targetC = findClientByName(%user);
if(isObject(%target))
{
%target.kill();
messageAll("",'\c3%1 \c6was force killed by \c3%2', %targetC.name, %client.name);
messageClient(%targetC, '', '\c3%1 \c6has force killed you.', %client.name);
}
else messageClient(%client,'','\c3That person has not spawned.");
}
}

That should work unless I messed something up

But that doesn't include the spawn check so it won't check to see if they are alive yet. It will just do the same thing won't it? I'll test it tomorrow. See ya

I stuck in the if(isObject(%target)), that's the spawn check. It actually works in reverse of yours, I suppose: yours stops the command if they're dead, while mine continues the command if they're alive.

You may also want to change the MessageAll into a MessageAllExcept.