Author Topic: Variable Events  (Read 1274 times)

1) Use VCE
2) Make a special "money" variable
3) ???
4) Profit

No confusing scripting necessary.
He wants to make a script.

He wants to make a script.

And I'm saying that he doesn't need to do that.

Just a question...
doesn't the first line override the "addItem" event?

Code: [Select]
registerOutputEvent("Player", "AddItem", "datablock ItemData", "Money" 1);

function Player::addItem(%player,%image,%client)
{
for(%i = 0; %i < %player.getDatablock().maxTools; %i++)
{
%tool = %player.tool[%i];
if(%tool == 0)
{
if(%client.money = "Money")
{
%player.tool[%i] = %image;
%player.weaponCount++;
messageClient(%client,'MsgItemPickup','',%i,%image);
break;
               }
else
return;
}
}
}

function fxDtsBrick::ifMoneyValid(%brick,%client)
{
$inputTarget_Self = %brick;
$inputTarget_Player = %client.player;
$inputTarget_Bot = %brick.vehicle;
$inputTarget_Client = %client;
$inputTarget_Minigame = getMinigameFromObject(%client);
if(%client.money >= "Money");
%brick.processInputEvent("ifMoneyValid",%client);
}

function fxDtsBrick::ifMoneyInvalid(%brick,%client)
{
$inputTarget_Self = %brick;
$inputTarget_Player = %client.player;
$inputTarget_Bot = %brick.vehicle;
$inputTarget_Client = %client;
$inputTarget_Minigame = getMinigameFromObject(%client);
if(%client.money < "Money");
%brick.processInputEvent("ifMoneyValid",%client);
}
Cleaned up the code a bit and fixed a few things, it doesn't do what you want it to do though... or work.

It would be much easier with VCE.
« Last Edit: May 19, 2011, 09:15:50 PM by Daenth »

-snip-

OP already admitted that this code was garbage that he added so it wouldn't look like a request.  I don't think he actually wants it to have anything to do with the AddItem event.

And I don't think you can do those "if" tests with strings like that.

And I'm saying that he doesn't need to do that.
He does. I think he's doing this for a scripting contest.

Also,
- Do not put ; after an if statement.
- The >= operator is for comparing integers (greater than or equal to). if(%client.money >= "Money"); You are trying to compare a string with an integer operator. I also don't think you want anything to do with a string. You should replace "Money" with something like $MyMoneyMod::maxMoney