Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Need help scripting item(s) + item(s) = item…


cook
 Share

Recommended Posts

I am using Eclipse Stable and all I want is to be able to have an item creation aspect to my game, however every single script tutorial out there does not seem to be for Stable. And even if there was one out there made with Stable in mind it doesnt give good enough instructions on how and where to put all the code as well as testing it out. Could somebody please give me some detailed instructions on how to incorporate this into my game or maybe even a preconfigured main.txt for me to use?
Link to comment
Share on other sites

```
Case U
    If CountPlayerInvItem(Index, X, 1) And CountPlayerInvItem(Index, Y, 1) Then
        Call RemovePlayerInvItem(Index, X, 1)
        Call RemovePlayerInvItem(Index, Y, 1)
        Call AddPlayerInvItem(Index, Z, -1)
    End If
```
Add that code to ScriptedItems.ess, somewhere in the ScriptedItems procedure, replace U with the proper case number, X and Y with the item numbers and Z with the item number of the product to be formed. Then you should create two scripted items with the numbers you specified for X and Y and you should configure them to use that script.

I really recommend you to take a look at some scripting tutorials before messing around with the scripts though.

Regards,
  Godlord.
Link to comment
Share on other sites

That sounds simple enough, I'll test it out as soon as I get a chance. I have read a bunch of different script tuts and feel like I got the just of it, I just have a hard time with placement. Thanks for your help though, I cant wait to test this out.
Link to comment
Share on other sites

There seems to be 2 item scripts. One in the client and one in the server folder. Am I suppose to put that code in the same spot in both of them or just in one of them? Also where exactly in the code do I put it?
This is where Im at…D:\Games\Eclipse\Eclipse-Stable\Server\Scripts\Events\ScriptedItem

Where in this code do I put your code? And once its in how do I check to see if it works? Is it as simple as right clicking on one of the items or will it automatically create the desired item once I get the needed items in my inventory?

Sub ScriptedItem(Index, Script, Slot)
Select Case Script
Case 0
Call PlayerMsg(Index, "This scripted item has no apparent use.", WHITE)

Exit Sub

Case Else
Call PlayerMsg(Index, "No item script found. Please contact an admin to solve this problem.", WHITE)

Exit Sub

End Select

End Sub
Link to comment
Share on other sites

The client doesn't have any scripts, normally. Unless you're talking about the DAT-files, which are just the items not the scripts.

```
Sub ScriptedItem(Index, Script, Slot)
    Select Case Script
        Case 0
            Call PlayerMsg(Index, "This scripted item has no apparent use.", WHITE)

            Exit Sub

        Case 1
            If CountPlayerInvItem(Index, X, 1) And CountPlayerInvItem(Index, Y, 1) Then
                Call RemovePlayerInvItem(Index, X, 1)
                Call RemovePlayerInvItem(Index, Y, 1)
                Call AddPlayerInvItem(Index, Z, -1)
            End If

            Exit Sub

        Case Else
            Call PlayerMsg(Index, "No item script found. Please contact an admin to solve this problem.", WHITE)

            Exit Sub
    End Select
End Sub
```Replace X and Y with the numbers of the items to be replaced and replace the Z with the number of the item with what to replace them with. You should make three items using those three item numbers you specified (in your item editor). Two of them (X and Y) should be a scripted item and should be using script 1\. You can fill in the rest as you desire. The third item could be anything you want.

How to use it in the game: get item X and get item Y, click on either of them, doesn't matter which, you'll normally get item Z and item X and item Y will disappear.

Regards,
  Godlord.
Link to comment
Share on other sites

Ok please be patient with me. Im doing something wrong, please help.  Im getting this error:

TYPE: Type mismatch: 'CountPlayerInvItem'
LINE:7
CLOUMN:0
CODE:

I'm attempting to use items number 8 and 9 to create item 10\. Now correct me if Im wrong but shouldnt I make items 8 and 9 script items, each being script number 1, an then make item 10 just a normal item?

This is what my code looks like:

