Sealbreaker Posted July 28, 2009 Author Share Posted July 28, 2009 since i want to script more… but often get problems i am goin to make this to my: sealbreakers problems with scripts thread =Pso... here's my next problem..... its supposed to be a script for a chest... you double klick ( open ) it and with a bit luck you get a cool item....```Case 1Call Rand(1,100)If Rand(1, 100) > 78 ThenCall PlayerMsg(index, "Suddenly you see a bright light coming out of the chest", BLACK )Call GiveItem (index, #, 1)Call TakeItem(index, #, 1)If Rand(1, 100) < 10Call PlayerMsg(index, "you jump in the air as you see what is in the chest", BLACK )Call GiveItem (index, #, 1)Call TakeItem(index, #, 1)ElseCall PlayerMsg(index, "Inside the chest is nothing", RED)Call TakeItem(index, #, 1)End ifExit Sub``` Link to comment Share on other sites More sharing options...
kris_hole Posted July 28, 2009 Share Posted July 28, 2009 well the 1st one should work.The second one try replacingGetplayertargetnpc(index)with…Target = GetPlayerTargetNpc(index) Link to comment Share on other sites More sharing options...
Sealbreaker Posted July 28, 2009 Author Share Posted July 28, 2009 i'll try…. thx for the fast answer... =Pedit: YEAH! everything works now! =) thank you very much ^^ Link to comment Share on other sites More sharing options...
kris_hole Posted July 28, 2009 Share Posted July 28, 2009 lol np sealbraker :)glad i could help :) Link to comment Share on other sites More sharing options...
Diskmaster Posted July 28, 2009 Share Posted July 28, 2009 well, your first one seems correct, but since your second one is wrong, it is probably throwing off all of your /commands so, if u want the first one to work, take out the second one or fix it (seems almost right). Link to comment Share on other sites More sharing options...
Sealbreaker Posted July 28, 2009 Author Share Posted July 28, 2009 like i already said: everything's working now… :huh:but this is my problem-thread now... lol ^^ Link to comment Share on other sites More sharing options...
Admiral Refuge Posted July 28, 2009 Share Posted July 28, 2009 The code "Call Rand(1,100)" will not work. Rand() is a function, not a sub; it just calculates the random of two numbers; also, you're calculating Rand() more then once; it's not like it stores it for you; so the first time you calculate it, it could return 3, then the second time it returns 81, thus making it bring "Inside the chest is nothing".If you want it to recheck the same number if it doesn't meet the first criteria, you could always store it in a local variable (more on that in afew).```If Rand(1, 100) < 10```Should be:```Elseif Rand(1, 100) < 10```So it'd be:```Case 1Call Rand(1,100)If Rand(1, 100) > 78 ThenCall PlayerMsg(index, "Suddenly you see a bright light coming out of the chest", BLACK )Call GiveItem (index, #, 1)Call TakeItem(index, #, 1)ElseIf Rand(1, 100) < 10Call PlayerMsg(index, "you jump in the air as you see what is in the chest", BLACK )Call GiveItem (index, #, 1)Call TakeItem(index, #, 1)ElseCall PlayerMsg(index, "Inside the chest is nothing", RED)Call TakeItem(index, #, 1)End IfExit Sub```With a variable added (and with that faulty "Call Rand()" taken out), it would be:```Case 1Dim MyRandomVariableMyRandomVariable = Rand(1,100)If MyRandomVariable > 78 Then Call PlayerMsg(index, "Suddenly you see a bright light coming out of the chest", BLACK ) Call GiveItem (index, #, 1) Call TakeItem(index, #, 1)ElseIf MyRandomVariable < 10 Call PlayerMsg(index, "you jump in the air as you see what is in the chest", BLACK ) Call GiveItem (index, #, 1) Call TakeItem(index, #, 1)Else Call PlayerMsg(index, "Inside the chest is nothing", RED) Call TakeItem(index, #, 1)End IfExit Sub```Also, you need Godlord's inventory script to use this code (the TakeItem and GiveItem). Link to comment Share on other sites More sharing options...
Sealbreaker Posted July 28, 2009 Author Share Posted July 28, 2009 thank you very much.. =) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now