Author Topic: Raycast's  (Read 2282 times)

Odd enough, that did work. Thank you all for the help, raycast's are a tricky subject I guess.
Your player was getting in the way of the raycast, therefore putting the %client.player as the last arguement stops the player being included in the check. And no, raycasts are super easy really.

Interesting, I would have never thought of an error like that.

containerRaycast hits containers of objects, hence the name. You're doing a search from the middle of the player (and container) so it hits it's own container.

Oh I see, thanks for explaining it.

Also, instead of making a whole new topic I was wondering if you could help me out with a command.

The following code works well, with one exception. Apparently new server commands can not inherit existing functions "Setup", such as "MessageSent". "MessageSent" uses the argument %Message and passes it as one to display on the clients that receive such a string. How would I go about doing that for the following code, I'd suspect I would have to use a For loop.

Example: "Kunit Runs _", _ being away.

Code: [Select]
function serverCmdMe(%client,%Message)
{
if($RoleplayChat == 1)
{
InitContainerRadiusSearch(%client.player.position,20,$TypeMasks::PlayerObjectType);
while((%targetobject=containerSearchNext()) !$= 0)
{
%client=%targetobject.client;
messageClient(%client,'',"\c6" @ %client.Name @ " " @ %message);
}
echo("" @ %client.Name @ " - [Me] " @ %message @ "!");
return;
}
else
{
return parent::serverCommandTeamMessageSent(%client, %message);
}
}

What the hell is the parent for?

Woops, that must have been left there from my experimenting.

Code: [Select]
package PACKAGE
{
function servercmdMessageSent(%client,%msg)
{
if(getSubStr(%msg,0,1) $= "*" && $RolePlayChat == 1)
{
%Message = getSubStr(%msg,1,strLen(%msg));
initContainerRadiusSearch(%client.player.position,20,$TypeMasks::PlayerObjectType);
while((%targetobject=containerSearchNext()) !$= 0)
{
%client=%targetobject.client;
messageClient(%client,'',"\c6" @ %client.Name @ " " @ %message);
}
echo("" @ %client.Name @ " - [Me] " @ %message @ "!");
return;
}
parent::serverCmdMessageSent(%client.%msg);
}
};
ActivatePackage(Package);
I didn't test this so I'm not sure.
Say: *MessageHere

Code: [Select]
package PACKAGE
{
function servercmdMessageSent(%client,%msg)
{
if(getSubStr(%msg,0,1) $= "*" && $RolePlayChat == 1)
{
%Message = getSubStr(%msg,1,strLen(%msg));
initContainerRadiusSearch(%client.player.position,20,$TypeMasks::PlayerObjectType);
while((%targetobject=containerSearchNext()) !$= 0)
{
%client=%targetobject.client;
messageClient(%client,'',"\c6" @ %client.Name @ " " @ %message);
}
echo("" @ %client.Name @ " - [Me] " @ %message @ "!");
return;
}
parent::serverCmdMessageSent(%client.%msg);
}
};
ActivatePackage(Package);
I didn't test this so I'm not sure.
Say: *MessageHere
You shouldn't parent it because it'll go through what it's supposed to, give you the warning that you're not in a minigame, or it'll message everyone in the minigame.

Code: [Select]
package PACKAGE
{
function servercmdMessageSent(%client,%msg)
{
if(getSubStr(%msg,0,1) $= "*" && $RolePlayChat == 1)
{
%Message = getSubStr(%msg,1,strLen(%msg));
initContainerRadiusSearch(%client.player.position,20,$TypeMasks::PlayerObjectType);
while((%targetobject=containerSearchNext()) !$= 0)
{
%client=%targetobject.client;
messageClient(%client,'',"\c6" @ %client.Name @ " " @ %message);
}
echo("" @ %client.Name @ " - [Me] " @ %message @ "!");
return;
}
parent::serverCmdMessageSent(%client.%msg);
}
};
ActivatePackage(Package);
I didn't test this so I'm not sure.
Say: *MessageHere
You shouldn't parent it because it'll go through what it's supposed to, give you the warning that you're not in a minigame, or it'll message everyone in the minigame.

