Browse Source

* Fixes to the dynamic shop sample script (first part of dynamic shop fixes).
- Fixed wrong check in ::OnSellItem, causing not-enough-items condition not getting detected (since r11829).
- Fixed an exploit in ::OnSellItem, causing Zeny to be given to the player, even if the items fail to delete (since r5842).
- Fixed missing 'close' in ::OnSellItem (since r5842).
- Replaced 'end' with 'close' in ::OnBuyItem (since r5842, followup to r11829).

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@14609 54d463be-8e91-2dee-dedb-b68131a5f0ec

ai4rei 14 years ago
parent
commit
8643992d0b
2 changed files with 10 additions and 4 deletions
  1. 5 0
      Changelog-Trunk.txt
  2. 5 4
      doc/sample/npc_dynamic_shop.txt

+ 5 - 0
Changelog-Trunk.txt

@@ -1,6 +1,11 @@
 Date	Added
 
 2010/12/19
+	* Fixes to the dynamic shop sample script. [Ai4rei]
+	- Fixed wrong check in ::OnSellItem, causing not-enough-items condition not getting detected (since r11829).
+	- Fixed an exploit in ::OnSellItem, causing Zeny to be given to the player, even if the items fail to delete (since r5842).
+	- Fixed missing 'close' in ::OnSellItem (since r5842).
+	- Replaced 'end' with 'close' in ::OnBuyItem (since r5842, followup to r11829).
 	* Replaced maximum script array size literals with a define (constant). [Ai4rei]
 	- Fixed an off-by-one mistake in copyarray, allowing to copy 1 element more into the target array, than allowed (since r10813).
 2010/12/18

+ 5 - 4
doc/sample/npc_dynamic_shop.txt

@@ -7,21 +7,22 @@ end;
 
 OnSellItem:
 for(set @i, 0; @i < getarraysize(@sold_nameid); set @i, @i + 1){
-	if(countitem(@sold_nameid[@i]) < @sold_quantity[@i] && @sold_quantity[@i] <= 0){
+	if(countitem(@sold_nameid[@i]) < @sold_quantity[@i] || @sold_quantity[@i] <= 0){
 		mes "omgh4x!";
 		close;
 	}
 	if(@sold_nameid[@i] == 501){
+		delitem 501, @sold_quantity[@i];
 		set $@rpotsleft, $@rpotsleft + @sold_quantity[@i];
 		set Zeny, Zeny + @sold_quantity[@i]*20;
-		delitem 501, @sold_quantity[@i];
 	} else {
 		if(@sold_nameid[@i] == 502){
+			delitem 502, @sold_quantity[@i];
 			set $@opotsleft, $@opotsleft + @sold_quantity[@i];
 			set Zeny, Zeny + @sold_quantity[@i]*100;
-			delitem 502, @sold_quantity[@i];
 		} else {
 			mes "Sorry, I don't need your items.";
+			close;
 		}
 	}
 }
@@ -34,7 +35,7 @@ OnBuyItem:
 for(set @i, 0; @i < getarraysize(@bought_nameid); set @i, @i + 1){
 	if(@bought_quantity[@i] <= 0){
 		mes "omgh4x!";
-		end;
+		close;
 	}
 	if(@bought_nameid[@i] == 501){
 		if(@bought_quantity[@i] > $@rpotsleft){