Jump to content

[Guide]Creating some basic methods[For newbies]


Recommended Posts

Hello gyes, since it requested, i will try to make this guide about some methods and creating methods explanations.

 

This time, we will talk about set and is methods.You know..., maybe all of you know these methods , you have seen it at hero status,noble status :

setHero(true,false)  ,   setNoble(true,false)  , isHero()  ,  isNoble().

I will explain you exactly how these methods are working, so that you can create easy your own .

 

In my guide i will use the name MaxCheatersMember.So, there will be two methods, right?

The one is   setMaxCheatersMember(true,false)  and the other isMaxCheatersMember() .

 

Creating the methods....

First of all, lets create the method isMaxCheatersMember() .  I will make it via steps.

1)We go at L2PcInstance.java class and we create a boolean named like we want i will use this:

private boolean _maxcheater;

 

2)For make it easy and more readable, find this line: public boolean isNoble() , above this create a method :

public boolean isMaxCheatersMember()

{

}

 

3)We have a empty method,named isMaxCheatersMember,right? Inside this method just add this line:

return _maxcheater; . So the method will have the body return _maxcheater; .

The isMaxCheatersMember() method is ready, now we will create the method seMaxCheatersMember(true or false).

 

4)Above of the line: public boolean isMaxCheatersMember() or under the whole method we create a new method named setMaxCheatersMember(boolean value)

{

}

 [in the value you can put everything ,even x,y,z

 

5)Now we have again a empty method xD , inside this method now we put this line:

_maxcheater = value; (where value the name of your boolean)

 

Now we have the both methods we need: isMaxCheatersMember() and setMaxCheatersMember(boolean value)

 

 

How they work.....?Explanation?

I will explain it again in some simple steps:

 

1)First of all we create a private boolean named _maxcheater;. A boolean can have only 2 values ,

it can be true or false .

Ok , but why private?

We set it as private because the only class that checks this value is the class L2PcInstance, only this class checks this boolean , only.

 

2)the whole method:

public boolean isMaxCheatersMember()

{

  return _maxcheater;

}

just returns the value of _maxcheater; So if _maxcheater boolean is true , the method

isMaxCheatersMember() will return true, if false the method will return false; You catch it , o yea!!

By default it is false, as we created the boolean _maxcheater as false in the beggining.But for changing it,for changing the boolean, so for changing the value of method isMaxCheatersMember() to return true if we want, or false, look at the step 3.

Why the method is public?

Because , we want to use this method and in another classes, not only in L2PcInstance for example maybe we want to go at Enterworld class and we need to add this method there!

 

3)Here's come the creation of method:

public void setMaxCheatersMember(boolean value)

{

 _maxcheater = value;

}

What the hell is it?Ok, this method first of all needs a parameter,a parameter in our example is the: boolean value .Then it reads this boolean , so it will read if it is true or false.Then it takes the value of the boolean, and it set's it at _maxcheater boolean.For example if value=true then _maxcheater = true ; if False, the opposite. It's easy i think to understand it.

Why public and why void and not boolean?

Not private for the same reason as method isMaxCheatersMember().

Ok, now lets explain why void and not boolean.If we had boolean we should return something, for example return _aboolean; But we don't want this method to return something, we want this method to DO something.We we want a method to do something, we put void.

 

That was how these simple methods work, i think that for newbies it is usefull and they can understand it.

 

Puting methods into methods...

Ok, i will continue with these 2 methods. isMaxCheatersMember() and setMaxCheatersMember(true,false) .

Now , players can't get this method to true, its false by default....for example now i will explain you how to "check" if the players has some conditions to take the isMaxCheatersMember() status(i mean to be true).

 

In my example, one player will become isMaxCheatersMember() if he has 50000 pvp.How can we do it?We can do it and without put methods into methods, but by doing this it's better, i think it looks more advanced.

So what we want our method to return or do something? Think about it, we need to DO, so we create a void method.

