Author Topic: Making an event appear in-game  (Read 534 times)

Hi, I've been making a quick event and cannot figure out why it doesn't work.  It's supposed to be an event that makes a bot aim at the player entered with the name as a string.  When I try to run it using exec I get this error:

Invalid script


anyway here's the code:

Server.cs:

Code: [Select]
//////////////////
//Event_MoreBotz//
//////////////////
//By: Zmaster587 ( ID )

// VERSION  1.0 //


  //error("ERROR: Event_MoreBotz - required add-on Event_Bots not found");
if(!$MoreBotEventsLoaded)
{
RegisterOutputEvent(AIPlayer, "aimAtPlayerByName", "String 20 20");
$MoreBotEventsLoaded = true;
}




Package Morebot
{
function AIplayer::aimAtPlayerByName(%this, %playerName)
{
%player = findClientByName(%playerName);
if(%player != NULL)
{
%this.setAimObject(%player, Point3F(0,0,0));
}
}
}
activatePackage(Morebot);

Edit: I can enable it but when i go to use it in wrench events it is not in the AIPlayer category (bot).
« Last Edit: November 04, 2011, 02:45:20 PM by zmaster »

findClientByName only returns the client

%player = findClientByName(%playerName).player;

if(isObject(%player))

setAimObject only takes an object as the variable.

%this.setAimObject(%player);

And you don't need to package a command you are making, yourself. Especially one with such an irreplicable name.

Edit:

Ok, fixed that, but it still won't show up under the output events for the AIPlayer.

It is now

input.cs
Code: [Select]
function AIplayer::aimAtPlayerByName(%this, %playerName)
{
%player = findClientByName(%playerName).player;

               //Edit
if(isObject(%player))
{
%this.setAimObject(%player);
}
}

Server.cs
Code: [Select]
// VERSION  1.0 //



RegisterOutputEvent(AIPlayer, "aimAtPlayerByName", "String 20 20");
$MoreBotEventsLoaded = true;

exec("./input.cs");
« Last Edit: November 02, 2011, 04:37:46 PM by zmaster »

There is more in my post than saying you don't have to package it.

I did change the player thing too.

Why in the world did you move the script for that output into a file named input?

Lol, I was working on an input and forgot to change the name