Author Topic: Help with an event  (Read 1163 times)

This is the first event I made. Unfortunately it has a syntax error and I don't know what the hell to do to it. Here is the event:
Code: [Select]

Loading Add-On: Event_SpaceRP (CRC:1425376662)
Add-Ons/Event_SpaceRP/server.cs Line: 7 - Syntax error.
>>> Some error context, with ## on sides of error halt:





package SpaceRP_Events
{
^
^registerOutputEvent(##"##client", "addCredits","int -10000 10000 25", 1);
^
^function Client::addCredits(%client, %amount)
^{
^^%old = %client.credits;
^^%client.credits = (%old + %amount);
^}
^
>>> Error report complete.

ADD-ON "Event_SpaceRP" CONTAINS SYNTAX ERRORS


Can somebody please fix it? In case you need to know what I want the event do do, this is it:
This is an output event and the target is the client. This adds an integer to their "%client.credits" variable. I want, in the eventing GUI, next to the "Output Event" pull-down box, a box in which I can enter the integer which I want to add to %client.credits.



%client.credits = (%old + %amount);



%client.credits = %old + %amount;

registerOutputEvent(GameConnection,"addCredits","int -10000 10000 25", 1);

GameConnection is the Client, I think.

I don't really deal with events but that should work right.

Edit:
Give us the full server.cs file please. Giving us the console.log wont give us much information on what the problem is.

Here's the full server.cs:

Code: [Select]
package SpaceRP_Events
{

registerOutputEvent("client", "addCredits","int -10000 10000 25", 1);

function Client::addCredits(%client, %amount)
{
%old = %client.credits;
%client.credits = (%old + %amount);
}

registerOutputEvent(client, "setCredits","int -10000 10000 25", 1);

function Client::setCredits(%client, %amount)
{
%client.credits = %amount;
}

registerOutputEvent(client, "addIceCrystals","int -10000 10000 25", 1);

function Client::addIceCrystals(%client, %amount)
{
%old = %client.icecrystal;
%client.icecrystal = (%old + %amount);
}

registerOutputEvent(client, "setIceCrystals","int -10000 10000 25", 1);

function Client::setIceCrystals(%client, %amount)
{
%client.icecrystal = %amount;
}

registerOutputEvent(client, "addGold","int -10000 10000 25", 1);

function Client::addGold(%client, %amount)
{
%old = %client.gold;
%client.gold = (%old + %amount);
}

registerOutputEvent(client, "setGold","int -10000 10000 25", 1);

function Client::setGold(%client, %amount)
{
%client.gold = %amount;
}
};
activatePackage(SpaceRP_Events);


Code: [Select]
package SpaceRP_Events
{

registerOutputEvent(GameConnection, "addCredits","int -10000 10000 25", 1);

function GameConnection::addCredits(%client, %amount)
{
%old = %client.credits;
%client.credits = %old + %amount;
}

registerOutputEvent(GameConnection, "setCredits","int -10000 10000 25", 1);

function GameConnection::setCredits(%client, %amount)
{
%client.credits = %amount;
}

registerOutputEvent(GameConnection, "addIceCrystals","int -10000 10000 25", 1);

function GameConnection::addIceCrystals(%client, %amount)
{
%old = %client.icecrystal;
%client.icecrystal = %old + %amount;
}

registerOutputEvent(GameConnection, "setIceCrystals","int -10000 10000 25", 1);

function GameConnection::setIceCrystals(%client, %amount)
{
%client.icecrystal = %amount;
}

registerOutputEvent(GameConnection, "addGold","int -10000 10000 25", 1);

function GameConnection::addGold(%client, %amount)
{
%old = %client.gold;
%client.gold = %old + %amount;
}

registerOutputEvent(GameConnection, "setGold","int -10000 10000 25", 1);

function GameConnection::setGold(%client, %amount)
{
%client.gold = %amount;
}
};
activatePackage(SpaceRP_Events);

Yes, I did that, now let me see if it still has a syntax error, which it probably does.

Same error again:

Code: [Select]

Loading Add-On: Event_SpaceRP (CRC:-1416058606)
Add-Ons/Event_SpaceRP/server.cs Line: 7 - Syntax error.
>>> Some error context, with ## on sides of error halt:





package SpaceRP_Events

{

^

^registerOutputEvent(##G##ameConnection, "addCredits","int -10000 10000 25", 1);

^

^function Client::addCredits(%client, %amount)

^{

^^%old = %client.credits;

^^%client.credits = (%old + %amount);

^}

^

^registerOutputEvent(GameConnection, "setCredits","int -10000 10000 25", 1);
>>> Error report complete.

ADD-ON "Event_SpaceRP" CONTAINS SYNTAX ERRORS

Same error again:

Code: [Select]

Loading Add-On: Event_SpaceRP (CRC:-1416058606)
Add-Ons/Event_SpaceRP/server.cs Line: 7 - Syntax error.
>>> Some error context, with ## on sides of error halt:





package SpaceRP_Events

{

^

^registerOutputEvent(##G##ameConnection, "addCredits","int -10000 10000 25", 1);

^

^function Client::addCredits(%client, %amount)

^{

^^%old = %client.credits;

^^%client.credits = (%old + %amount);

^}

^

^registerOutputEvent(GameConnection, "setCredits","int -10000 10000 25", 1);
>>> Error report complete.

ADD-ON "Event_SpaceRP" CONTAINS SYNTAX ERRORS
You didn't even copy my code and use it.

You didn't even copy my code and use it.

ohh I get it now - I replaced the client argument in the registering part but didnt replace it while declaring the function.

ohh I get it now - I replaced the client argument in the registering part but didnt replace it while declaring the function.
That's not a syntax error but that is an error.

Still the same old error:
Code: [Select]
package SpaceRP_Events

{

^

^registerOutputEvent(##G##ameConnection, "addCredits","int -10000 10000 25", 1);

^

^function GameConnection::addCredits(%client, %amount)

^{

^^%old = %client.credits;

^^%client.credits = %old + %amount;

^}

^

^registerOutputEvent(GameConnection, "setCredits","int -10000 10000 25", 1);
>>> Error report complete.

ADD-ON "Event_SpaceRP" CONTAINS SYNTAX ERRORS

Maybe you should try registering the output events at the top OUTSIDE of the package

might not be the problem but remove the _ from the package's name
also you dont need to package this script
« Last Edit: August 13, 2012, 04:28:27 PM by nerraD »

might not be the problem but remove the _ from the package's name
That's certainly not the problem

ok, just didnt know if that was the problem, not really named packages with underscores