2011年09月03日

ガチャガチャベンダーのエラーについて

こんにちは。
Drinkinsteins GAtcha Script - OSS Edition v1.0.1
というスクリプトを使わせてもらって、ガチャベンダーを作ってみたのですが、
トランス可・コピー不可の商品を入れた場合、商品がなくなっても
支払いが出来てしまいエラーとなります。
お客さんは商品が届かずお金だけ払ってしまう状態です。
ベンダーの中のオブジェクトがなくなった場合、フローティング
テキストで中身はないと表示できれば解決できると思うのですが。
どうすればよいでしょうか?よろしくお願いします。


タグ :スクリプト

同じカテゴリー(スクリプト関連)の記事画像
オブジェクトのリンクとタッチで開く扉
自動チャットを止めたい
テレポートするとアニメーションが解除される
同じカテゴリー(スクリプト関連)の記事
 テクスチェンジのHUDについて (2015-07-01 04:51)
 モール用のプリムカウンターを探しています (2014-11-29 20:09)
 連続するアニメーションの処理 (2014-08-24 03:23)
 オブジェクトの上にフローティングテキストを出す。 (2014-08-22 16:46)
 チャットログの盗聴について (2014-02-03 03:43)
 椅子に座った後で位置調整できるスクリプト (2013-03-24 16:37)

Posted by てば  at 13:45 │Comments(9)スクリプト関連

この記事へのコメント
Drinkinsteins GAtcha Script - OSS Edition v1.0.1

がないのでわからないのですが・・・
スクリプト貼ってもらえると対応しやすいです。


考え方としては
1. 最後にガチャをした後
money() の最後

2. 残りの商品の数が0だったら
if(llGetInventoryNumber==0){}

3. テキストで表示
llSetText("sold out",<1,1,1>,1);

支払い設定を解除する。
llSetPayPrice(PAY_HIDE,[PAY_HIDE,PAY_HIDE,PAY_HIDE,PAY_HIDE]);

ってかんじでいいとおもいます。
Posted by it at 2011年09月03日 14:29
訂正

2. 残りの商品の数が0だったら

if(llGetInventoryNumber==0){}
    ↓
if(llGetInventoryNumber(INVENTORY_OBJECT )==0){}
Posted by it at 2011年09月03日 14:31
それは作者に言えばいんじゃね? とは思うのですが、


 changedでinvetoryの変化を確認する。
 確認して景品の数が0ならフローティングテキストを表示。

 景品の数が0じゃ無いならフローティングテキストを消す。


こんな感じのスクリプトを追加すれば可能です。

 それでも支払い出来る事には変わらないので、商品が無くなった
ら支払えない様になっている方がいいでしょうね。例えば上記の物
でフローティングテキストを出す変わりに装置の覆いとなる様なプ
リムをrezして支払えない様にしちゃうとかね。
Posted by Maaya Yohkoh at 2011年09月03日 14:32
スクリプトの内容です。
長いですが私にはちんぷんかんぷんです><;
利用規約らしきものも、一応全文貼り付けました
it様の助言通りに改造できるか一度試してみますね
よろしくお願いします。

/////////////////////////////////////
/////////////////////////////////////
integer price = 15; //SET PRICE HERE
/////////////////////////////////////
/////////////////////////////////////
//DrinkInstein Sorbet Open Source Gatcha Script. I am releasing this code under the Simplified BSD License.
//Copyright 2010 "Drinkinstein Sorbet" All rights reserved.
//
//Redistribution and use in source and binary forms, with or without modification, are
//permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
//
//THIS SOFTWARE IS PROVIDED BY "Drinkinstein Sorbet" ``AS IS'' AND ANY EXPRESS OR IMPLIED
//WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
//FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL "Drinkinstein Sorbet OR
//CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
//CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
//SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
//ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
//NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
//ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//The views and conclusions contained in the software and documentation are those of the
//authors and should not be interpreted as representing official policies, either expressed
//or implied, of "Drinkinstein Sorbet".



key requestid;
string avatar;

default
{
state_entry()
{
llSetPayPrice(PAY_HIDE, [price ,PAY_HIDE, PAY_HIDE, PAY_HIDE]);

}
touch_start(integer number)
{
string id = llDetectedKey(0);
string scriptname = llGetScriptName();
llPlaySound("0e20b5f9-1b06-843e-446c-49fee8827448", 1.0);
llInstantMessage(id, "Click pay to play the Gatcha!");
}
money(key id, integer amount)
{
list items;
list finalitems;
string name;
string stuff;
string returnitem;
integer num = llGetInventoryNumber(INVENTORY_ALL);
integer finalnum = num - 1;
string folder = llGetObjectName();
integer i;
integer min = 0;
string scriptname = llGetScriptName();


integer random = (integer)llFrand(finalnum);
if(random == num) {
random -= 1 ;
}
for (i = 0; i < num; ++i) {
name = llGetInventoryName(INVENTORY_ALL, i);
items += name;
}
integer placeinlist = llListFindList(items, [scriptname]);
finalitems = llDeleteSubList(items, placeinlist, placeinlist);
returnitem = llList2String(finalitems, random);

integer finallen = llGetListLength( finalitems );
avatar = llKey2Name(id);

if(amount != price)
{
llInstantMessage(id, "You paid "+(string)amount+", which is the wrong amount, the price is: "+(string)price);
state default;
}
llPlaySound("0e20b5f9-1b06-843e-446c-49fee8827448", 1.0);
llSleep(2.0);
llPlaySound("81e91c22-6e1c-9cac-b6ab-7a7cab6a8a70", 1.0);
llSleep(1.5);
llInstantMessage(id, "You Purchased " + ": " + returnitem);
llGiveInventory(id, returnitem);

}
}
Posted by てば at 2011年09月03日 14:43
maayaさんのいうとおり、changeでチェックしたほうがいいですね。


