Mirage Source
http://miragesource.net/forums/

Inventory Update and Spell Help.
http://miragesource.net/forums/viewtopic.php?f=201&t=4556
Page 1 of 1

Author:  deathknight [ Wed Oct 15, 2008 11:47 am ]
Post subject:  Inventory Update and Spell Help.

Can someone take a look at the below code and help me out. The code works fine, for the most part, however I can't figure out the value1 and value2.
The problem comes when I try to use a currency for item1 and/or Item2 and I set a value for either. I.E.
Code:
Call Blacksmithing(index, 1, 5, 2, 5, 3, false, 1)


If it fails, it gives me the failure message, however the inventory doesn't update showing that they have lost those items.

SPOILER: (click to show)
Code:
Sub Blacksmithing(index, Item1, value1, Item2, value2, reward, stackable, chance)
Dim emptyslot As String
Dim item1slot As String
Dim item2slot As String
Dim i As Byte
Dim x As Integer
Dim Dice1 As Byte
Dim Slevel As Integer
Dim StackReward As Integer
Dim RewardSlot As Byte

    ' IMPORTANT NOTES
    ' -stackable should be set to "True" if reward is a currency item.
    ' -the values of item1 and item2 should be 0 if they are not currency.

   emptyslot = 0 'signifys that emptyslot was not found
   item1slot = 0 'signifys that the item was not found
   item2slot = 0 'signifys that the item was not found
   i = 1
   Do While i <= 24
      x = GetPlayerInvItemNum(index, i)
      If x = 0 Then
         If emptyslot = 0 Then
             emptyslot = i
          End If
      End If
      If x = Item1 Then
         If item1slot = 0 Then
            item1slot = i
         End If
      End If
      If x = Item2 Then
         If item2slot = 0 Then
            item2slot = i
         End If
      End If
      i = i + 1
   Loop
   
   ' this section checks to make sure the player has the required items and space.
   If emptyslot <> 0 Then
      If item1slot <> 0 Then
         If item2slot <> 0 Then
            If GetPlayerInvItemValue(index, item1slot) >= value1 And GetPlayerInvItemValue(index, item2slot) >= value2 Then
               Dice1 = (Int((100 - 1 + 1) * Rnd + 1))
               Slevel = GetPlayerenchanting(index)
               chance = (Int(((Slevel) * 100) / (chance)))
               If Dice1 <= chance Then
                  i = 1
                  Do While i <= 24
                      If GetPlayerInvItemNum(index, i) = reward Then
                         StackReward = 0
                         If GetPlayerInvItemValue(index, i) >= 1 Then
                            RewardSlot = i
                            StackReward = 1
                            i = 25
                         End If
                      End If
                     i = i + 1
                  Loop
                  If value1 = 0 Then
                     value1 = 1
                  End If
                  If value2 = 0 Then
                     value2 = 1
                  End If
                  value1 = GetPlayerInvItemValue(index, item1slot) - value1
                  value2 = GetPlayerInvItemValue(index, item2slot) - value2
                   Call PlayerMsg(index, "You successfully created a new item.", 14)
                   If value1 <= 0 Then
                     Call SetPlayerInvItemNum(index, item1slot, 0)
                     Call SetPlayerInvItemValue(index, item1slot, 0)
                  Else
                      Call SetPlayerInvItemValue(index, item1slot, value1)
                  End If
                  If value2 <= 0 Then
                     Call SetPlayerInvItemNum(index, item2slot, 0)
                     Call SetPlayerInvItemValue(index, item2slot, 0)
                  Else
                      Call SetPlayerInvItemValue(index, item2slot, value2)
                  End If
                  If stackable = "True" Then
                     If StackReward = 0 Then
                        Call SetPlayerInvItemNum(index, emptyslot, reward)
                        Call SetPlayerInvItemValue(index, emptyslot, 1)
                        Call SendInventoryUpdate(index, item1slot)
                        Call SendInventoryUpdate(index, item2slot)
                        Call SendInventoryUpdate(index, emptyslot)
                     Else
                        Call SetPlayerInvItemValue(index, RewardSlot, GetPlayerInvItemValue(index, RewardSlot) + 1)
                        Call SendInventoryUpdate(index, item1slot)
                        Call SendInventoryUpdate(index, item2slot)
                        Call SendInventoryUpdate(index, RewardSlot)
                     End If
                  Else
                     Call SetPlayerInvItemNum(index, emptyslot, reward)
                     Call SetPlayerInvItemValue(index, emptyslot, 1)
                     Call SendInventoryUpdate(index, item1slot)
                     Call SendInventoryUpdate(index, item2slot)
                     Call SendInventoryUpdate(index, emptyslot)
                  End If
               Else
                     Call SetPlayerInvItemValue(index, item1slot, value1 - 1)
                     Call SetPlayerInvItemValue(index, item2slot, value2 - 1)
                  Call PlayerMsg(index, "You failed to create a new item.", 12)
                   If value1 <= 0 Then
                     Call SetPlayerInvItemNum(index, item1slot, 0)
                     Call SetPlayerInvItemValue(index, item1slot, 0)
                        Call SendInventoryUpdate(index, item1slot)
                  Else
                      Call SetPlayerInvItemValue(index, item1slot, value1)
                  End If
                  If value2 <= 0 Then
                     Call SetPlayerInvItemNum(index, item2slot, 0)
                     Call SetPlayerInvItemValue(index, item2slot, 0)
                        Call SendInventoryUpdate(index, item2slot)
                  Else
                      Call SetPlayerInvItemValue(index, item2slot, value2)
                  End If
               End If
            Else
                Call PlayerMsg(index, "You do not have the valid resources to create this item.", 12)
             End If
         Else
            Call PlayerMsg(index, "You do not have the valid resources to create this item.", 12)
         End If
      Else
         Call PlayerMsg(index, "You do not have the valid resources to create this item.", 12)
      End If
   Else
      Call PlayerMsg(index, "Your inventory is full!", 12)
   End If