Let's create it, i will explain you what i did then.

 

public void checkForMxcStatus(L2PcInstance activeChar)

{

 if (activeChar.getPvpKills() >= 50000 && !(activeChar.isMaxCheatersMember()))

 {

   activeChar.setMaxCheatersMember(true);

 }

 else if (activeChar.getPvpKills() < 50000)

 {

   activeChar.setMaxCheatersMember(false);

 }

}

 

What we did?

1)We created a public (you know now why public) method as void named checkForMxcStatus with 1 parameter which is an l2pcinstance object, the well known to all of you activeChar.

2)First of all we check if the activeChar has 50000 pvp and if he is'nt MaxCheatersMember() (! means not).

3)If the player has these conditions, we set him isGamingParadiseMember() with the setMaxCheatersMember() method that we created before.

4)then we use the else if to check if the player's pvps ar lower than 50000 , if it is we set him isMaxCheatersMember false, again with the method setMaxCheatersMember().

 

Yes that can be done with a better way, that was an example.If you are a newbie, the best you can do is practice to methods, they are very very very very usefull to continue your carreer.I hope i helped gyes, for now i need some masause at my fingers.

 

 

PS: the is and get is example, but all are used to use these methods to be more understandable, you catch me :D

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • I can use this folder system for High Five offline server?   The folder does not have a l2.exe file.   Thank you very much if anyone can help me.   https://drive.google.com/file/d/13kU-g_4JJ-sP-kg2F7pqkUOVKmQdubFm/view
    • I know, but...every time I have problem with IP address setup 😞
    • ENGLISH As you know, we have always profiled in the development of Java emulators, we continue to do our favorite thing, and now we have the opportunity to provide you with services in the field of private development of L2 assemblies Essence, Classic and High Five, which we have been doing in recent years, we have not been working on basic builds for a long time and work only on contracts for the world's best projects. These are the best builds we can offer, we have test servers and we can show them to you on the test, and if you are very good at gameplay, you will see a big difference in the quality and detail of the official content compared to the basic builds. These are the best top solutions in the world, which are currently used to implement the largest projects in the world. We guarantee 100% implementation of all official content. If you have any questions about testing, discussions, etc., please contact our studio and we will discuss everything. At the moment, you can get acquainted with the preliminary information and prices for Private L2 contracts here: Private Server packs L2 Essence 464, 447, 388, 362, 286 protocols Private server packs L2Classic Private server pack High Five РУССКИЙ --------------------------------------------- Как вы знаете мы всегда профилировались на разработке в сфере Java эмуляторов, мы продолжаем заниматься своим любимым делом, и сейчас у нас появилась возможность предоставлять вам услуги в сфере приватных разработок L2 сборок Essence, Classic и High Five, которыми мы занимаемся последние годы, мы уже давно не работаем над базовыми сборками и работаем только на контрактах для лучших мировых проектов. Это лучшие сборки, которые мы можем предложить, у нас есть тестовые сервера, и мы можем показать их вам на тесте, и если вы очень хорошо разбираетесь в игровом процессе, вы увидите большую разницу в качестве и детализации официального контента по сравнению с базовыми сборками. Это лучшие топовые решения в мире, которые на данный момент используются для реализации крупнейших проектов в мире. Мы даем гарантии - 100% реализации всего официального контента. По вопросам тестирования, обсуждений и тд - пишите по контактам нашей студии и мы все обсудим. На данный момент вы можете ознакомиться с предварительной информацией и ценами на Приватные контракты L2 тут: Приватные Сборки L2 Essence 464, 447, 388, 362, 286 protocols Приватные Сборки L2Classic Приватная Сборка High Five -------------------------------------------------------------- Contacts: Telegram: https://t.me/L2scripts Whatsapp, Viber: +1 (916) 226 1910 С уважением, Администрация !
    • I can sell it. If you are interested just pm.
    • Its really not that hard to setup a server on a vps.
  • Topics

×
×
  • Create New...