Author Topic: Help With a Code  (Read 1295 times)

-problem was fixed, instead see posts below-
« Last Edit: October 10, 2014, 10:22:34 PM by Blake1 »

If there's no error on the line where the error appears then that usually means that the error is in one of the previous lines. Please post the entire script.

If there's no error on the line where the error appears then that usually means that the error is in one of the previous lines. Please post the entire script.
I worked around the formatting a bit. Here's the entire script:
Code: [Select]
serverCmdkill(%client, %target)
{
if(%client.isAdmin)
{
findclientbyname(%target).player.kill();
}
}

Alright, the problem is that you're missing the "function" keyword before the function decleration. Correct and formatted code would be:

Code: [Select]
function serverCmdkill(%client, %target)
{
    if(%client.isAdmin)
    {
        findclientbyname(%target).player.kill();
    }
}

Alright, the problem is that you're missing the "function" keyword before the function decleration. Correct and formatted code would be:
Ah, thank you. I'll try this out.

EDIT: It worked. Thank you very much.
« Last Edit: October 10, 2014, 08:28:36 PM by Blake1 »

I'm adding in a new feature but I can't seem to define %client and %target for the chatmessageall.
Code: [Select]
function serverCmdkill(%client, %target)
{
    if(%client.isAdmin)
    {

messageAll("",'\c3%target \c6was Force-Killed by \c3%client\c6.', %target.name, %client.name);
findclientbyname(%target).player.kill();
    }

    if(!%client.isAdmin)
    {
messageClient(%client, '', '\c6This command is Admin only.');
    }
}
Another problem I'm having is I don't know how to make it to where the command doesn't execute if the player is dead/hasn't spawned. Anyone know how to do this?

I'm adding in a new feature but I can't seem to define %client and %target for the chatmessageall.
I'm not sure what you mean
%client and %target look used correctly, and I don't see anything about chatmessageall

Another problem I'm having is I don't know how to make it to where the command doesn't execute if the player is dead/hasn't spawned. Anyone know how to do this?
if(isObject(%client.player))
{
    //do stuff
}

%client and %target look used correctly, and I don't see anything about chatmessageall
My bad I mean MessageAll. The %target doesn't work in the message.

EDIT:
Here's the problem.


if(isObject(%client.player))
{
    //do stuff
}
Thank you.
« Last Edit: October 10, 2014, 11:00:40 PM by Blake1 »

Replace %target and %client in the ""'s with %1 and %2 because that's how that kind of thing works i think

Replacing the %1 and %2 caused the area where target is to break.

You should just do messageAll('',"\c3" @ %target.name SPC "\c6was killed by\c3" SPC %client.name @ "\c6."); also don't forget to add in %target = findClientByName(%target); so that way %target.name will actually work.

Replacing the %1 and %2 caused the area where target is to break.
"break" doesn't mean anything
In the future, specify what doesn't work

also don't forget to add in %target = findClientByName(%target); so that way %target.name will actually work.
This is the problem though

You should just do messageAll('',"\c3" @ %target.name SPC "\c6was killed by\c3" SPC %client.name @ "\c6.");
Either way is valid, it's just preference
The way he did it is more readable to me

also don't forget to add in %target = findClientByName(%target); so that way %target.name will actually work.
Oh thank you.

I noticed you made them one entire string with the SPC (spaces) separating them. I had no idea you could do that.

Got the code working. Just going to spice a few things up here and there and I'm good to go. Thanks guys.
« Last Edit: October 12, 2014, 11:05:25 AM by Blake1 »