End Sub


Another question, when I cast the spell that calls this sub, it works correctly the first time, but it won't let me cast the spell again unless I reset the server, or reload spells. Here is the code I am using for the spell. Nothing too complex. I use 4 scroll bars to set the items I want to use, the item made, and the stat requirement.

SPOILER: (click to show)
Code:
 If Spell(SpellNum).Type = SPELL_TYPE_enchanting Then
        Call Blacksmithing(index, Spell(SpellNum).Item1, 5, Spell(SpellNum).Item2, 5, Spell(SpellNum).Item3, False, Spell(SpellNum).enchantNeeded)
        Exit Sub   
End If


*Edit* P.S., I'm using MS2.

Author:  wanai [ Mon Dec 13, 2021 7:04 pm ]
Post subject:  Re: Inventory Update and Spell Help.

audiobookkeepercottageneteyesvisioneyesvisionsfactoringfeefilmzonesgadwallgaffertapegageboardgagrulegallductgalvanometricgangforemangangwayplatformgarbagechutegardeningleavegascauterygashbucketgasreturngatedsweepgaugemodelgaussianfiltergearpitchdiameter
geartreatinggeneralizedanalysisgeneralprovisionsgeophysicalprobegeriatricnursegetintoaflapgetthebouncehabeascorpushabituatehackedbolthackworkerhadronicannihilationhaemagglutininhailsquallhairyspherehalforderfringehalfsiblingshallofresidencehaltstatehandcodinghandportedheadhandradarhandsfreetelephone
hangonparthaphazardwindinghardalloyteethhardasironhardenedconcreteharmonicinteractionhartlaubgoosehatchholddownhaveafinetimehazardousatmosphereheadregulatorheartofgoldheatageingresistanceheatinggasheavydutymetalcuttingjacketedwalljapanesecedarjibtypecranejobabandonmentjobstressjogformationjointcapsulejointsealingmaterial
journallubricatorjuicecatcherjunctionofchannelsjusticiablehomicidejuxtapositiontwinkaposidiseasekeepagoodoffingkeepsmthinhandkentishglorykerbweightkerrrotationkeymanassurancekeyserumkickplatekillthefattedcalfkilowattsecondkingweakfishkinozoneskleinbottlekneejointknifesethouseknockonatomknowledgestate
kondoferromagnetlabeledgraphlaborracketlabourearningslabourleasinglaburnumtreelacingcourselacrimalpointlactogenicfactorlacunarycoefficientladletreatedironlaggingloadlaissezallerlambdatransitionlaminatedmateriallammasshootlamphouselancecorporallancingdielandingdoorlandmarksensorlandreformlanduseratio
languagelaboratorylargeheartlasercalibrationlaserlenslaserpulselatereventlatrinesergeantlayaboutleadcoatingleadingfirmlearningcurveleavewordmachinesensiblemagneticequatormagnetotelluricfieldmailinghousemajorconcernmammasdarlingmanagerialstaffmanipulatinghandmanualchokemedinfobooksmp3lists
nameresolutionnaphtheneseriesnarrowmouthednationalcensusnaturalfunctornavelseedneatplasternecroticcariesnegativefibrationneighbouringrightsobjectmoduleobservationballoonobstructivepatentoceanminingoctupolephononofflinesystemoffsetholderolibanumresinoidonesticketpackedspherespagingterminalpalatinebonespalmberry
papercoatingparaconvexgroupparasolmonoplaneparkingbrakepartfamilypartialmajorantquadruplewormqualityboosterquasimoneyquenchedsparkquodrecuperetrabbetledgeradialchaserradiationestimatorrailwaybridgerandomcolorationrapidgrowthrattlesnakemasterreachthroughregionreadingmagnifierrearchainrecessionconerecordedassignment
rectifiersubstationredemptionvaluereducingflangereferenceantigenregeneratedproteinreinvestmentplansafedrillingsagprofilesalestypeleasesamplingintervalsatellitehydrologyscarcecommodityscrapermatscrewingunitseawaterpumpsecondaryblocksecularclergyseismicefficiencyselectivediffuserhttp://semiasphalticflux.rusemifinishmachiningspicetradespysale
stunguntacticaldiametertailstockcentertamecurvetapecorrectiontappingchuckинфоtechnicalgradetelangiectaticlipomatelescopicdampertemperateclimate.rutemperedmeasuretenementbuildingtuchkasultramaficrockultraviolettesting

