Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*CREATE TABLE IF NOT EXISTS `restock` (
- `slotname` VARCHAR(10) NOT NULL DEFAULT '',
- `charid` INT(11) UNSIGNED NOT NULL DEFAULT '0',
- `itemid` INT(10) NOT NULL DEFAULT '0',
- `amount` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',
- `zeny` INT(40) UNSIGNED NOT NULL DEFAULT '0',
- PRIMARY KEY (`slotname`)
- ) ENGINE=MYISAM;
- */
- - script RestockNPC -1,{
- end;
- function ClearVars;
- OnSaveID:
- if(.@atcmd_parameters$[0] == "new") {
- for(set .@i,0; .@i < 3; set .@i, .@i +1){
- if(.CanRestock[.@i] != 0) {
- set .@menu$, .@menu$ + "> ^0000FF "+getitemname(.CanRestock[.@i])+" ^000000 ="+.CanRestockZ[.@i]+"z";
- set .@menu$, .@menu$ + ":";
- }
- }
- set @Restock,select(.@menu$)-1;
- mes "Введите кол-во";
- input @amount;
- switch(select("Слот 1:Слот 2:Слот 3")){
- case 1:
- query_sql("SELECT itemid FROM `restock` WHERE `charid` = '"+getcharid(0)+"' and `slotname` = '1'", @checkID);
- if(@checkID > 0) {
- query_sql("UPDATE `restock` SET `itemid` = '"+.CanRestock[@Restock]+"', `amount` = '"+@amount+"', `zeny` = '"+.CanRestockZ[@Restock]*@amount+"' WHERE `charid` = '"+getcharid(0)+"' and `slotname` = '1'");
- break;
- }
- query_sql("INSERT INTO `restock` (`slotname`,`charid`,`itemid`,`amount`,`zeny`) VALUES ('1','"+getcharid(0)+"','"+.CanRestock[@Restock]+"','"+@amount+"','"+.CanRestockZ[@Restock]*@amount+"')");
- break;
- case 2:
- query_sql("SELECT itemid FROM `restock` WHERE `charid` = '"+getcharid(0)+"' and `slotname` = '2'", @checkID2);
- if(@checkID2 > 0) {
- query_sql("UPDATE `restock` SET `itemid` = '"+.CanRestock[@Restock]+"', `amount` = '"+@amount+"', `zeny` = '"+.CanRestockZ[@Restock]*@amount+"' WHERE `charid` = '"+getcharid(0)+"' and `slotname` = '2'");
- break;
- }
- query_sql("INSERT INTO `restock` (`slotname`,`charid`,`itemid`,`amount`,`zeny`) VALUES ('2','"+getcharid(0)+"','"+.CanRestock[@Restock]+"','"+@amount+"','"+.CanRestockZ[@Restock]*@amount+"')");
- break;
- case 3:
- query_sql("SELECT itemid FROM `restock` WHERE `charid` = '"+getcharid(0)+"' and `slotname` = '3'", @checkID3);
- if(@checkID3 > 0) {
- query_sql("UPDATE `restock` SET `itemid` = '"+.CanRestock[@Restock]+"', `amount` = '"+@amount+"', `zeny` = '"+.CanRestockZ[@Restock]*@amount+"' WHERE `charid` = '"+getcharid(0)+"' and `slotname` = '3'");
- break;
- }
- query_sql("INSERT INTO `restock` (`slotname`,`charid`,`itemid`,`amount`,`zeny`) VALUES ('3','"+getcharid(0)+"','"+.CanRestock[@Restock]+"','"+@amount+"','"+.CanRestockZ[@Restock]*@amount+"')");
- break;
- }
- dispbottom "Готово.";
- end;
- } else if(.@atcmd_parameters$[0] == "1") {
- query_sql("SELECT itemid,amount,zeny FROM `restock` WHERE `charid` = '"+getcharid(0)+"' and `slotname` = '1'", @itemID, @amountID, @zenyID);
- if(checkweight(@itemID, @amountID) == 0) {
- message strcharinfo(0), "@restock failed. У Вас не хватает веса.";
- end;
- }
- if(zeny < @zenyID) {
- message strcharinfo(0), "@restock failed. У Вас не хватает зени. Нужно: "+@zenyID;
- end;
- }
- zeny -= @zenyID;
- getitem @itemID, @amountID;
- end;
- } else if(.@atcmd_parameters$[0] == "2") {
- query_sql("SELECT itemid,amount,zeny FROM `restock` WHERE `charid` = '"+getcharid(0)+"' and `slotname` = '2'", @itemID, @amountID, @zenyID);
- if(checkweight(@itemID, @amountID) == 0) {
- message strcharinfo(0), "@restock failed. У Вас не хватает веса.";
- end;
- }
- if(zeny < @zenyID) {
- message strcharinfo(0), "@restock failed. У Вас не хватает зени. Нужно: "+@zenyID;
- end;
- }
- zeny -= @zenyID;
- getitem @itemID, @amountID;
- end;
- } else if(.@atcmd_parameters$[0] == "3") {
- query_sql("SELECT itemid,amount,zeny FROM `restock` WHERE `charid` = '"+getcharid(0)+"' and `slotname` = '3'", @itemID, @amountID, @zenyID);
- if(checkweight(@itemID, @amountID) == 0) {
- message strcharinfo(0), "@restock failed. У Вас не хватает веса.";
- end;
- }
- if(zeny < @zenyID) {
- message strcharinfo(0), "@restock failed. У Вас не хватает зени. Нужно: "+@zenyID;
- end;
- }
- zeny -= @zenyID;
- getitem @itemID, @amountID;
- end;
- } else if(.@atcmd_parameters$[0] == "info") {
- ClearVars;
- query_sql("SELECT itemid,amount,zeny FROM `restock` WHERE `charid` = '"+getcharid(0)+"' and `slotname` = '1'", @itm1, @amt1, @zny1);
- query_sql("SELECT itemid,amount,zeny FROM `restock` WHERE `charid` = '"+getcharid(0)+"' and `slotname` = '2'", @itm2, @amt2, @zny2);
- query_sql("SELECT itemid,amount,zeny FROM `restock` WHERE `charid` = '"+getcharid(0)+"' and `slotname` = '3'", @itm3, @amt3, @zny3);
- dispbottom "[ Restock Info ] :::: [ Restock Info ]";
- dispbottom "~ Slot 1 - ["+getitemname(@itm1)+"/"+@amt1+"/"+@zny1+"z] ~";
- dispbottom "~ Slot 2 - ["+getitemname(@itm2)+"/"+@amt2+"/"+@zny2+"z] ~";
- dispbottom "~ Slot 3 - ["+getitemname(@itm3)+"/"+@amt3+"/"+@zny3+"z] ~";
- end;
- }
- function ClearVars {
- @itm1 = 0;
- @amt1 = 0;
- @zny1 = 0;
- @itm2 = 0;
- @amt2 = 0;
- @zny2 = 0;
- @itm3 = 0;
- @amt3 = 0;
- @zny3 = 0;
- return;
- }
- OnInit:
- setarray .CanRestock[0], 607, 502, 503;
- setarray .CanRestockZ[0], 10000, 500, 500;
- bindatcmd "restock",strnpcinfo(0)+"::OnSaveID";
- end;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement