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

And the or sign is || right?
|| is logical or, | is or. But, for all intensive purposes || is or.

Why is this
Code: [Select]
            %player1pos = %client.player;
            %player2pos = findclientbyname(%targetName).player;
            %distance1 = vectorDist(%player1pos.getPosition(),%player2pos.getPosition());
            %client2 = findClientByName(%targetName);

            if(%distance1 < 5)
            {
                messageClient(%client,'',"<color:ffffff>Grabbing <color:ffff00>" @ %objectName);
                %client.player.mountobject(findclientbyname(%objectName).player,0);
                %client2.messageClient(%client,'',"<color:ffff00>" @ %playername @ "<color:ffffff> grabbed you!");
            }

            if(%distance1 >= 5)
            {
                messageClient(%client,'',"<color:ffff00>" @ %objectName @ "<color:ffffff> is to far awway!");
            }
Not working?
It lets me grab the person no matter how far away they are.

Here try this:

Code: [Select]
%grabDist = 5;
%player1pos = %client.player.getPosition();
%player2pos = findclientbyname(%targetName).player.getPosition();
%distance1 = vectorDist(%player1pos,%player2pos);
%client2 = findClientByName(%targetName);

if(%distance1 < %grabDist)
{
messageClient(%client,'',"<color:ffffff>Grabbing <color:ffff00>" @ %client2.name @ " Distance: " @ %distance1);
%client.player.mountobject(findclientbyname(%targetName).player,0);
%client2.messageClient(%client,'',"<color:ffff00>" @ %client.name @ "<color:ffffff> grabbed you!");
}

if(%distance1 >= %grabDist)
{
messageClient(%client,'',"<color:ffff00>" @ %client2.name @ "<color:ffffff> is to far awway!" @ " Distance:" @ %distance1 @ " Range:" @ %grabDist);
}

Here try this:

Code: [Select]
%grabDist = 5;
%player1pos = %client.player.getPosition();
%player2pos = findclientbyname(%targetName).player.getPosition();
%distance1 = vectorDist(%player1pos,%player2pos);
%client2 = findClientByName(%targetName);

if(%distance1 < %grabDist)
{
messageClient(%client,'',"<color:ffffff>Grabbing <color:ffff00>" @ %client2.name @ " Distance: " @ %distance1);
%client.player.mountobject(findclientbyname(%targetName).player,0);
%client2.messageClient(%client,'',"<color:ffff00>" @ %client.name @ "<color:ffffff> grabbed you!");
}
else
{
messageClient(%client,'',"<color:ffff00>" @ %client2.name @ "<color:ffffff> is to far awway!" @ " Distance:" @ %distance1 @ " Range:" @ %grabDist);
}
I'm tired no need for 2 if's also.

Why does this
Code: [Select]
   %player = %client.player;
    %EyeVector = %player.getEyeVector();
    %EyePoint = %player.getEyePoint();
    %Range = 100;
    %RangeScale = VectorScale(%EyeVector, %Range);
    %RangeEnd = VectorAdd(%EyePoint, %RangeScale);
    %raycast = containerRayCast(%eyePoint,%RangeEnd,$TypeMasks::PlayerObjectType, %player);
//player attached to me here
%p2name1 = %raycast.getId();


function serverCmdDropRH(%client)
{
    %p2name1.dismount();
}
not dismount the player attached to me?

The raycast? That I guess you are trying to do has to be in a function. And you would have the call the function while looking at someone. It won't magically do raycasts for you.

The raycast? That I guess you are trying to do has to be in a function. And you would have the call the function while looking at someone. It won't magically do raycasts for you.
No so the racast is sent and works and finds a player before hand.
Why does this
Code: [Select]
   %player = %client.player;
    %EyeVector = %player.getEyeVector();
    %EyePoint = %player.getEyePoint();
    %Range = 100;
    %RangeScale = VectorScale(%EyeVector, %Range);
    %RangeEnd = VectorAdd(%EyePoint, %RangeScale);
    %raycast = containerRayCast(%eyePoint,%RangeEnd,$TypeMasks::PlayerObjectType, %player);
//player attached to me here
%p2name1 = %raycast.getId();


function serverCmdDropRH(%client)
{
    %p2name1.dismount();
}
not dismount the player attached to me?
The only part that does not work is the function serverCmdDropRH(%client) and maybe the %p2name1 = %raycast.getId(); which is also set in a function before hand.

It doesn't work because you didn't define %p2name1 anywhere

It doesn't work because you didn't define %p2name1 anywhere
%p2name1 = %raycast.getId();

Code: [Select]
if(%playerdis < 10)
{
    echo("Its ok to grab");
}
That did not work i found a way though.
NVM yes it did but i ended up doing it this way.
Code: [Select]
%tofardis = 5
i(%playerdis < %tofardis)
{
    //its ok to grab.
}
« Last Edit: June 28, 2012, 11:45:29 AM by zefoo »

You're asking a lot of questions but you still don't know how local variables work. You should probably spend some more time learning before you try to make something. We've pretty much done the entire code progressively for you throughout this entire topic.

You're asking a lot of questions but you still don't know how local variables work. You should probably spend some more time learning before you try to make something. We've pretty much done the entire code progressively for you throughout this entire topic.
So they are local variables housed in functions? If so I get that, I have programmed and scripted before in TONS of other languages.

So they are local variables housed in functions? If so I get that, I have programmed and scripted before in TONS of other languages.
Yes
This isn't the only thing though, you've made plenty of dumb mistakes in this topic and asked us what you did wrong without even bothering to check spelling

Yes
This isn't the only thing though, you've made plenty of dumb mistakes in this topic and asked us what you did wrong without even bothering to check spelling
Yea sorry it was 2:00 at night and I was tired so.
I have started trying to fix my own problems now.

Hey how do you check what is mounted to you? And even better can you check if something is mounted to node 1 or node 0?