Hello, i need some help with a script, i cant make it subtract the amount of COINS on the players backpack.
It does all actions, create the item if has the correct amount of coins in backpack, and if doesn't it says that you don't have enough, but when you have and create the item, it does not destroy the SCROLLPRICE from my stack.
use uo;
use os;
use basic;
use cfgfile;
include "include/attributes";
include "include/dotempmods";
include "include/itemutil";
include "include/string";
include "include/random";
include "include/objtype";
include "include/math";
include "include/utility";
include "include/myutil";
include "include/all";
Include "include/client";
Include "include/objtype";
Include "include/classes";
include "include/eventid";
include "include/npcbackpacks";
const SCROLLPRICE := 5000;
const MOEDA := UOBJ_AX_COIN;
Program belo(who)
var layout := {
"nomove",
"nodispose",
"page 0",
"resizepic 140 80 3600 750 500", // "resizepic 140 80 3600 330 340",
// texto x y z num
"text 375 100 66 0", // powerscroll stone
"text 190 540 2116 1", //AXCOINS (BOTTON)
"text 183 162 88 2", // warrior
"text 283 162 88 3", // mage
"text 383 162 88 4", // ranger
"text 483 162 88 5", // crafter
"text 583 162 88 6", // thief
"text 683 162 88 7", // bard
"text 783 162 88 8", // other
"text 275 540 2116 59", //QUANTIDADE DE AX
"button 195 145 2117 2118 0 1 0", // warrior
"button 300 145 2117 2118 0 2 1", // mage
"button 395 145 2117 2118 0 3 2", // ranger
"button 495 145 2117 2118 0 4 3", // crafter
"button 595 145 2117 2118 0 5 4", //thief
"button 695 145 2117 2118 0 6 5", //bard
"button 795 145 2117 2118 0 7 6", //other
// warrior
"page 1",
"text 198 197 1153 9", // anatomy
"text 198 237 1153 10", // fencing
"text 198 277 1153 11", // healing
"text 198 317 1153 12", // macefighting
"text 198 357 1153 13", // parrying
"text 445 197 1153 14", // swordsmanship
"text 445 237 1153 15", // tactics
"text 445 277 1153 16", // wrestling
"button 176 197 2714 2715 1 0 8",
"button 176 237 2714 2715 1 0 9",
"button 176 277 2714 2715 1 0 10",
"button 176 317 2714 2715 1 0 11",
"button 176 357 2714 2715 1 0 12",
"button 420 197 2714 2715 1 0 13",
"button 420 237 2714 2715 1 0 14",
"button 420 277 2714 2715 1 0 15",
// mage
"page 2",
"text 198 197 1153 17", // alchemy
"text 198 237 1153 18", // evalint
"text 198 277 1153 19", // inscription
"text 198 317 1153 20", // itemid
"text 198 357 1153 21", // magery
"text 445 197 1153 22", // meditation
"text 445 237 1153 23", // resistspells
"text 445 277 1153 24", // spiritspeak
"button 176 197 2714 2715 1 0 16",
"button 176 237 2714 2715 1 0 17",
"button 176 277 2714 2715 1 0 18",
"button 176 317 2714 2715 1 0 19",
"button 176 357 2714 2715 1 0 20",
"button 420 197 2714 2715 1 0 21",
"button 420 237 2714 2715 1 0 22",
"button 420 277 2714 2715 1 0 23",
// ranger
"page 3",
"text 198 197 1153 25", // animallore
"text 198 237 1153 26", // animaltaming
"text 198 277 1153 27", // archery
"text 198 317 1153 28", // camping
"text 198 357 1153 29", // cooking
"text 445 197 1153 30", // fishing
"text 445 237 1153 31", // tracking
"text 445 277 1153 32", // veterinary
"button 176 197 2714 2715 1 0 24",
"button 176 237 2714 2715 1 0 25",
"button 176 277 2714 2715 1 0 26",
"button 176 317 2714 2715 1 0 27",
"button 176 357 2714 2715 1 0 28",
"button 420 197 2714 2715 1 0 29",
"button 420 237 2714 2715 1 0 30",
"button 420 277 2714 2715 1 0 31",
//crafter
"page 4",
"text 198 197 1153 33", // armslore
"text 198 237 1153 34", // blacksmithy
"text 198 277 1153 35", // bowcraft
"text 198 317 1153 36", // carpentry
"text 198 357 1153 37", // lumberjacking
"text 445 197 1153 38", // mining
"text 445 237 1153 39", // tailoring
"text 445 277 1153 40", // tinkering
"button 176 197 2714 2715 1 0 32",
"button 176 237 2714 2715 1 0 33",
"button 176 277 2714 2715 1 0 34",
"button 176 317 2714 2715 1 0 35",
"button 176 357 2714 2715 1 0 36",
"button 420 197 2714 2715 1 0 37",
"button 420 237 2714 2715 1 0 38",
"button 420 277 2714 2715 1 0 39",
//thief
"page 5",
"text 198 197 1153 41", // detectinghidden
"text 198 237 1153 42", // hiding
"text 198 277 1153 43", // lockpicking
"text 198 317 1153 44", // poisoning
"text 198 357 1153 45", // removetrap
"text 445 197 1153 46", // snooping
"text 445 237 1153 47", // stealing
"text 445 277 1153 48", // stealth
"button 176 197 2714 2715 1 0 40",
"button 176 237 2714 2715 1 0 41",
"button 176 277 2714 2715 1 0 42",
"button 176 317 2714 2715 1 0 43",
"button 176 357 2714 2715 1 0 44",
"button 420 197 2714 2715 1 0 45",
"button 420 237 2714 2715 1 0 46",
"button 420 277 2714 2715 1 0 47",
//bard
"page 6",
"text 198 197 1153 49", // begging
"text 198 237 1153 50", // cartography
"text 198 277 1153 51", // enticement
"text 198 317 1153 52", // herding
"text 198 357 1153 53", // musicianship
"text 445 197 1153 54", // peacemaking
"text 445 237 1153 55", // provocation
"text 445 277 1153 56", // tasteid
"button 176 197 2714 2715 1 0 48",
"button 176 237 2714 2715 1 0 49",
"button 176 277 2714 2715 1 0 50",
"button 176 317 2714 2715 1 0 51",
"button 176 357 2714 2715 1 0 52",
"button 420 197 2714 2715 1 0 53",
"button 420 237 2714 2715 1 0 54",
"button 420 277 2714 2715 1 0 55",
"page 7",
"text 198 197 1153 57", // forensiceval
"button 176 197 2714 2715 1 0 56",
};
var data := {
"PowerScroll Selling Stone - CR-WS",
"Ax Coins : ",
"WARRIOR",
"MAGE",
"RANGER",
"CRAFTER",
"THIEF",
"BARD",
"OTHER",
//warrior
"Anatomy PowerScroll",
"Fencing PowerScroll",
"Healing PowerScroll",
"Macefighting PowerScroll",
"Parrying PowerScroll",
"Swordsmanship PowerScroll",
"Tactics PowerScroll",
"Wrestling PowerScroll",
//mage
"Alchemy PowerScroll",
"EvalInt PowerScroll",
"Inscription PowerScroll",
"ItemID PowerScroll",
"Magery PowerScroll",
"Meditation PowerScroll",
"Resisting Spells PowerScroll",
"Spirit Speak PowerScroll",
//ranger
"Animal Lore PowerScroll",
"Animal Taming PowerScroll",
"Archery PowerScroll",
"Camping PowerScroll",
"Cooking PowerScroll",
"Fishing PowerScroll",
"Traking PowerScroll",
"Veterinary PowerScroll",
//crafter
"Armslore PowerScroll",
"Blacksmithy PowerScroll",
"Bowcraft PowerScroll",
"Carpentry PowerScroll",
"Lumberjacking PowerScroll",
"Mining PowerScroll",
"Tailoring PowerScroll",
"Tinkering PowerScroll",
//thief
"Detecting Hidden PowerScroll",
"Hiding PowerScroll",
"Lockpicking PowerScroll",
"Poisoning PowerScroll",
"Remove Trap PowerScroll",
"Snooping PowerScroll",
"Stealing PowerScroll",
"Stealth PowerScroll",
//bard
"Begging PowerScroll",
"Cartography PowerScroll",
"Enticement PowerScroll",
"Herding PowerScroll",
"Musicianship PowerScroll",
"Peacemaking PowerScroll",
"Provocation PowerScroll",
"TasteID PowerScroll",
//other
"Forensic Evaluation PowerScroll",
"CR-WS",
"AX COINS: ",
};
data[60] := PlayerGold(who);
var res := SendDialogGump( who, layout, data );
If(!res[0])
SendSysMessage(who, "Cancelado.",3,1176);
Return;
EndIf
If(who.dead)
SendSysMessage(who, "Voce esta morto.",3,1176);
Return;
EndIf
Case(res[0])
1: Fun1(who); //war
2: Fun2(who); //mage
3: Fun3(who); //ranger
4: Fun4(who); //crafter
5: Fun5(who); //thief
6: Fun6(who); //bard
7: Fun7(who); //other
//warrior
8: criar(who, 0x14a4); // anatomy
9: criar(who, 0x14e6); // fencing
10: criar(who, 0x14c1); // healing
11: criar(who, 0x14e5); // macefighting
12: criar(who, 0x14a8); // parrying
13: criar(who, 0x14e4); // swords
14: criar(who, 0x14d1); // tactics
15: criar(who, 0x14e7); // wrestling
//mage
16: criar(who, 0x14a3); // alchemy
17: criar(who, 0x14c0); // evalint
18: criar(who, 0x14c7); // inscription
19: criar(who, 0x14a6); // itemid
20: criar(who, 0x14c9); // magery
21: criar(who, 0x14f0); // meditation
22: criar(who, 0x14d0); // resistspells
23: criar(who, 0x14d6); // spiritspeak
//ranger
24: criar(who, 0x14a5);// animallore
25: criar(who, 0x14d9);// animaltaming
26: criar(who, 0x14d5); // archery
27: criar(who, 0x14b3); // camping
28: criar(who, 0x14b7); // cooking
29: criar(who, 0x14c2); // fishing
30: criar(who, 0x14e2); // tracking
31: criar(who, 0x14e3); // veterinary
//crafter
32: criar(who, 0x14a7);// armslore
33: criar(who, 0x14b0);// blacksmith
34: criar(who, 0x14b1); // bowcraft
35: criar(who, 0x14b4); // carpentry
36: criar(who, 0x14e8); // lumberjacking
37: criar(who, 0x14e9); // mining
38: criar(who, 0x14d8); // tailoring
39: criar(who, 0x14e1); // tinkering
//thief
40: criar(who, 0x14b8);// dettecthidden
41: criar(who, 0x14c5);// hiding
42: criar(who, 0x14c8); // lockpicking
43: criar(who, 0x14d4); // poisoning
44: criar(who, 0x14f4); // remove trap
45: criar(who, 0x14d2); // snooping
46: criar(who, 0x14d7); // stealing
47: criar(who, 0x14f7); // stealth
//bard
48: criar(who, 0x14a9);// begging
49: criar(who, 0x14b6);// cartography
50: criar(who, 0x14b9); // enticement
51: criar(who, 0x14c4); // herding
52: criar(who, 0x14d3); // musicianship
53: criar(who, 0x14b2); // peacemaking
54: criar(who, 0x14c6); // provocation
55: criar(who, 0x14e0); // tasteID
//other
56: criar(who, 0x14c3); // forensiceval
EndCase
// funcao para retorno no gump
function PlayerGold( who )
var backpack := EnumerateItemsInContainer(who.backpack);
var axamount := 0;
foreach item in backpack
if (item.objtype == UOBJ_AX_COIN )
axamount := axamount + item.amount;
endif
endforeach
return axamount;
endfunction
//funcao criar o power scroll quando tem a quantidade de axcoins correta
function criar (who , item )
/////////////////////////////////////////////////////////////////////////////////////////
//verifica axcoins dentro da bag
var backpack := EnumerateItemsInContainer(who.backpack);
var axamount := 0;
foreach item in backpack
if (item.objtype == MOEDA )
axamount := axamount + item.amount;
endif
endforeach
//fim de verificacao
/////////////////////////////////////////////////////////////////////////////////////////
if (axamount >= SCROLLPRICE)
createiteminbackpack( who , item );
SendSysMessage(who,"You have received a PowerScroll.");
SubtractAmount(MOEDA, SCROLLPRICE );
return 1;
else
SendSysMessage(who, "You do not have " + SCROLLPRICE + " AX coins!",3,1500);
return 0;
endif
endfunction
//botoes das classes
Function Fun1(who)
EndFunction
Function Fun2(who)
EndFunction
Function Fun3(who)
EndFunction
Function Fun4(who)
EndFunction
Function Fun5(who)
EndFunction
Function Fun6(who)
EndFunction
Function Fun7(who)
EndFunction
Function Fun8(who)
EndFunction
EndProgram
POWER SCROLL STONE
Moderator: POL Developer
Re: POWER SCROLL STONE
You are using SubtractAmount and should be using ConsumeSubstance as ConsumeSubstance takes an objtype and SubtractAmount takes an item_ref.
I took some liberty in modifying two of your functions.
I uhh didn't test this but it looks correct so give it a whirl.
I took some liberty in modifying two of your functions.
Code: Select all
function PlayerGold( who )
// https://docs.polserver.com/pol100/fullfunc.php?xmlfile=uoem#FindSubstance
var objs := FindSubstance( who.backpack, UOBJ_AX_COIN, 1, 0, FINDSUBSTANCE_FIND_ALL ),
amount := 0;
foreach obj in objs
amount := amount + obj.amount
endforeach
return amount;
endfunction
function criar (who , item )
/////////////////////////////////////////////////////////////////////////////////////////
//verifica axcoins dentro da bag
// Call PlayerGold here instead of repeating essentially the same code...
var axamount := PlayerGold( who );
//fim de verificacao
/////////////////////////////////////////////////////////////////////////////////////////
if (axamount >= SCROLLPRICE)
createiteminbackpack( who , item );
SendSysMessage(who,"You have received a PowerScroll.");
// SubtractAmount(MOEDA, SCROLLPRICE );
ConsumeSubstance( who.backpack, UOBJ_AX_COIN, SCROLLPRICE );
return 1;
else
SendSysMessage(who, "You do not have " + SCROLLPRICE + " AX coins!",3,1500);
return 0;
endif
endfunction