Kolm,

$exec="$$newamount=($amount" + "$affect)"


Here is the code snippet:

code:

if len($affect)>0
$amount=$drugs[$affected]
if $amount<>0 ; if the drug exists here
$exec="$$newamount=($amount" + "$affect)"
$=execute($exec)
$drugs[$affected]=$newamount
...

if len($affect)>0

The $affect has the modifier to the price of the drug - ie *10 to increase the price or /5 to decrease it. I was going to change that to *11 so that you wouldn't notice the extra 0 appear in the price list, but never did.


$amount=$drugs[$affected]

$amount gets the current price of the affected drug: 1=Acid, 2=Coke etc


if $amount<>0 ; if the drug exists here

If the $amount is 0 then this drug is not available and you don't get the event. No point telling you that Weed is cheaper when there is no weed for sale.


$exec="$$newamount=($amount" + "$affect)"
$=execute($exec)

This is eqivalent to:
$newamount=$amount*10 or $newamount=$amount/5

but, rather than:

if $affect="*10" $newamount=$amount*10 endif
if $affect="/5" $newamount=$amount/5 endif

I did the Exec. When the exec runs, it sees:

exec("$newamount=X*10")
because the $$newamount becomes $newamount
the $amount becomes a numerical value as taken from the array $drugs
and $affect becomes "*10" or "/5"

I did this also to allow the flexability of making the *10 into *9 or *2 etc, so that you can make the price of drugs more "realistic" ie if the Columbians dusted the coast guard, the price of weed would not increase tenfold, as Canada also makes weed :P

and finally

$drugs[$affected]=$newamount

We update the $drugs array with the new price.

If you are having problems with the code, check you KiX version (I use 3.62) and put

"$$variable=$variable " get$

after every line with variable is the $variable that you are interested in monitoring. Also, try changing $= to

"EXEC code = "

before the

exec($exec)

and it will show you if any errors occur.


DrillSergeant,

go for it!


cj