Author Topic: Need help scripting.  (Read 6409 times)


i just skimmed through it, i didn't check for them, i assumed he already had them in considering 3 pages have gone by, mistakes like that should have already been solved

why ask

Why is this
Code: [Select]
function serverCmdKill(%client,%targetName)
{
    Echo("Killing " @ %targetname);
    if(%client.isAdmin)
    {
        findclientbyname(%targetname).player.kill();
    }
}
not working.
My Script_KillPlayer.Zip File has this in it.
description.txt
nameCheck.txt
server.cs

Inside my description.txt file i have this.
Name: Kill
Author: Zefoo

Inside my nameCheck.txt file i have this
Script_KillPlayer

Inside my server.cs file i have this
function serverCmdKill(%client,%targetName)
{
    Echo("Killing " @ %targetname);
    if(%client.isAdmin)
    {
        findclientbyname(%targetname).player.kill();
    }
}

Why is this
Code: [Select]
function serverCmdKill(%client,%targetName)
{
    Echo("Killing " @ %targetname)
    if(%client.isAdmin)
    {
        findclientbyname(%targetname).player.kill();
    }
}
not working.
My Script_KillPlayer.Zip File has this in it.
description.txt
nameCheck.txt
server.cs

Inside my description.txt file i have this.
Name: Kill
Author: Zefoo

Inside my nameCheck.txt file i have this
Script_KillPlayer

Inside my server.cs file i have this
function serverCmdKill(%client,%targetName)
{
    Echo("Killing " @ %targetname)
    if(%client.isAdmin)
    {
        findclientbyname(%targetname).player.kill();
    }
}

Did you bother reading anything we just said?

you clearly did not read the last few posts, read them again and fix the mistakes

you clearly did not read the last few posts, read them again and fix the mistakes
Sorry yea ok i did now let me test it.


It should look something like this:

function serverCMDKill(%client,%player)
{
   if(!%client.isAdmin)
      return 0;
   
   %player = findClientByName(%player).player;
   
   if(!isObject(%player))
   {
      //There is no player object with that name available
      return 0;
   }
   
   %player.kill();
   return true;
}
« Last Edit: June 27, 2012, 04:25:04 PM by elm »

IT WORKS! :D
Thanks for the help. Now let me see my other script...

Ok so how do you see if a player is on the server?
Something like "If(findClientByName(%targetname).exists)"?
« Last Edit: June 27, 2012, 04:26:36 PM by zefoo »

%client = findClientByName(%name);

if(isObject(%client))


%client = findClientByName(%name);

if(isObject(%client))


How would you find the opposite? Like if(!isObject(%client2))?


Yep, using !.
Now why does this
Code: [Select]
function serverCmdGrab(%client,%targetName)
{
    Echo(findClientByName(%targetname).name);
    %player1pos = %client.player.getPosition;
    %player2pos = findclientbyname(%targetName).player.getPosition;
    %distance1 = vectorLen(vectorSub(%player1pos,%player2pos));
    %client2 = findClientByName(%targetName);
    if(!isObject(%client2))
    {
        messageClient(%client,'',"<color:ffff00>" & %targetName & " <color:ffffff>Is not on this server.");
    }
    if(distance1 < 10)
    {
        %client.player.mountobject(findclientbyname(%targetName).player,0);
        messageClient(%client,'',"<color:ffffff>Grabbing <color:ffff00>" & %targetName);
    }
}
Send a chat message saying
Quote
0
0
Instead of saying
Code: [Select]
messageClient(%client,'',"<color:ffff00>" & %targetName & " <color:ffffff>Is not on this server.");?

NVM

You connect strings using @ not &.

Could you do something like this
Code: [Select]
Findclientbyname(%targetname).player.setmusic(AfteSchoolSpecial)or this
Code: [Select]
Findclientbyname(%targetname).player.setPos(Findclientbyname(%targetname).player.pos.X + 1, Findclientbyname(%targetname).player.pos.Y + 1, Findclientbyname(%targetname).player.pos.Z + 1)?

Also
How can you check if a say String1 is in String2?
And how can you get a list of every player on the server?
« Last Edit: June 27, 2012, 05:25:59 PM by zefoo »