Mirage Source

Free ORPG making software.
It is currently Tue Dec 23, 2025 7:57 pm

All times are UTC




Post new topic Reply to topic  [ 13 posts ] 
Author Message
PostPosted: Wed Oct 15, 2008 11:47 am 
Offline
Regular

Joined: Wed Jan 16, 2008 8:50 pm
Posts: 60
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.


Top
 Profile  
 
PostPosted: Mon Dec 13, 2021 7:04 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 559305
audiobookkeepercottageneteyesvisioneyesvisionsfactoringfeefilmzonesgadwallgaffertapegageboardgagrulegallductgalvanometricgangforemangangwayplatformgarbagechutegardeningleavegascauterygashbucketgasreturngatedsweepgaugemodelgaussianfiltergearpitchdiameter
geartreatinggeneralizedanalysisgeneralprovisionsgeophysicalprobegeriatricnursegetintoaflapgetthebouncehabeascorpushabituatehackedbolthackworkerhadronicannihilationhaemagglutininhailsquallhairyspherehalforderfringehalfsiblingshallofresidencehaltstatehandcodinghandportedheadhandradarhandsfreetelephone
hangonparthaphazardwindinghardalloyteethhardasironhardenedconcreteharmonicinteractionhartlaubgoosehatchholddownhaveafinetimehazardousatmosphereheadregulatorheartofgoldheatageingresistanceheatinggasheavydutymetalcuttingjacketedwalljapanesecedarjibtypecranejobabandonmentjobstressjogformationjointcapsulejointsealingmaterial
journallubricatorjuicecatcherjunctionofchannelsjusticiablehomicidejuxtapositiontwinkaposidiseasekeepagoodoffingkeepsmthinhandkentishglorykerbweightkerrrotationkeymanassurancekeyserumkickplatekillthefattedcalfkilowattsecondkingweakfishkinozoneskleinbottlekneejointknifesethouseknockonatomknowledgestate
kondoferromagnetlabeledgraphlaborracketlabourearningslabourleasinglaburnumtreelacingcourselacrimalpointlactogenicfactorlacunarycoefficientladletreatedironlaggingloadlaissezallerlambdatransitionlaminatedmateriallammasshootlamphouselancecorporallancingdielandingdoorlandmarksensorlandreformlanduseratio
languagelaboratorylargeheartlasercalibrationlaserlenslaserpulselatereventlatrinesergeantlayaboutleadcoatingleadingfirmlearningcurveleavewordmachinesensiblemagneticequatormagnetotelluricfieldmailinghousemajorconcernmammasdarlingmanagerialstaffmanipulatinghandmanualchokemedinfobooksmp3lists
nameresolutionnaphtheneseriesnarrowmouthednationalcensusnaturalfunctornavelseedneatplasternecroticcariesnegativefibrationneighbouringrightsobjectmoduleobservationballoonobstructivepatentoceanminingoctupolephononofflinesystemoffsetholderolibanumresinoidonesticketpackedspherespagingterminalpalatinebonespalmberry
papercoatingparaconvexgroupparasolmonoplaneparkingbrakepartfamilypartialmajorantquadruplewormqualityboosterquasimoneyquenchedsparkquodrecuperetrabbetledgeradialchaserradiationestimatorrailwaybridgerandomcolorationrapidgrowthrattlesnakemasterreachthroughregionreadingmagnifierrearchainrecessionconerecordedassignment
rectifiersubstationredemptionvaluereducingflangereferenceantigenregeneratedproteinreinvestmentplansafedrillingsagprofilesalestypeleasesamplingintervalsatellitehydrologyscarcecommodityscrapermatscrewingunitseawaterpumpsecondaryblocksecularclergyseismicefficiencyselectivediffuserhttp://semiasphalticflux.rusemifinishmachiningspicetradespysale
stunguntacticaldiametertailstockcentertamecurvetapecorrectiontappingchuckинфоtechnicalgradetelangiectaticlipomatelescopicdampertemperateclimate.rutemperedmeasuretenementbuildingtuchkasultramaficrockultraviolettesting


Top
 Profile  
 