Sub ScriptedItem(Index, Script, Slot)
    Select Case Script
        Case 0
            Call PlayerMsg(Index, "This scripted item has no apparent use.", WHITE)

            Exit Sub

        Case 1
            If CountPlayerInvItem(Index, 8, 1) And CountPlayerInvItem(Index, 9, 1) Then
                Call RemovePlayerInvItem(Index, 8, 1)
                Call RemovePlayerInvItem(Index, 9, 1)
                Call AddPlayerInvItem(Index, 10, -1)
            End If

            Exit Sub

        Case Else
            Call PlayerMsg(Index, "No item script found. Please contact an admin to solve this problem.", WHITE)

            Exit Sub
    End Select
End Sub
Link to comment
Share on other sites

Firstly, use code tags, it's really annoying when you don't.

Now to fix your problem, CountPlayerInvItem is a boolean value i believe, so try doing this:
```
'###################
'Fixed by Lam3r
'###################
Sub ScriptedItem(Index, Script, Slot)
    Select Case Script
        Case 0
            Call PlayerMsg(Index, "This scripted item has no apparent use.", WHITE)

            Exit Sub

        Case 1
            If CountPlayerInvItem(Index, 8, 1) = True And CountPlayerInvItem(Index, 9, 1) = True Then
                Call RemovePlayerInvItem(Index, 8, 1)
                Call RemovePlayerInvItem(Index, 9, 1)
                Call AddPlayerInvItem(Index, 10, -1)
            End If

            Exit Sub

        Case Else
            Call PlayerMsg(Index, "No item script found. Please contact an admin to solve this problem.", WHITE)

            Exit Sub
    End Select
End Sub

```
Link to comment
Share on other sites

I also wanted to repeat that my version of eclipse stable does indeed have a client\scripts\scripteditem ess file. Now with that being said is it necessary for me to copy that line of code into both the client scripteditem ess file and the server scripteditem ess file?
Link to comment
Share on other sites

```
Sub ScriptedItem(Index, Script, Slot)
    Select Case Script
        Case 0
            Call PlayerMsg(Index, "This scripted item has no apparent use.", WHITE)

            Exit Sub

        Case 1
            If CountPlayerInvItem(Index, 8) > 0 And CountPlayerInvItem(Index, 9) > 0 Then
                Call RemovePlayerInvItem(Index, 8, 1)
                Call RemovePlayerInvItem(Index, 9, 1)
                Call AddPlayerInvItem(Index, 10, -1)
            End If

            Exit Sub

        Case Else
            Call PlayerMsg(Index, "No item script found. Please contact an admin to solve this problem.", WHITE)

            Exit Sub
    End Select
End Sub
```

Regards,
  Godlord.
Link to comment
Share on other sites

I just deleted and reinstalled the game from scratch, didnt change or touch anything except for input the code you gave me and I still get the error:

```
TYPE: Type mismatch: 'CountPlayerInvItem'
LINE:7
CLOUMN:0
CODE:
```
This is exactly what Im doing…

1\. Put in your code so it looks like this
```
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Module: ScriptedItem.ess '
' Author: Stephan J.R. van Schaik '
' Date: August 30th, 2009. '
' Version: 1.0.0 '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function: ScriptedItem '
' Brief: executes when somebody uses an item. '
' Parameters: '
' Index: the index of the player. '
' Script: the script to execute. '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub ScriptedItem(Index, Script, Slot)
    Select Case Script
        Case 0
            Call PlayerMsg(Index, "This scripted item has no apparent use.", WHITE)

            Exit Sub

        Case 1
            If CountPlayerInvItem(Index, 8, 1) > 0 And CountPlayerInvItem(Index, 9, 1) > 0 Then
                Call RemovePlayerInvItem(Index, 8, 1)
                Call RemovePlayerInvItem(Index, 9, 1)
                Call AddPlayerInvItem(Index, 10, -1)
            End If

            Exit Sub

        Case Else
            Call PlayerMsg(Index, "No item script found. Please contact an admin to solve this problem.", WHITE)

            Exit Sub
    End Select
End Sub

```
2\. Then I create 2 scripted items both of which use script 1.  I use the eighth and ninth item spots for these items.