integer price = 15; //SET PRICE HERE
string f_text = "sold out"; // コメント

key requestid;
string avatar;

object_check(){
if(llGetInventoryNumber(INVENTORY_OBJECT) == 0){
llSetText(f_text,<1,1,1>,1);
llSetPayPrice(PAY_HIDE,[PAY_HIDE,PAY_HIDE,PAY_HIDE,PAY_HIDE]);
}else if(llGetInventoryNumber(INVENTORY_OBJECT) != 0){
llSetText("",<1,1,1>,0);
llSetPayPrice(PAY_HIDE, [price ,PAY_HIDE, PAY_HIDE, PAY_HIDE]);
}
}

default
{
state_entry()
{
object_check();
}
touch_start(integer number)
{
string id = llDetectedKey(0);
string scriptname = llGetScriptName();
llPlaySound("0e20b5f9-1b06-843e-446c-49fee8827448", 1.0);
llInstantMessage(id, "Click pay to play the Gatcha!");
}

changed(integer change){
if(change & CHANGED_INVENTORY){
object_check();
}
}

money(key id, integer amount)
{
list items;
list finalitems;
string name;
string stuff;
string returnitem;
integer num = llGetInventoryNumber(INVENTORY_ALL);
integer finalnum = num - 1;
string folder = llGetObjectName();
integer i;
integer min = 0;
string scriptname = llGetScriptName();


integer random = (integer)llFrand(finalnum);
if(random == num) {
random -= 1 ;
}
for (i = 0; i < num; ++i) {
name = llGetInventoryName(INVENTORY_ALL, i);
items += name;
}
integer placeinlist = llListFindList(items, [scriptname]);
finalitems = llDeleteSubList(items, placeinlist, placeinlist);
returnitem = llList2String(finalitems, random);

integer finallen = llGetListLength( finalitems );
avatar = llKey2Name(id);

if(amount != price)
{
llInstantMessage(id, "You paid "+(string)amount+", which is the wrong amount, the price is: "+(string)price);
state default;
}
llPlaySound("0e20b5f9-1b06-843e-446c-49fee8827448", 1.0);
llSleep(2.0);
llPlaySound("81e91c22-6e1c-9cac-b6ab-7a7cab6a8a70", 1.0);
llSleep(1.5);
llInstantMessage(id, "You Purchased " + ": " + returnitem);
llGiveInventory(id, returnitem);

}
}
Posted by it at 2011年09月03日 15:05
すみません、やはり同じエラーが出ます
謎ですね><

Unable to give inventory: 'No item named ''.'. (在庫を与えることができない:"アイテムが名前のない''.'.)
Posted by てば at 2011年09月03日 15:42
すみません、正確には売り切れのフローティングテキストが
でないってことです@@;(最初スクリを入れたときだけ売り切れが出ます)
Posted by てば at 2011年09月03日 15:49
あらら、ほんとですね。llGiveInventory だとchange が動かないんですね。知らなかったです。すみません


integer price = 15; //SET PRICE HERE
string f_text = "sold out"; // コメント

key requestid;
string avatar;

object_check(){
if(llGetInventoryNumber(INVENTORY_OBJECT) == 0){
llSetText(f_text,<1,1,1>,1);
llSetPayPrice(PAY_HIDE,[PAY_HIDE,PAY_HIDE,PAY_HIDE,PAY_HIDE]);
}else if(llGetInventoryNumber(INVENTORY_OBJECT) != 0){
llSetText("",<1,1,1>,0);
llSetPayPrice(PAY_HIDE, [price ,PAY_HIDE, PAY_HIDE, PAY_HIDE]);
}
}

default
{
state_entry()
{
object_check();
}
touch_start(integer number)
{
string id = llDetectedKey(0);
string scriptname = llGetScriptName();
llPlaySound("0e20b5f9-1b06-843e-446c-49fee8827448", 1.0);
llInstantMessage(id, "Click pay to play the Gatcha!");
}

changed(integer change){
if(change & CHANGED_INVENTORY){
object_check();
}
}

money(key id, integer amount)
{
list items;
list finalitems;
string name;
string stuff;
string returnitem;
integer num = llGetInventoryNumber(INVENTORY_ALL);
integer finalnum = num - 1;
string folder = llGetObjectName();
integer i;
integer min = 0;
string scriptname = llGetScriptName();


integer random = (integer)llFrand(finalnum);
if(random == num) {
random -= 1 ;
}
for (i = 0; i < num; ++i) {
name = llGetInventoryName(INVENTORY_ALL, i);
items += name;
}
integer placeinlist = llListFindList(items, [scriptname]);
finalitems = llDeleteSubList(items, placeinlist, placeinlist);
returnitem = llList2String(finalitems, random);

integer finallen = llGetListLength( finalitems );
avatar = llKey2Name(id);

if(amount != price)
{
llInstantMessage(id, "You paid "+(string)amount+", which is the wrong amount, the price is: "+(string)price);
state default;
}
llPlaySound("0e20b5f9-1b06-843e-446c-49fee8827448", 1.0);
llSleep(2.0);
llPlaySound("81e91c22-6e1c-9cac-b6ab-7a7cab6a8a70", 1.0);
llSleep(1.5);
llInstantMessage(id, "You Purchased " + ": " + returnitem);
llGiveInventory(id, returnitem);
object_check();
}
}
Posted by it at 2011年09月03日 17:00
おおおお!うまくいきました!
it様、Maaya Yohkoh様、ありがとうございました!
特にit様何度もスクリプト修正していただいて
ありがとうございます^^
Posted by てば at 2011年09月03日 17:14
<ご注意>
書き込まれた内容は公開され、ブログの持ち主だけが削除できます。