//リクエストBOX http://test-ro.net78.net/ hugel.gat,86,168,5 script ポスト 111,{ //--------設定--------- set @name$, "[名称募集中]"; //名前 set '@MAX_NUM,10000; //最大個数 set '@MAX_Zeny,950000000; //最大金額 if ('db_first < 1) { set 'csvid$,"CSVREQUEST"; //CSVファイル set 'Margin,5; //手数料 //--------終了--------- set 'db_first, 1; } //メッセージの管理 function message { switch (getarg(0)){ case 1://初めに話したとき mes @name$; mes "こんにちわ!何をするの?"; next; break; case 2://ID検索 mes @name$; mes "調べたい名前を入力してね。"; next; break; case 3://ID検索後 mes @name$; mes "次は何する?"; next; break; case 11://依頼するとき mes @name$; mes "依頼をしたいの?"; mes "この用紙に必要事項を書いてね。"; if ('Margin) mes "あ、手数料として" + 'Margin + "%もらうからね。"; mes "---"; mes "^ff0000※注意※"; mes "IDのみ管理しているので、"; mes "属性、カード、精錬値等は消されます。"; mes "ご注意下さい。^000000"; next; break; case 12://入力事項 mes @name$; mes getarg(1) + "を入力してね。"; mes " "; break; case 13://入力確認 mes "^ff0000" + getarg(1) + "^000000でいい?"; next; break; case 14://確認 mes @name$; mes "確認するよ〜"; mes "^ff0000" + getarg(1) + "^000000を^ff0000" + getarg(3) + "z^000000で^ff0000" + getarg(2) + "^000000個"; mes "合計金額は^ff0000" + getarg(4) + "z^000000だけどいいかな?"; next; break; case 15://コメント入力 mes @name$; mes "何かコメントがあれば入れてね。"; mes "(例 : ***の***が落とします。)"; next; break; case 16://書き込み前 mes @name$; mes "じゃあ、依頼を受けるよ。"; break; case 17://書き込み完了 mes "ありがと〜。"; set '@temp$,getarg(1) + "様が" + getarg(2) + "(" + getarg(3) + ")" + "を" + getarg(5) + "zで" + getarg(4) + "個まで買い取るそうです。"; announce '@temp$,0,0x7B6BEF; break; case 18://お金が足りない mes "お金が足りないよ?"; break; case 19://アイテムがない mes "アイテムが無いみたい…"; mes "もう一回調べてから来て。"; break; case 21://依頼表示 mes @name$; mes "どれを見るの?"; next; break; case 22://内容表示 mes "依頼者:^ff0000" + getarg(1) + "^000000様"; mes "依頼品:^ff0000" + getarg(3) + "(" + getarg(2) + ")^000000"; mes "個数:^ff0000" + getarg(4) + "^000000個"; mes "単価:^ff0000" + getarg(5) + "^000000z"; mes "---"; mes getarg(6); next; break; case 23://アイテム処理前 mes @name$; mes "じゃあ、もらうよ?"; mes "---"; mes "^ff0000※注意※"; mes "基本的に最大数量消されます。"; mes "同じIDのカード付や精錬品等は、"; mes "持たないようにして下さい。^000000"; next; break; case 24://処理完了 mes @name$; mes "ありがと!またよろしくね♪"; break; case 28://他の人が達成済み mes @name$; mes "依頼書が消えてる…"; mes "一足遅かったかも…"; break; case 29://アイテムがない mes @name$; mes "アイテムが無いみたい…"; mes "所持品に入れてから来て。"; break; case 31://内容表示 mes @name$; mes "^ff0000" + getarg(1) + "^000000様…"; mes "^ff0000" + getarg(3) + "(" + getarg(2) + ")^000000だったよね?"; if (getarg(5) == 0) mes "今のところ納品はないみたい…。"; else mes "今^ff0000" + getarg(5) + "^000000個届いてるわ。"; if (getarg(4) == 0) mes "全部納品されたみたい!"; else mes "残りは^ff0000" + getarg(4) + "^000000個ね。"; mes "どうする?"; next; break; case 32://アイテム処理前 mes @name$; mes "じゃあ、渡すよ?"; mes "---"; mes "^ff0000※注意※"; mes "重量チェックはしてません。"; mes "もしも持てなかった時は、"; mes "自己責任でお願いします。^000000"; next; break; case 33://処理完了(1:依頼完了 0:依頼継続) mes @name$; mes "ありがと!"; if (getarg(1) == 1) mes "これで依頼完了だね!"; else mes "依頼はこのまま継続するよ!"; mes "またよろしくね♪"; break; case 41://依頼継続 mes @name$; mes "わかった!期待して待っててね♪"; break; case 42://依頼終了 mes @name$; mes "そっか、差額はお返しするね…"; mes "ほんとにやめるの?"; next; break; case 43://依頼終了 mes @name$; mes "差額は" + getarg(1) + "zだよ。"; mes "またきてね!"; break; case 49://処理中に納品あり mes @name$; mes "あ、納品があったみたい!"; mes "もう一回話しかけて!!"; break; case 97://不正orエラー(悪意?) mes @name$; mes "あれれ?エラーだわ…"; mes "もう一回やってみて。"; break; case 98://入力数値がマイナス(悪意) mes @name$; mes "あんまりいじめないで…"; break; case 99://キャンセル mes @name$; mes "また来てね。"; break; } return; } //メイン処理 message 1; setarray @menu$,"依頼をする","依頼を見る","依頼品を受け取る","IDを調べる","やめる"; if (csvfind('csvid$, 0, strcharinfo(0)) > -1) set @menu$[0],""; else set @menu$[2],""; L_Select: switch(arrayselect(@menu$)){ case 0: goto L_Request; case 1: goto L_View; case 2: goto L_Get; case 3: message 2; input '@search$; gmcommand "@idsearch " + '@search$; message 3; goto L_Select; case 4: goto L_Cansel; } L_Request: //依頼をする //入力変数 // '@Item_ID :アイテムのID(GMコマンドでそれぞれ検索してもらう) // '@Item_NUM :アイテムの個数 // '@Item_ZENY :アイテム1個当たりの値段 // '@comment$ :コメント //格納変数 // '@Item_NAME$:アイテムのJname // '@Total_ZENY:必要なお金 //配列 // '@format$[0]:セーブ形式 message 11; while (1) { message 12,"アイテムID"; input '@Item_ID; set '@Item_NAME$,getitemname('@Item_ID); if('@Item_NAME$ == ""){ message 19; goto L_Exit; } message 13,'@Item_ID+"("+'@Item_NAME$+")"; if (select("はい","いいえ") == 1) break; } while (1) { message 12,"個数("+'@MAX_NUM+"まで)"; input '@Item_NUM; if('@Item_NUM <= 0 || '@Item_NUM >= '@MAX_NUM){ message 98; goto L_Exit; } message 13,'@Item_NUM + "個"; if (select("はい","いいえ") == 1) break; } //所持金と最大金額を比較、少ない方を採用 if ('@MAX_Zeny > Zeny) set '@MAX_Zeny, Zeny; //手数料抜き最大価格(桁あふれが怖いので、割り算を先に。) set '@MAX_Zeny,'@MAX_Zeny / '@Item_NUM / (100 + 'Margin) * 100; while (1) { message 12,"単価("+'@MAX_Zeny+"まで)"; input '@Item_ZENY; if('@Item_ZENY <= 0 || '@Item_ZENY > '@MAX_Zeny){ message 98; goto L_Exit; } message 13,'@Item_ZENY + "z"; if (select("はい","いいえ") == 1) break; } set '@Total_ZENY, ('@Item_ZENY * '@Item_NUM); set '@Total_ZENY, '@Total_ZENY + '@Total_ZENY / 100 * 'Margin; message 14 ,'@Item_NAME$,'@Item_NUM,'@Item_ZENY,'@Total_ZENY; menu "お願いします",-,"やり直す",L_Request,"やめる",L_Cansel; message 15; input '@comment$; message 16; //CSV書き込み(ロック→お金のチェック→お金の減少→CSV書き込み) while('Lock_CSV) { if (!sleep2 ( 100 )) end; //ユーザーがログアウトしてたら終了 } set 'Lock_CSV,1; if (Zeny < '@Total_ZENY){ set 'Lock_CSV,0; message 18; goto L_Exit; } set Zeny, Zeny - '@Total_ZENY; csvinsert 'csvid$, 0; setarray '@format$[0],strcharinfo(0),'@Item_ID,'@Item_NUM,'@Item_ZENY,0,'@comment$; csvwritearray 'csvid$,0,'@format$; csvflush 'csvid$; set 'Lock_CSV,0; message 17,strcharinfo(0),'@Item_NAME$,'@Item_ID,'@Item_NUM,'@Item_ZENY; goto L_Exit; L_View: //依頼を見る //格納変数 // '@CSV_Cols :CSVファイルの行数 // '@MENU_Page :メニューのページ数 // '@MENU_Cols :メニューの行数 // '@Item_ID :アイテムのID // '@Item_NAME$:アイテムのJname // '@Item_NUM :アイテムの個数 // '@Item_ZENY :アイテム1個当たりの値段 // '@comment$ :コメント //配列 // '@Client$[0]:依頼人 // '@menu$[0] :メニュー内容 //CSVからメニューを作成 message 21; while(1) { cleararray '@menu$['@MENU_Cols],"",10; setarray '@menu$[10],"戻る","次へ","やめる"; if ('@MENU_Page == 0) set '@menu$[10],""; for(set '@MENU_Cols,0;'@MENU_Cols < 10;set '@MENU_Cols,'@MENU_Cols+1) { set '@CSV_Cols, '@MENU_Page * 10 + '@MENU_Cols; //strcharinfo(0),'@Item_ID,'@Item_NUM,'@Item_ZENY,0; set '@Item_NUM,csvread('csvid$, '@CSV_Cols, 2); set '@Client$['@MENU_Cols],csvread('csvid$, '@CSV_Cols, 0); if ('@Client$['@MENU_Cols] == "" || '@Item_NUM == 0){ set '@menu$[11],""; break; } set '@Item_NAME$,getitemname(csvread('csvid$, '@CSV_Cols, 1)); set '@Item_ZENY,csvread('csvid$, '@CSV_Cols, 3); set '@menu$['@MENU_Cols],'@Item_NAME$ + "|" + '@Item_NUM + "個|" + '@Item_ZENY + "z"; } switch(arrayselect('@menu$)){ case 10: set '@MENU_Page,'@MENU_Page - 1; continue; case 11: set '@MENU_Page,'@MENU_Page + 1; continue; case 12: goto L_Cansel; default: set '@Client$,'@Client$[@menu]; } break; } //内容表示 set '@CSV_Cols, csvfind('csvid$, 0, '@Client$); set '@Item_ID, csvread('csvid$, '@CSV_Cols, 1); set '@Item_NUM, csvread('csvid$, '@CSV_Cols, 2); set '@Item_ZENY,csvread('csvid$, '@CSV_Cols, 3); set '@Comment$, csvread('csvid$, '@CSV_Cols, 5); set '@Item_NAME$,getitemname('@Item_ID); message 22,'@Client$,'@Item_ID,'@Item_NAME$,'@Item_NUM,'@Item_ZENY,'@Comment$; //選択 menu "アイテムを渡す",-,"戻る",L_View,"やめる",L_Cansel; //チェック set '@check,countitem('@Item_ID); if ('@check < 1){ message 29; goto L_Exit; } message 23; if (select("はい","いいえ") == 2) goto L_Cansel; //ここからロックして最終チェック while ('Lock_CSV) { if (!sleep2 ( 100 )) end; //ユーザーがログアウトしてたら終了 } set 'Lock_CSV,1; //再読込 CSVの行数、アイテムの募集数 set '@CSV_Cols, csvfind('csvid$, 0, '@Client$); set '@Item_NUM, csvread('csvid$, '@CSV_Cols, 2); //依頼が終了してる場合(名前がない||'@Item_IDが別のものになってる||先に納品された) if ('@CSV_Cols < 0 || '@Item_ID != csvread('csvid$, '@CSV_Cols, 1) || '@Item_NUM == 0){ set 'Lock_CSV,0; message 28; goto L_Exit; } //所持数チェック(会話中に移動させられた?) set '@check,countitem('@Item_ID); if ('@check < 1){ set 'Lock_CSV,0; message 97; goto L_Exit; } //アイテムの消去と残り数 if ('@check > '@Item_NUM) set '@check,'@Item_NUM; delitem '@Item_ID, '@check; set '@Item_NUM, '@Item_NUM - '@check; //お金の増加 set Zeny, Zeny + '@Item_ZENY * '@check; //現在の在庫の読込と増加(csvreadは文字列で読むため、一応分離) set '@Item_Get,csvread('csvid$, '@CSV_Cols, 4); set '@Item_Get,'@Item_Get + '@check; //CSV書き込み setarray '@format$[0],'@Client$,'@Item_ID,'@Item_NUM,'@Item_ZENY,'@Item_Get,'@Comment$; //募集数が0になったら末尾に移動 if ('@Item_NUM == 0){ csvdelete 'csvid$,'@CSV_Cols; set '@CSV_Cols,csvgetrows('csvid$); } csvwritearray 'csvid$,'@CSV_Cols,'@format$; csvflush 'csvid$; set 'Lock_CSV,0; message 24; goto L_Exit; L_Get: //依頼品を受け取る //格納変数 // '@CSV_Cols :CSVファイルの行数 // '@Item_ID :アイテムのID // '@Item_NAME$:アイテムのJname // '@Item_NUM :アイテムの残数 // '@Item_Get :アイテムの納品数 // '@GET_NUM :アイテムの貰う数 //配列 // '@Client$[0]:依頼人 // '@menu$[0] :メニュー内容 //CSVからメニューを作成 set '@CSV_Cols, csvfind('csvid$, 0, strcharinfo(0)); set '@Item_ID, csvread('csvid$, '@CSV_Cols, 1); set '@Item_NUM, csvread('csvid$, '@CSV_Cols, 2); set '@Item_Get, csvread('csvid$, '@CSV_Cols, 4); set '@Item_NAME$,getitemname('@Item_ID); message 31,strcharinfo(0),'@Item_ID,'@Item_NAME$,'@Item_NUM,'@Item_Get; //納品がある時 if ('@Item_Get != 0){ switch(select("全部受け取る","数量指定","やめる")){ case 1: set '@GET_NUM,'@Item_Get; break; case 2: input '@GET_NUM; if ('@GET_NUM < 1 || '@GET_NUM > '@Item_Get){ message 98; goto L_Exit; } break; case 3: goto L_Cansel; } message 32; if (select("はい","いいえ") == 2) goto L_Cansel; //ここからロック while ('Lock_CSV) { if (!sleep2 ( 100 )) end; //ユーザーがログアウトしてたら終了 } set 'Lock_CSV,1; //再読込 変動の可能性があるので行数と残り数と納品数だけ。 set '@CSV_Cols, csvfind('csvid$, 0, strcharinfo(0)); set '@Item_NUM, csvread('csvid$, '@CSV_Cols, 2); set '@Item_Get, csvread('csvid$, '@CSV_Cols, 4); //残りの計算とアイテム取得 set '@Item_Get, '@Item_Get - '@GET_NUM; gmcommand "@giveitem " + '@Item_ID + " " + '@GET_NUM + " " + strcharinfo(0); //CSV書き込み if ('@Item_Get == 0 && '@Item_NUM == 0){ //残り数と在庫が0なら行を削除 csvdelete 'csvid$,'@CSV_Cols; } else { //上記以外なら書き込み保存。読み込んでない単価とコメントを追加読み込み set '@Item_ZENY,csvread('csvid$, '@CSV_Cols, 3); set '@Comment$, csvread('csvid$, '@CSV_Cols, 5); setarray '@format$[0],strcharinfo(0),'@Item_ID,'@Item_NUM,'@Item_ZENY,'@Item_Get,'@Comment$; csvwritearray 'csvid$,'@CSV_Cols,'@format$; } csvflush 'csvid$; set 'Lock_CSV,0; message 33,('@Item_Get == 0 && '@Item_NUM == 0); goto L_Exit; } //納品が無い時 else { switch(select("依頼を継続する","依頼を終了する")){ case 1: message 41; goto L_Exit; case 2: message 42; if (select("はい","いいえ") == 2) goto L_Cansel; //ここからロック while ('Lock_CSV) { if (!sleep2 ( 100 )) end; //ユーザーがログアウトしてたら終了 } set 'Lock_CSV,1; //行数・納入・単価の再読込 納品があったら破棄取消 set '@CSV_Cols, csvfind('csvid$, 0, strcharinfo(0)); set '@Item_Get, csvread('csvid$, '@CSV_Cols, 4); if ('@Item_Get > 0){ message 49; goto L_Exit; } set '@Item_ZENY,csvread('csvid$, '@CSV_Cols, 3); //ゼニーの追加 set '@Total_ZENY,'@Item_ZENY * '@Item_NUM; set Zeny, Zeny + '@Total_ZENY; //行の削除 csvdelete 'csvid$,'@CSV_Cols; csvflush 'csvid$; set 'Lock_CSV,0; message 43,'@Total_ZENY; goto L_Exit; } } L_Cansel: message 99; L_Exit: set 'Lock_CSV,0; close2; end; }