Aller au contenu

Photo

How do you grant player money from opening placeables?(solved)


  • Veuillez vous connecter pour répondre
2 réponses à ce sujet

#1
carmadaum

carmadaum
  • Members
  • 52 messages
I'm not completely sure a script is used for this, but here we go.

Basicly the char in my mod at one point enters a bank and my plan is to use the "pile of coins" placeable inside a kind of vault. What I want is once the player clicks on the pile of coins he is granted money and then the pile disappears. I know the disappearing part is in the useful scripts in the wiki. But can anybody direct me to a place in the wiki that explains how to give the player money off of a placeable that i've missed? Or even better can someone explain this to me? It would really help. 

Thanks!

Modifié par carmadaum, 09 mai 2010 - 12:24 .


#2
Mengtzu

Mengtzu
  • Members
  • 258 messages
You want to include utility_h and use the following:



UT_AddItemToInventory(R"gen_im_copper.uti",1000);



(the last term is the number of copper, so 10 silver in this example)



I'm assuming you're already assigning a custom script to the placeable with an EVENT_TYPE_USE case or similar to make it disappear. Just put the UT_AddItemToInventory inside the same bit of script.

#3
carmadaum

carmadaum
  • Members
  • 52 messages
Thanks for the reply!



Whats funny is that I found the answer right after I posted. I knew that the useful scripts wiki had an example to get a placeable to disappear, but I hadn't look at it recently. I looked at it right after I posted only to find that it was exactly what I was looking for. It's not only an example of how to get the placeable to disappear but it also gives money to the player:



#include "wrappers_h"

void main()

{

event ev = GetCurrentEvent();

int nEventType = GetEventType(ev);

switch (nEventType)

{

case EVENT_TYPE_USE:

{

//MoveAllItems(OBJECT_SELF, GetHero());

AddCreatureMoney (1000000, GetHero(), TRUE);

Safe_Destroy_Object(OBJECT_SELF);

}

}

}