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

Elm, you don't really need that last argument. It only exists for the use of really big objects like interiors

So if I want to see if %targetName = nothing then would i do  this?
Code: [Select]
if(%targetname = "")?

No, that would set it to nothing. To compare strings use $

so

if(%string1 $= %string2)

or

if(%string1 !$= %string2)

So if I want to see if %targetName = nothing then would i do  this?
Code: [Select]
if(%targetname = "")?
Targetname would never be blank, if we're still taking about the Raycasting.

Oh, didn't read that aiming part, lol.


Edit:

To shoot a raycast, here is the code below:

//%player should be defined above

What do you mean by that?


Targetname would never be blank, if we're still taking about the Raycasting.
Lets just say what if %potato was blank
Would that mean I would do
Code: [Select]
if(%potato $= "")
{

}
?

What do you mean by that?

It means that their should already be a %player that is defined, above that code.

It means that their should already be a %player that is defined, above that code.
Like it should be something?
like %player = Zefoo?

Oh i get it.
So would
Code: [Select]
%player = %client.player.name(); work?
« Last Edit: June 27, 2012, 08:05:13 PM by zefoo »

Like it should be something?
like %player = Zefoo?

It should be an existing player object, so if that player object is yours or anyone else's, sure.

It should be an existing player object, so if that player object is yours or anyone else's, sure.
Re read what i said above.

No, because first off, that name isn't stored to your player object, but to your client object. Secondly, the %player should be a player object, not a string.

No, because first off, that name isn't stored to your player object, but to your client object. Secondly, the %player should be a player object, not a string.
So how would i get the person typing /command's name
Code: [Select]
%player = %client.player; ?

Try learning from this:


function serverCMDShootRayCast(%client)
{
   //Define the client's variables
   //--
   %player = %client.player;
   %name = %client.name;
   //--
   
   %eyeVector = %player.getEyeVector();
   %eyePoint = %player.getEyePoint();
   %range = 100;
   %rangeScale = VectorScale(%eyeVector, %range);
   %rangeEnd = VectorAdd(%eyePoint, %rangeScale);
   %raycast = containerRayCast(%eyePoint,%rangeEnd,$TypeMasks::PlayerObjectType, %player);
   %object = %raycast.getId();

   if(isObject(%object) && %object.getClassname() $= "Player")
   {
      //Define the player who we are looking at's variables
      //--
      %objectName = %object.client.name;
      %objectClient = %object.client;
      //--
     
      messageClient(%client,'',"\c2You are looking at "@%objectName@".");
      messageClient(%objectClient,'',"\c2"@%name@" is looking at you.");
   }
}


{
   if(isObject(%object) && %object.getClassname() $= "Player")
   {
      //Define the player who we are looking at's variables
      //--
      %objectName = %object.client.name;
      %objectClient = %object.client;
      //--
     
      messageClient(%client,'',"\c2You are looking at "@%objectName@".");
      messageClient(%objectClient,'',"\c2"@%name@" is looking at you.");
   }
}

And if i wanted to see if the object im looking at is not a player or not anything i would do this right?
Code: [Select]
       if(!isObject(%object) && %object.getClassname() $= "Player")
        {
            
        }
« Last Edit: June 27, 2012, 08:22:38 PM by zefoo »

No, you should change the $TypeMasks type. Go into your console and type $Typemasks then hit Tab until you see what you want. Alternatively you can do $TypeMasks::All I believe, then configure the if statement to filter out anything you don't want.

No, you should change the $TypeMasks type. Go into your console and type $Typemasks then hit Tab until you see what you want. Alternatively you can do $TypeMasks::All I believe, then configure the if statement to filter out anything you don't want.
Would this be the compare not equal sign?
$!

Would this be the compare not equal sign?
$!

To compare strings:

$=
!$=


To compare anything else:

==
!=