Pick up money

Posted By: Miami305

Pick up money - 06/28/07 13:36

First of all, hi everyone, this is my first post in this forum (even if i've been visiting it every once in a while...)

So, the other day, I was on acknex ulimited as I discovered a money wdl:
http://www.coniserver.net/coni_users/web_users/pirvu/au/scripts/Money_WDL.zip

Then I wanted to test that script, so I've made a demo level (with the shooter template) and assigned an action to a dollar model... there was some errors (i've fixed some of them, thought)

here is the modified code:
Code:
 // money.wdl by Matt Fritz
// WDL Script to handle money pickups

/////////////////////////////////////////////////////////////////////////
// Sounds and variables for picking up money
SOUND money_fetch <moneyPickup.wav>; // money pickup sound (beamer.wav) from template folder
var money = 0; // money ID
var m_bill = 0; // money value

/////////////////////////////////////////////////////////////////////////
// Strings for needing and picking up money
STRING got_money1_str "Got a 1 dollar bill!";
STRING got_money5_str "Got a 5 dollar bill!";
STRING got_money10_str "Got a 10 dollar bill!";
STRING got_money20_str "Got a 20 dollar bill!";
STRING got_money50_str "Got a 50 dollar bill!";
STRING got_money100_str "Got a 100 dollar bill!";
/////////////////////////////////////////////////////////////////////////

// Desc: controls the money pickup
function _money_pickup()
{
if(EVENT_TYPE == EVENT_SCAN && indicator != _HANDLE) { return; }
if(EVENT_TYPE == EVENT_PUSH && YOU != player) { return; }

if(m_bill == 1) { money = money + 1; msg.STRING = got_money1_str; }
if(m_bill == 5) { money = money + 5; msg.STRING = got_money5_str; }
if(m_bill == 10) { money = money + 10; msg.STRING = got_money10_str; }
if(m_bill == 20) { money = money + 20; msg.STRING = got_money20_str; }
if(m_bill == 50) { money = money + 50; msg.STRING = got_money50_str; }
if(m_bill == 100) { money = money + 100; msg.STRING = got_money100_str; }
if(MY.__SILENT != ON) { show_message(); }
snd_play(money_fetch,50,0);
wait(1);
remove(ME);
}

// Assign an action to a money entity and pick up the entity and watch the results!
// Or, just use the included sprite, money.bmp

ACTION money_one
{
m_bill = 1;
MY.EVENT = _money_pickup;
item_pickup();
}

ACTION money_five
{
m_bill = 5;
MY.EVENT = _money_pickup;
item_pickup();
}

ACTION money_ten
{
m_bill = 10;
MY.EVENT = _money_pickup;
item_pickup();
}

ACTION money_twenty
{
m_bill = 20;
MY.EVENT = _money_pickup;
item_pickup();
}

ACTION money_fifty
{
m_bill = 50;
MY.EVENT = _money_pickup;
item_pickup();
}

ACTION money_hundred
{
m_bill = 100;
MY.EVENT = _money_pickup;
item_pickup();
}



It still gives errors like :
(EVENT_TYPE == EVENT_SCAN && indicator != _HANDLE) >> parameter unknown indicator

If you could help, it would be very appreciated
bye guys
Posted By: dennis

Re: Pick up money - 06/28/07 19:06


Well.....in my eyes there are many errors....but I can't say that precisely because I don't know waht's exactly in the shooter template.


I have modified it a bit...hope it works...i did not test it....

Just try out and just post the errors...I will take a look at them..;)


With your script you can only use predefined amounts of money (one, five, ten).

With the new code you can set the amount of money yourself in the WED and set a default value. Furthermore you can change the amount to 3, 8 or 154.

code:
"
//////////////////////////////////////////////////////////////////////
//
// money.wdl by Matt Fritz modified by Dennis
//
// -> WDL Script to handle money pickups
//
// version 0.1
//
//////////////////////////////////////////////////////////////////////

SOUND money_fetch <moneyPickup.wav>;

var MoneyAmountDefault = 10;

define MoneyAmount,skill50;
define Live,skill51;

string Temp_Str[1000];

function MoneyPickup_Event()
{

// Return other entities
if(EVENT_TYPE == EVENT_PUSH && YOU != player) { return; }
if(EVENT_TYPE == EVENT_ENTITY && YOU != player) { return; }

// Display it
str_for_num(Temp_Str,my.MoneyAmount);
str_cpy(msg.string,"Got");
str_cat(msg.string,Temp_Str);
str_cat(msg.string," euros/dollars");

// Player gets the money
player.MoneyAmount += my.MoneyAmount;

// Sound
snd_play(money_fetch,50,0);

// Removing through setting the "live"-skill to zero
// I think that prevents an error if your pc wants to
// access the money in its endless loop in the action-definition
wait(1);
my.Live = 0;

}

action Money_Act()
{

if(my.MoneyAmount == 0) { my.MoneyAmount = MoneyAmountDefault; }

// Init

my.Live = 1;

my.enable_push = on;
my.enable_entity = on;
my.event = MoneyPickup_Event;

// Endless loop
while(my.Live)
{

// Some item stuff....

// eg. rotating
my.pan += 1*time_step;

// or a light effect with a certain color

my.light = on;
my.red = 255;
my.green = 50;
my.blue = 50;

// add....more stuff here

wait(1);

}

// Kill...well...Remove me....
ent_remove(me);

}
"
Posted By: Miami305

Re: Pick up money - 06/28/07 21:18

First of all, thanks for your reply
So,i've tested and the script has no errors

but the problem is that character just passes through the money model: no money is added and the model doesn't disappear

Well, this is very strange.

PS: I've also tested the script with another project (the newton tutorial's car template) and it doesnt work neighter

Hope you have an idea why...
Thanks again
Posted By: Why_Do_I_Die

Re: Pick up money - 06/29/07 07:40

If the model just passes through try changing the money's push value , i.e. my.push = 10;
or something , i dont remember exactly but it should be higher or lower than the player, so try something like 20 or -20 , see if changing that value works. If not , you can also try event_impact. Thuogh I personally found using vect_dist to work very well , i.e. ,
if(vec_dist(my.x,player.x)<=5{money+=whatever;wait(1);ent_remove(me);}
I've used that before and it works very well. Good luck.
Posted By: dennis

Re: Pick up money - 06/29/07 12:45


I agree with "Why_DO_I_Die"....the vec_dist-function is a good solution although it's using more CPU...

That's why I would try changing the push value first.....
© 2023 lite-C Forums