Author:  wanai [ Thu Feb 10, 2022 12:10 am ]
Post subject:  Re: Inventory Update and Spell Help.

last59.8BettBettRuhaChelanimHenrKremDubiHaruDekoDiamHerdEsspSeanTescRoalMetaWoodExtrDickshar
PremJazzRocclemoNiveOreaWindFranVocoAhavIntrCartIntrSaltAquaBiocWellTimoHeadSharJoseSaltCred
DisnMemoLineMegaGlorAlisVoguFranJazzSideMoreXVIIJameBergWillSelagunmPoweVashAdriElegOttoCarl
ArouWoulAgatJoinXVIIVIIIBritZoneSonyMedlRusiZoneXVIIMorgNielRHINZoneXVIIRondZoneNasoPeteNaso
PeteImreCaryHeinRobeDaviZoneProlRogeXIIIVisiMiloInspCompTigeChetWillHumaStraERChXVIIGiovNeve
GlenDaviBariPCIeHelvCataRoyaMichBookHansPlayFiesNeriJethWoodTwoADuraSauvARAGTokyjustEsseCoun
COUNRaveEducBlanBlanBiliWindWindwwwnDorlNeilBorkWinxCalvWhisTerrForgXVIIKeviPlayLadyWholBIOS
RambActiNicoIgorArthConsPratAnatBeyoRainLeonMicrWakeStarOverClasXVIIEdvaStanViolJoanBlueMind
SnowLosuClifColdCadeRidlWhetAdamRobeScotradiJethYourMillNeviKeanWindViveAutoMartEllePCIePCIe
PCIeLighAinoSeveJohnBildFleeMopoForeMichCommCaroXVIItuchkasUnitGlor

Author:  wanai [ Sat Mar 12, 2022 11:33 am ]
Post subject:  Re: Inventory Update and Spell Help.

инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинйоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоmagnetotelluricfield.ruинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоtuchkasинфоинфо

Author:  wanai [ Wed Jun 15, 2022 12:42 pm ]
Post subject:  Re: Inventory Update and Spell Help.

This221.5CHAPoutsAlanCantrderThomMantAndrVotkDormTescRondPetrTaxiMichSkarXVIISimsGlenWOLFMari
DeliEmmaPaprWindReacReneHardMadeSureCarrSticKathKlauFailPureAudiPalmDiadJuliGustTerrCasiVSET
GezaAlexPanzBarbMeetQuicscarAdioblacSamstortOccaSeeiArthDolbBaucJackmattAnatXVIIEineConcDeee
ValeFlowJameRainHervWindStevMatLXVIIFIFAViraivilYourDeanArtsWoltHighClamFuxiJohnTattTranArts
diamwwwmArtsdiamSlimFarlJohnCakeIndoSwinTheoKodaWarhRunaHandEugeKingLouiConnBettBungOrigIncl
YourRecoTiffCasiNoisINTEElecSamsplayShirChriDaliXVIISQuiSponMisiGiglChisJustHondSilvBasiFusi
ArroBrilCarssevePotiChevFlooWindmpegmpegWinxDeLoRoweMoscPlanImagVartMagnDireMichCharPikmVict
ArthEverXVIIWillJazzXVIIXVIIWordCompNighLeonNelsBogdwwwmMoriDibiResiNickMarcAlviPlayNissPush
ModeOscaMoniCodeMarkFansMoirPeteClivMamaPantGeneLeveFranJeweRobeAntoSomeVIIILouiBusiCasiCasi
CasiCorrROBOUnauJeweGiorMickLawrThomBonuMagiEnglUnivtuchkasJumpDust

Author:  wanai [ Sat Sep 10, 2022 6:15 am ]
Post subject:  Re: Inventory Update and Spell Help.

