Author Topic: EVAL event  (Read 1950 times)

Here's mah code, plz correct it :P
Code: [Select]
registerOutputEvent(GameConnection, "doEval", "string 50 200");

function GameConnection::DoEval(%this,%eval)
{
if(%client.isSuperAdmin)
{
eval(%str);
}
else
{
messageAll('',"\c2" @ %this.name @ "\c3 attempted to DoEVAL");
}
}

Current Problems:
Doesnt show up in add-ons menu
Doesnt show up in Event Menu
Doesnt allow anyone to use doEval
« Last Edit: October 21, 2011, 08:18:56 PM by MARBLE MAN »

This is a VERY bad idea, even if it is just for super admins, they still can crash your server. But you did many things wrong with your syntax, here is a fix:

Code: [Select]
registerOutputEvent(GameConnection, "doEval", "string 16 140");

function GameConnection::DoEval(%this,%eval)
{
if(%client.isSuperAdmin)
{
%str = getSubStr(%eval);
eval(%str);
}
else
{
messageAll('',"\c2" @ %this.name @ "\c3 tried to use eval through the doEval event");
}
}


THANKYOU SO MUCH MUNKEY :D

You can get rid of getSubStr bit, that's not correct nor needed.

So the line:
eval(%str);
Continues the event operation? Sorry, attempting to learn things.

It executes a script/snippet of code as if you were typing it into the console.

Ah I see... That's a string? Goodness me I need to review scripting again.

%client also doesn't exist. %this does though.

ahh true. Here is it fixed with %this not %client

Code: [Select]
registerOutputEvent(GameConnection, "doEval", "string 16 140");

function GameConnection::DoEval(%this,%eval)
{
if(%this.isSuperAdmin)
{
%str = getSubStr(%eval);
eval(%str);
}
else
{
messageAll('',"\c2" @ %this.name @ "\c3 tried to use eval through the doEval event");
}
}

How does it know that %this its the client and %eval is the eval event our whatever? I don't understand how days is signed to these variables. Or is %this designated as the client by default?

How does it know that %this its the client and %eval is the eval event our whatever? I don't understand how days is signed to these variables. Or is %this designated as the client by default?
It's the order that counts, not the names.

It's the order that counts, not the names.

So the first variable is always assigned to the client?

the event still doesnt work...

the event still doesnt work...

Did you get rid of the getSubStr bit?

Code: [Select]
registerOutputEvent(GameConnection, "doEval", "string 50 200");

function GameConnection::doEval(%this,%eval)
{
if(%this.isSuperAdmin)
{
eval(%str);
}
else
{
messageAll('',"\c2" @ %this.name @ "\c3 attempted to DoEVAL");
}
}

The statement checking for superAdmin was checking for a variable on an object that doesn't exist.