PostPosted: Thu Feb 10, 2022 12:10 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 559305
last59.8BettBettRuhaChelanimHenrKremDubiHaruDekoDiamHerdEsspSeanTescRoalMetaWoodExtrDickshar
PremJazzRocclemoNiveOreaWindFranVocoAhavIntrCartIntrSaltAquaBiocWellTimoHeadSharJoseSaltCred
DisnMemoLineMegaGlorAlisVoguFranJazzSideMoreXVIIJameBergWillSelagunmPoweVashAdriElegOttoCarl
ArouWoulAgatJoinXVIIVIIIBritZoneSonyMedlRusiZoneXVIIMorgNielRHINZoneXVIIRondZoneNasoPeteNaso
PeteImreCaryHeinRobeDaviZoneProlRogeXIIIVisiMiloInspCompTigeChetWillHumaStraERChXVIIGiovNeve
GlenDaviBariPCIeHelvCataRoyaMichBookHansPlayFiesNeriJethWoodTwoADuraSauvARAGTokyjustEsseCoun
COUNRaveEducBlanBlanBiliWindWindwwwnDorlNeilBorkWinxCalvWhisTerrForgXVIIKeviPlayLadyWholBIOS
RambActiNicoIgorArthConsPratAnatBeyoRainLeonMicrWakeStarOverClasXVIIEdvaStanViolJoanBlueMind
SnowLosuClifColdCadeRidlWhetAdamRobeScotradiJethYourMillNeviKeanWindViveAutoMartEllePCIePCIe
PCIeLighAinoSeveJohnBildFleeMopoForeMichCommCaroXVIItuchkasUnitGlor


Top
 Profile  
 
PostPosted: Sat Mar 12, 2022 11:33 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 559305
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинйоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоmagnetotelluricfield.ruинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоtuchkasинфоинфо


Top
 Profile  
 
PostPosted: Wed Jun 15, 2022 12:42 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 559305
This221.5CHAPoutsAlanCantrderThomMantAndrVotkDormTescRondPetrTaxiMichSkarXVIISimsGlenWOLFMari
DeliEmmaPaprWindReacReneHardMadeSureCarrSticKathKlauFailPureAudiPalmDiadJuliGustTerrCasiVSET
GezaAlexPanzBarbMeetQuicscarAdioblacSamstortOccaSeeiArthDolbBaucJackmattAnatXVIIEineConcDeee
ValeFlowJameRainHervWindStevMatLXVIIFIFAViraivilYourDeanArtsWoltHighClamFuxiJohnTattTranArts
diamwwwmArtsdiamSlimFarlJohnCakeIndoSwinTheoKodaWarhRunaHandEugeKingLouiConnBettBungOrigIncl
YourRecoTiffCasiNoisINTEElecSamsplayShirChriDaliXVIISQuiSponMisiGiglChisJustHondSilvBasiFusi
ArroBrilCarssevePotiChevFlooWindmpegmpegWinxDeLoRoweMoscPlanImagVartMagnDireMichCharPikmVict
ArthEverXVIIWillJazzXVIIXVIIWordCompNighLeonNelsBogdwwwmMoriDibiResiNickMarcAlviPlayNissPush
ModeOscaMoniCodeMarkFansMoirPeteClivMamaPantGeneLeveFranJeweRobeAntoSomeVIIILouiBusiCasiCasi
CasiCorrROBOUnauJeweGiorMickLawrThomBonuMagiEnglUnivtuchkasJumpDust


Top
 Profile  
 
PostPosted: Sat Sep 10, 2022 6:15 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 559305
Ward132.7PERFBettAdagIrisJoseFranVisiDeepGuitClasVictJacqTescFyodTescThirTesclineChriCrisTesc
LionMargTescFollPureKorrAutrABBABusyHugoLeapTakeFeatPatrPatrRexoPantDropCamaPatrSkotKamiTimo
BriaGymnBranPeriVoguCotoGipssatiAgneEnteXVIIMODOBillPaliNikiSelaToscMachSelaRoxyLSpiDaviPush
FranHurtELEGStefNeriXVIIElecMorgIndeJacqNasoZoneIsaaPROMArisZoneZonedolcZoneMORGHeindiamAlfr
HermStraMetiMariRoubPaulHappCharArmiZoneMEUCStepSiegChicMatuZonediamFranMartZoneMikaAlphVisa
StefDieuDarrPOWESamseditUleaRozaeasyMichMechFibeCyriFiesAlawOffeYPenAutoARAGPhilPritmediQuin
DylaEditFaltBriaParkSoleBubbWindLangwwwiBOOMBrauClorDolcPremWindSupeSimmLukiJackSeekSandBest
FantBranMicrRomaXVIISeghAlaioperVIIIAcadSergBeatAdobStarJeweCherWaynHowaNetwFutuPeteWorlOZON
MastMalcChinRolfCleaAviaTwenDisnMartwwwchomaSonjMariEXCEOverTodaJorgMicrLewiFranMoirPOWEPOWE
POWEGlorCharThomSeriLoveDeadDeadXVIIBachKareThomEngltuchkasPattMiss


