DrNova Posted August 10, 2008 Author Share Posted August 10, 2008 I plan on having "damaged" items, user can click them(scripted item) to repair them.However, I dont want to have to make a seperate case for ever single item if I dont have to.Is there a way to make a function to check the number of the scripted item used?Such asFunction(num)num= scripted item used(scripted item sub)Case 4If num=this, thenElse if num=this then, ectIf that makes sence.I COULD make them all seperate cases, but just seems like it would be more efficient to put it all into a single scripted item that can tell the item number clicked. Link to comment Share on other sites More sharing options...
Guest Posted August 10, 2008 Share Posted August 10, 2008 Okay… I don't quite understand your request, your title is different than what you say...?Anyway, if it's what your title is asking:```Function CanTake(Index, Number, Amount) Dim Slot Slot = 1 Index = Int(Index) Number = Int(Number) Amount = Int(Amount) Do While Slot < 25 If GetPlayerInvItemNum(Index, Slot) = Number Then If GetPlayerInvItemValue(Index, Slot) >= Amount Then CanTake = True Exit Function End If End If Slot = Slot + 1 Loop CanTake = FalseEnd Function```Credits 2 Godlord. If it's not what you're asking, then… tell me. XD> Command/Function Name: CanTake> Parameters:> Index (Integer): the player index.> Number (Integer): the item number.> Amount(Integer): the amount of items.> Description: checks if the item is available and if the quantity of that item is at least as much as the one specifed, or more than specified.> Return Value: true if there is an item with the right amount else false (Boolean). Link to comment Share on other sites More sharing options...
DrNova Posted August 10, 2008 Author Share Posted August 10, 2008 I mean to be able to check the item number of the scripted item used.I have a bunch of nearly identical scripted items, just different item numbers, and want to condense it to a single scripted item that can tell which item number the script was ran from, instead of having a bunch of nearly identical cases, same thing just different item number.If possible Link to comment Share on other sites More sharing options...
lucifer1101 Posted August 10, 2008 Share Posted August 10, 2008 either that would be a source edit or a big script which would make the server really laggy. Link to comment Share on other sites More sharing options...
Guest Posted August 10, 2008 Share Posted August 10, 2008 Why the hell did you post that reply? DrNova is intelligent, and he'd know that you could script it in sadscript rather than source editing. Think before posting. And it wouldn't be a huge script that would make the server laggy, there are only about two scripts that are of that magnitude. I doubt this would be one. Think before posting.To answer your request: I think it's possible. I'll get back to you on that. I'll try scripting it now.[edit]Hmm… I know it's possible. I just can't think right now, I'm kind of tired. I hope someone can help you with it.Also, try using```GetPlayerInvItemValue(Index, Slot)```to make the script. That's what I'm thinking along the lines of right now. Link to comment Share on other sites More sharing options...
DrNova Posted August 10, 2008 Author Share Posted August 10, 2008 The problem I havent been able to get past however, is how to tell the number of the item clicked, or even its slot.I know how to find item slots and such, but how to find the number of the item using that case. For example, I have 5 items using the same base script in a case, how can I get it to know which item activated the script.I'm beginning to think this cant be done with current scripting commands, I cant see any way to identify the item number that was used to call the script, except by having multiple case's for each different item.. Link to comment Share on other sites More sharing options...
Guest Posted August 10, 2008 Share Posted August 10, 2008 I'm conflicting with myself whether this is possible or not. Now that I think about it, it would be way easier just hardcoding it in. However, I'm pretty sure it can be sadscripted. Link to comment Share on other sites More sharing options...
Bobosk Posted August 10, 2008 Share Posted August 10, 2008 Hmm, use temporary .ini's is the way i'm thinking…Like how the whole general "Commands" sub uses the "Commands.ini" in the scripts folder to tear them apart and read each variable when you use LCase.. Link to comment Share on other sites More sharing options...
dg1423 Posted August 10, 2008 Share Posted August 10, 2008 nah, you'd have to do a small source edit to include the item number in the scripteditem sub call. it's a very easy modification, and I think it'll be included in 2.8. Link to comment Share on other sites More sharing options...
balliztik1 Posted August 11, 2008 Share Posted August 11, 2008 @dg1423:> nah, you'd have to do a small source edit to include the item number in the scripteditem sub call. it's a very easy modification, and I think it'll be included in 2.8.If you've not already thought about it, adding the slot parameter would also be beneficial. 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