3\. Then I create a normal weapon item in the tenth item spot.

4\. Then I place items 8 and 9 on my map, pick them up, and try to use them. This is when I get the error.
Link to comment
Share on other sites

No the item slot on the player has nothing to do with it..

By item# we mean the 8th item you created in your game. Items actually have a number, and if you look through a list of all your items they are all numbered, the item that you want to use needs to be #8/9/10
Link to comment
Share on other sites

Yes I knew that. I didn't mean to make it sound like I was talking about the actual slots in the inventory. The items are items numbers 8,9, and 10\. I wish that was the mistake I made cuz then I would be that much closer to finding a fix.
Link to comment
Share on other sites

@Cook:

> I just deleted and reinstalled the game from scratch, didnt change or touch anything except for input the code you gave me and I still get the error:
>
> ```
> TYPE: Type mismatch: 'CountPlayerInvItem'
> LINE:7
> CLOUMN:0
> CODE:
> ```
> This is exactly what Im doing…
>
> 1\. Put in your code so it looks like this
> ```
> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> ' Module: ScriptedItem.ess '
> ' Author: Stephan J.R. van Schaik '
> ' Date: August 30th, 2009. '
> ' Version: 1.0.0 '
> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>
> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> ' Function: ScriptedItem '
> ' Brief: executes when somebody uses an item. '
> ' Parameters: '
> ' Index: the index of the player. '
> ' Script: the script to execute. '
> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> Sub ScriptedItem(Index, Script, Slot)
>     Select Case Script
>         Case 0
>             Call PlayerMsg(Index, "This scripted item has no apparent use.", WHITE)
>          
>             Exit Sub
>          
>         Case 1
>             If CountPlayerInvItem(Index, 8, 1) > 0 And CountPlayerInvItem(Index, 9, 1) > 0 Then
>                 Call RemovePlayerInvItem(Index, 8, 1)
>                 Call RemovePlayerInvItem(Index, 9, 1)
>                 Call AddPlayerInvItem(Index, 10, -1)
>             End If
>          
>             Exit Sub
>          
>         Case Else
>             Call PlayerMsg(Index, "No item script found. Please contact an admin to solve this problem.", WHITE)
>          
>             Exit Sub
>     End Select
> End Sub

> ```
> 2\. Then I create 2 scripted items both of which use script 1.  I use the eighth and ninth item spots for these items.
>
> 3\. Then I create a normal weapon item in the tenth item spot.
>
> 4\. Then I place items 8 and 9 on my map, pick them up, and try to use them. This is when I get the error.

You used the code before I edited and fixed some issue.

Regards,
  Godlord.
Link to comment
Share on other sites

Use this, I'm sure godlord edited after u pasted:
```
Sub ScriptedItem(Index, Script, Slot)
    Select Case Script
        Case 0
            Call PlayerMsg(Index, "This scripted item has no apparent use.", WHITE)

            Exit Sub

        Case 1
            If CountPlayerInvItem(Index, 8) > 0 And CountPlayerInvItem(Index, 9) > 0 Then
                Call RemovePlayerInvItem(Index, 8, 1)
                Call RemovePlayerInvItem(Index, 9, 1)
                Call AddPlayerInvItem(Index, 10, -1)
            End If

            Exit Sub

        Case Else
            Call PlayerMsg(Index, "No item script found. Please contact an admin to solve this problem.", WHITE)

            Exit Sub
    End Select
End Sub
```
Link to comment
Share on other sites

I am still getting that error every time I go to click on the items.
```
TYPE: Type mismatch: 'CountPlayerInvItem'
LINE:7
CLOUMN:0
CODE:
```
Does anybody know what this code means?
What could I possibly be doing wrong? Ive tried everything. I go into server, scripts, events, scripteditem ess, place the correct code there in the correct spot and I still get the error.
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...