Welcome to Jc - Scape!

Please log-in if you already have a JCscape forum account,

If you don't, please register!

Best regards, JCscape staff.
Welcome to Jc - Scape!

Please log-in if you already have a JCscape forum account,

If you don't, please register!

Best regards, JCscape staff.
Would you like to react to this message? Create an account in a few clicks or log in to continue.


.
 
HomeHome  Portal*Portal*  GalleryGallery  SearchSearch  Latest imagesLatest images  RegisterRegister  Log inLog in  
Navigation
 Index
 FinalX
 Server Status
Who is online
In total there are 5 users online :: 0 Registered, 0 Hidden and 5 Guests

None

Most users ever online was 167 on Mon May 18, 2009 10:33 pm
Top posters
♫ Steven ♫ (1243)
Handling Packet 40 I_vote_lcapHandling Packet 40 I_voting_barHandling Packet 40 I_vote_rcap 
Jamie (1112)
Handling Packet 40 I_vote_lcapHandling Packet 40 I_voting_barHandling Packet 40 I_vote_rcap 
Norway (1110)
Handling Packet 40 I_vote_lcapHandling Packet 40 I_voting_barHandling Packet 40 I_vote_rcap 
Immense Jelly <3 Obliv (1072)
Handling Packet 40 I_vote_lcapHandling Packet 40 I_voting_barHandling Packet 40 I_vote_rcap 
Mod Robbie (984)
Handling Packet 40 I_vote_lcapHandling Packet 40 I_voting_barHandling Packet 40 I_vote_rcap 
J A M I E (832)
Handling Packet 40 I_vote_lcapHandling Packet 40 I_voting_barHandling Packet 40 I_vote_rcap 
Oblivious (780)
Handling Packet 40 I_vote_lcapHandling Packet 40 I_voting_barHandling Packet 40 I_vote_rcap 
Disturb3d (760)
Handling Packet 40 I_vote_lcapHandling Packet 40 I_voting_barHandling Packet 40 I_vote_rcap 
ErenGurkan ツ (740)
Handling Packet 40 I_vote_lcapHandling Packet 40 I_voting_barHandling Packet 40 I_vote_rcap 
James (710)
Handling Packet 40 I_vote_lcapHandling Packet 40 I_voting_barHandling Packet 40 I_vote_rcap 

Advert

Interested to advertise at jcscape.org? Contact Evanna@graphicscene.net

 

Handling Packet 40

View previous topic View next topic Go down 
Author Message
The Soul
Moderator
Moderator
The Soul

Number of posts : 8
Points :
Handling Packet 40 Left_bar_bleue0 / 1000 / 100Handling Packet 40 Right_bar_bleue

Registration date : 2009-12-31

Handling Packet 40 Vide
PostSubject: Handling Packet 40   Handling Packet 40 EmptyThu Dec 31, 2009 12:54 am

This way is a lot more efficient than the huge if-statement lying in packet 40 checking every single continuous dialogue.

You'll first need to add an array (take every ID in packet 40 that the NpcDialogue var checks to see if it's equal). For example, do:
Code:
public int[] continueDialogue = {
    29, 50, 232
};

Once you have an array you'll need to add this method:
Code:
public boolean continue(int ID) { // returns type boolean
    for(int i : continueDialogue) { // using enhanced for loop to loop through the continueDialogue array
        return i == ID ? true : false; // uses ternary operator to check if iterator, 'i' is equal to parameter variable, ID, and if it is, it will return true. If it doesn't, it will return false
    }
}

Under packet 40, once you've collected all of the data, replace it with:
Code:
case 40: // starts packet 40
    if(continue(NpcDialogue)) // if you look back at the continue() method, it checks if the any elements in the array when you looped through it equaled NpcDialogue it would return true
        NpcDialogue++; // var NpcDialogue goes up in increments of 1
    break; // ends packet 40

Although a small tutorial it should be beneficial.
Back to top Go down

Handling Packet 40

View previous topic View next topic Back to top 
Page 1 of 1

Permissions in this forum: You cannot reply to topics in this forum
 :: Main Rsps :: Tutorial's / Config's Ect. -