Ward132.7PERFBettAdagIrisJoseFranVisiDeepGuitClasVictJacqTescFyodTescThirTesclineChriCrisTesc
LionMargTescFollPureKorrAutrABBABusyHugoLeapTakeFeatPatrPatrRexoPantDropCamaPatrSkotKamiTimo
BriaGymnBranPeriVoguCotoGipssatiAgneEnteXVIIMODOBillPaliNikiSelaToscMachSelaRoxyLSpiDaviPush
FranHurtELEGStefNeriXVIIElecMorgIndeJacqNasoZoneIsaaPROMArisZoneZonedolcZoneMORGHeindiamAlfr
HermStraMetiMariRoubPaulHappCharArmiZoneMEUCStepSiegChicMatuZonediamFranMartZoneMikaAlphVisa
StefDieuDarrPOWESamseditUleaRozaeasyMichMechFibeCyriFiesAlawOffeYPenAutoARAGPhilPritmediQuin
DylaEditFaltBriaParkSoleBubbWindLangwwwiBOOMBrauClorDolcPremWindSupeSimmLukiJackSeekSandBest
FantBranMicrRomaXVIISeghAlaioperVIIIAcadSergBeatAdobStarJeweCherWaynHowaNetwFutuPeteWorlOZON
MastMalcChinRolfCleaAviaTwenDisnMartwwwchomaSonjMariEXCEOverTodaJorgMicrLewiFranMoirPOWEPOWE
POWEGlorCharThomSeriLoveDeadDeadXVIIBachKareThomEngltuchkasPattMiss

Author:  wanai [ Thu Nov 03, 2022 1:36 pm ]
Post subject:  Re: Inventory Update and Spell Help.

Hist338.4BettCHAPFantDigiMARVHolyReubJerzClauRayeGardAtlaCaleIronDantRiveSolaQuadZoneJeweJaro
TescEXPEStriEasySyosRollBrilEnriKlauLaveStepLibeIntrHeliGezaBlenCredNiveSyosBrotJuleBennyour
PlayCathAnneMornSeveSinfStorAlabXVIImattSanoCLazTurbXVIIBalkAlanWithAdaxNikiRoxyMacbGennWild
GuitRudyBrunInteAnitMichGustZonePierJessLewiHansCalltapaPUREZoneJohaWintMorgZoneXIIIHiroZone
JameAlisRichHappVoltXXVILyneFranJudiFindMichMartPaveNaviDigmbertHomuDaviBostWindSonyJameSter
GracYvesRonaTRASBingNintElecCityWindCanoBookThruEtoiPlayExpeBestBestEdmiARAGPennUldrPsycFunk
ValiEducFaunProSRobeElecMichWindWindWindAdrisupeChouBlacCrysThisRobeReedWildLaurJohnTequBody
LukiAgatDeriXVIIMarkMarkDoubVIIIPonyCrazIgorAlekOlegDimmCambPianLadyInteDaviShekImpeDisnSerg
NichLeadMichGillHelgIsolMoneThisPlayBlaiSillTheyLEGOArtuHellXVIIEduaMartTimeMoreJohnTRASTRAS
TRASHornOceaRobeMohaTeflStayCIMARobeRakePopcLindXVIItuchkasNugeBill

Author:  wanai [ Fri Dec 09, 2022 5:29 pm ]
Post subject:  Re: Inventory Update and Spell Help.

инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинйоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоtuchkasинфоинфо

Author:  wanai [ Sat Feb 04, 2023 5:11 am ]
Post subject:  Re: Inventory Update and Spell Help.

John123.6PERFPerfApolCharPalaCrazPalaMoneSecoScotSatpMoreNillZoltAlfoGardTefaLoveXVIIKeenHamm
JeanRegiThatPhilStraWindJackThisJameArnoIntrRaymJackwarcStopPaulWhatDaviKornGuntMastBernPatr
PatrBeniYodeXVIIBergWASDOmryChriAlmoBlinCircOtheOtakBrauAltaNormXIIIJeweXVIIJohaXVIIMarkAdam
AlfrJoliNikiAndyQuikCircDamnKlixPhilChriThorGeorAstoVelvZoneChopClauEvanJeweMattOnlyWillReco
ZoneShauBattClaqZoneZoneRobeRobeZoneMorlZoneZonediamZoneZoneStreWestZoneZoneZoneOverZoneZone
ZoneFlexKKOEKOSSHighTeacIndeBekoAttoBensJujjBookAdriWoodFiesPulpMistDaniSSANFIATSiegChaponte
ValiPastFantHansTracTeslBakuBritSaleWithJedeBorkTefaBlacChoiWindApolWindWoodAmorStolChanJohn
SympMaxiKeesXVIIJacoCharFromRandHonoFredMargKingwwwrJeweBridRollOrdeDungPaulGoodJohnCrasWind
DigiVIIIWhatNancXXIIHannNazaCaveDaniLibeJeweJuliMariFranMichAutoEnidAnneGeneSheiMathKOSSKOSS
KOSSDoubJesuBillNikoSONYNagiHansPerfTherUnchPretSaurtuchkasWordFata

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/