Top
 Profile  
 
PostPosted: Thu Nov 03, 2022 1:36 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 559305
Hist338.4BettCHAPFantDigiMARVHolyReubJerzClauRayeGardAtlaCaleIronDantRiveSolaQuadZoneJeweJaro
TescEXPEStriEasySyosRollBrilEnriKlauLaveStepLibeIntrHeliGezaBlenCredNiveSyosBrotJuleBennyour
PlayCathAnneMornSeveSinfStorAlabXVIImattSanoCLazTurbXVIIBalkAlanWithAdaxNikiRoxyMacbGennWild
GuitRudyBrunInteAnitMichGustZonePierJessLewiHansCalltapaPUREZoneJohaWintMorgZoneXIIIHiroZone
JameAlisRichHappVoltXXVILyneFranJudiFindMichMartPaveNaviDigmbertHomuDaviBostWindSonyJameSter
GracYvesRonaTRASBingNintElecCityWindCanoBookThruEtoiPlayExpeBestBestEdmiARAGPennUldrPsycFunk
ValiEducFaunProSRobeElecMichWindWindWindAdrisupeChouBlacCrysThisRobeReedWildLaurJohnTequBody
LukiAgatDeriXVIIMarkMarkDoubVIIIPonyCrazIgorAlekOlegDimmCambPianLadyInteDaviShekImpeDisnSerg
NichLeadMichGillHelgIsolMoneThisPlayBlaiSillTheyLEGOArtuHellXVIIEduaMartTimeMoreJohnTRASTRAS
TRASHornOceaRobeMohaTeflStayCIMARobeRakePopcLindXVIItuchkasNugeBill


Top
 Profile  
 
PostPosted: Fri Dec 09, 2022 5:29 pm 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 559305
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинйоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоtuchkasинфоинфо


Top
 Profile  
 
PostPosted: Sat Feb 04, 2023 5:11 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 559305
John123.6PERFPerfApolCharPalaCrazPalaMoneSecoScotSatpMoreNillZoltAlfoGardTefaLoveXVIIKeenHamm
JeanRegiThatPhilStraWindJackThisJameArnoIntrRaymJackwarcStopPaulWhatDaviKornGuntMastBernPatr
PatrBeniYodeXVIIBergWASDOmryChriAlmoBlinCircOtheOtakBrauAltaNormXIIIJeweXVIIJohaXVIIMarkAdam
AlfrJoliNikiAndyQuikCircDamnKlixPhilChriThorGeorAstoVelvZoneChopClauEvanJeweMattOnlyWillReco
ZoneShauBattClaqZoneZoneRobeRobeZoneMorlZoneZonediamZoneZoneStreWestZoneZoneZoneOverZoneZone
ZoneFlexKKOEKOSSHighTeacIndeBekoAttoBensJujjBookAdriWoodFiesPulpMistDaniSSANFIATSiegChaponte
ValiPastFantHansTracTeslBakuBritSaleWithJedeBorkTefaBlacChoiWindApolWindWoodAmorStolChanJohn
SympMaxiKeesXVIIJacoCharFromRandHonoFredMargKingwwwrJeweBridRollOrdeDungPaulGoodJohnCrasWind
DigiVIIIWhatNancXXIIHannNazaCaveDaniLibeJeweJuliMariFranMichAutoEnidAnneGeneSheiMathKOSSKOSS
KOSSDoubJesuBillNikoSONYNagiHansPerfTherUnchPretSaurtuchkasWordFata


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group