A return; means the function will stop being executed, so it'll never get to the parent if the initial condition is met.

@Plornt, there is a . instead of a , between %client and %msg in the parent call.
« Last Edit: December 12, 2009, 12:04:33 PM by Ephialtes »

Well, I need it in the form of a new command, I've already got a Local Chat system working off of "serverCmdMessageSent". Also, I tried to tinker around with some of the code in that function and I didn't get any results, every time only one argument was returned.

Local Chat - This code works perfectly.

Code: [Select]

function serverCmdMessageSent(%client, %message)
{
if(!isObject(%client.player))
{
messageAll('',"\c2[Loading] \c1" @ %client.Name @ "\c6: " @ %message);
return;
}
if($RoleplayChat == 1)
{
InitContainerRadiusSearch(%client.player.position,20,$TypeMasks::PlayerObjectType);
while((%targetobject=containerSearchNext()) !$= 0)
{
%client=%targetobject.client;
messageClient(%client,'',"\c2[Local] \c3" @ %client.Name @ "\c6: " @ %message);
}
echo("" @ %client.Name @ " - [Local] " @ %message @ "!");
return;
}
else
{
return parent::serverCommandMessageSent(%client, %message);
}
}

Now what I need would be something like this.

Code: [Select]
function serverCmdMe(%client,%msg)
{
if($RoleplayChat == 1)
{
InitContainerRadiusSearch(%client.player.position,20,$TypeMasks::PlayerObjectType);
while((%targetobject=containerSearchNext()) !$= 0)
{
%client=%targetobject.client;
//Message all the clients in are with the total string the client types, just like MessageSent.
}
}
}

The only way I can do it as of right now is like so:

Code: [Select]
function serverCmdMe(%client,%m1,%m2,%m3...)
{
//PrintStuff using %m1-%mX.
}
« Last Edit: December 12, 2009, 12:19:16 PM by Desolation »

I tested out the chat to find bugs. If you are dead, [Loading] appears when you type. Make a thing that assigns a variable to you when you spawn and if that variable is true while client.player is not there, it messages as [Dead]

I tested out the chat to find bugs. If you are dead, [Loading] appears when you type. Make a thing that assigns a variable to you when you spawn and if that variable is true while client.player is not there, it messages as [Dead]
%client.hasSpawnedOnce

Ok, I fixed that bug. Any ideas on my previous post though?

You could just do
Code: [Select]
package Package
{
   function GameConnection::OnPlayerEnterGame(%client)
   {
      %client.clanPrefix = "[Local]" @ %client.clanPrefix;
      parent::OnPlayerEnterGame(%client);
   }
   function GameConnection::AutoAdminCheck(%client)
   {
      parent::AutoAdminCheck(%client);   
      %client.clanPrefix = "[Loading]" @ %client.clanPrefix;
   }
   function GameConnection::OnDeath(%this, %player, %killer, %damageType, %unknownA)
   {
       Parent::OnDeath(%this, %player, %killer, %damageType, %unknownA);
      %this.clanPrefix = "[Dead]" @ %this.clanPrefix;
   }
};
Activatepackage(Package);

So I join, spawn, and then die, my clan tags will be:
[Dead][Local][Loading]xxx

Why doesn't ANYONE preserve the original clan tags?
It's so stupid and line-wasting the way people accomplish clan-tag editing
Code: [Select]
package Package
{
    function serverCmdTeamMessageSent(%client, %text)
    {
%clanPrefix = %client.clanPrefix;

if(!%client.hasSpawnedOnce)
    %client.clanPrefix = "[Loading]"@ %client.clanPrefix;

else if(!isObject(%client.player))
    %client.clanPrefix = "[Dead]"@ %client.clanPrefix;

else
    %client.clanPrefix = "[Local]"@ %client.clanPrefix;

//regular code here

%client.clanPrefix = %clanPrefix;
    }
};
« Last Edit: December 12, 2009, 03:43:44 PM by Kalphiter »