Blockland Forums > Modification Help
Making an event appear in-game
zmaster:
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: ---//////////////////
//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);
--- End code ---
Edit: I can enable it but when i go to use it in wrench events it is not in the AIPlayer category (bot).
MegaScientifical:
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.
zmaster:
Edit:
Ok, fixed that, but it still won't show up under the output events for the AIPlayer.
It is now
input.cs
--- Code: ---function AIplayer::aimAtPlayerByName(%this, %playerName)
{
%player = findClientByName(%playerName).player;
//Edit
if(isObject(%player))
{
%this.setAimObject(%player);
}
}
--- End code ---
Server.cs
--- Code: ---// VERSION 1.0 //
RegisterOutputEvent(AIPlayer, "aimAtPlayerByName", "String 20 20");
$MoreBotEventsLoaded = true;
exec("./input.cs");
--- End code ---
MegaScientifical:
There is more in my post than saying you don't have to package it.
zmaster:
I did change the player thing too.