Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 07:04

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Will this make the players lagg?

Discussion on Will this make the players lagg? within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
LordGragen.'s Avatar
 
elite*gold: 0
Join Date: Dec 2012
Posts: 606
Received Thanks: 67
Will this make the players lagg?

hello there, so i made a quest and when you done the quest will check your level and give you the correct gift. but idk why i worry to much how i made the last part and i need to make sure this wont harm the player.



Code:
if (client.Inventory.Contains(729310, 1))
                                                {

                                                    if (client.Entity.Level >= 1 && client.Entity.Level < 25)
                                                    {
                                                        client.Inventory.Add(1458756, 0, 1);
                                                        client.Inventory.DeleteItem(729310, 1);
                                                    }
                                                    else
                                                        if (client.Entity.Level >= 25 && client.Entity.Level < 50)
                                                        {
                                                            client.Inventory.Add(1458958, 0, 1);
                                                            client.Inventory.DeleteItem(729310, 1);
                                                        }
                                                        else
                                                            if (client.Entity.Level >= 50 && client.Entity.Level < 70)
                                                            {
                                                                client.Inventory.Add(1462958, 0, 1);
                                                                client.Inventory.DeleteItem(729310, 1);
                                                            }
                                                            else
                                                                if (client.Entity.Level >= 70 && client.Entity.Level < 90)
                                                                {
                                                                    client.Inventory.Add(1469854, 0, 1);
                                                                    client.Inventory.DeleteItem(729310, 1);
                                                                }
                                                                else
                                                                    if (client.Entity.Level >= 90 && client.Entity.Level < 100)
                                                                    {
                                                                        client.Inventory.Add(1447854, 0, 1);
                                                                        client.Inventory.DeleteItem(729310, 1);
                                                                    }
                                                                    else
                                                                        if (client.Entity.Level >= 100 && client.Entity.Level < 110)
                                                                        {
                                                                            client.Inventory.Add(1454875, 0, 1);
                                                                            client.Inventory.DeleteItem(729310, 1);
                                                                        }
                                                                        else
                                                                            if (client.Entity.Level >= 110 && client.Entity.Level < 120)
                                                                            {
                                                                                client.Inventory.Add(14524421, 0, 1);
                                                                                client.Inventory.DeleteItem(729310, 1);
                                                                            }
                                                                            else
                                                                                if (client.Entity.Level >= 120 && client.Entity.Level < 135)
                                                                                {
                                                                                    client.Inventory.Add(14524422, 0, 1);
                                                                                    client.Inventory.DeleteItem(729310, 1);
                                                                                }
                                                }

so lets say 10 people finish the quest and trune it same time, will this do anything bad? i feel there is better way to do the way i coded but idk, any idea?
LordGragen. is offline  
Old 04/11/2013, 18:19   #2


 
KraHen's Avatar
 
elite*gold: 0
Join Date: Jul 2006
Posts: 2,216
Received Thanks: 793
Shouldn`t cause problems if your Inventory doesn`t cause any.
KraHen is offline  
Thanks
2 Users
Old 04/11/2013, 18:49   #3
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,376
This script does nothing besides call add/delete item methods. Assuming those are written properly then there's no reason for it to lag people out.

That being said... not a big fan of that giant if/else string. You sure you wouldn't rather use a reward for each 20-30 levels and use a switch statement?
pro4never is offline  
Thanks
1 User
Old 04/11/2013, 19:27   #4
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,211
Received Thanks: 4,114
Well, this might be a cleaner way of doing it (however, the level 25 wouldn't work). On my server, I keep track of the level class (10 levels for every one level class) the player's in (so I don't do the arithmetic that you'd be doing every time this runs). It should be more efficient though because you're only doing one check per level class instead of two (depending on what level ranges you're checking). It also looks cleaner. I have each level class defined in an enumeration type as well; you can do that too to replace the numbers with something a bit more understandable. Really, you don't need to worry too much about efficiency with something like this. Any little change is still O(n) efficiency. We're talking about a couple nanoseconds of difference.

Code:
switch (client.Entity.Level / 10)
{
    // Example:
    case 1: // Level 10
    case 2: // Level 20
        client.Inventory.Add(1458756, 0, 1);
        break;
}

// Put this on the outside since it's always called. Looks cleaner.
client.Inventory.DeleteItem(729310, 1);
Spirited is offline  
Thanks
1 User
Old 04/11/2013, 19:46   #5
 
LordGragen.'s Avatar
 
elite*gold: 0
Join Date: Dec 2012
Posts: 606
Received Thanks: 67
thank you all,

and fang i must take a look at that, its very clean.

thx all.
LordGragen. is offline  
Old 04/11/2013, 21:13   #6
 
elite*gold: 0
Join Date: Sep 2012
Posts: 51
Received Thanks: 30
Quote:
Originally Posted by LordGragen. View Post
i feel there is better way to do the way i coded but idk, any idea?
Code:
if (client.Inventory.Contains(729310, 1))
{
    int[] levels = {     120,      110,     100,      90,      70,      50,      25,       1}
    int[] prizes = {14524422, 14524421, 1454875, 1447854, 1469854, 1462958, 1458958, 1458756}
    int prize = prizes[levels.First(level => level <= client.Entity.Level)];
    client.Inventory.DeleteItem(729310, 1);
     client.Inventory.Add(prize, 0, 1);
}
@Fang, just curiosity: what will happen if the inventory is full before you add the prize?
Quote:
Originally Posted by Fаng View Post
Code:
// Put this on the outside since it's always called. Looks cleaner.
client.Inventory.DeleteItem(729310, 1);
urgabel is offline  
Thanks
1 User
Old 04/11/2013, 22:27   #7
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,376
If you're going to use an array like that... you should not generate it every time the function is called.

Store it somewhere else
pro4never is offline  
Thanks
2 Users
Old 04/11/2013, 23:12   #8
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,211
Received Thanks: 4,114
Quote:
Originally Posted by urgabel View Post
@Fang, just curiosity: what will happen if the inventory is full before you add the prize?
That's not my problem, and not what my code was getting at. It was just showing a cleaner alternative.
Edit: I like your alternative btw. I do that for walking coordinates. I'm not sure I would like using it for features like that though (just preference - which we have room for since we're talking about a couple nanoseconds for a feature that's used once a year).
Spirited is offline  
Thanks
1 User
Old 04/12/2013, 00:45   #9
 
elite*gold: 0
Join Date: Sep 2012
Posts: 51
Received Thanks: 30
Quote:
Originally Posted by LordGragen. View Post
Code:
if (client.Entity.Level >= 120 && client.Entity.Level < 135)
I didn't noticed you limited it up to level 134 at most, but maybe it was not intended so...


Quote:
Originally Posted by pro4never View Post
you should not generate it every time the function is called.
Yes, that's a good appointment.


Quote:
Originally Posted by Fаng View Post
not what my code was getting at
Ok, it was just a curiosity, as I'm not used to manage private servers code. Thanks anyway for answering.
urgabel is offline  
Old 04/12/2013, 12:59   #10
 
shadowman123's Avatar
 
elite*gold: 0
Join Date: Aug 2007
Posts: 1,525
Received Thanks: 230
Or u can use smthing Like

uint ItemID = GetPrizeID(client.Entity.Level);
client.Inventory.Add(ItemID, 0, 1);
client.Inventory.Delete(w.e, 1);

static uint GetPrizeID(byte PlayerLevel)
{
If (PlayerLevel >= 15 && PlayerLevel <= 25)
{
return (ItemID that u would like to add);
}
return 0;
}

Quote:
Originally Posted by urgabel View Post
Code:
if (client.Inventory.Contains(729310, 1))
{
    int[] levels = {     120,      110,     100,      90,      70,      50,      25,       1}
    int[] prizes = {14524422, 14524421, 1454875, 1447854, 1469854, 1462958, 1458958, 1458756}
    int prize = prizes[levels.First(level => level <= client.Entity.Level)];
    client.Inventory.DeleteItem(729310, 1);
     client.Inventory.Add(prize, 0, 1);
}
@Fang, just curiosity: what will happen if the inventory is full before you add the prize?
the method Add inside Inventory already have checker about ur Inventory Items Count if its = 40 it wont allow the item to be added
shadowman123 is offline  
Old 04/12/2013, 15:06   #11
 
LordGragen.'s Avatar
 
elite*gold: 0
Join Date: Dec 2012
Posts: 606
Received Thanks: 67
ty shadow, will take a look at that for sure.


and to answer your question bro about full inv.


i am going to add a check for that,

since the quest will give more then 4 items, so i will add a check to make sure the inv have at list 5 empty spot open.

here is a exmaple for you if you like.



if (client.Inventory.Count < 37)
{
add item here
}
else
client.Send(new Message("You need to make atleast 3 free spots in your inventory.", System.Drawing.Color.Red, Message.TopLeft));
LordGragen. is offline  
Old 04/12/2013, 16:12   #12
 
shadowman123's Avatar
 
elite*gold: 0
Join Date: Aug 2007
Posts: 1,525
Received Thanks: 230
Quote:
Originally Posted by LordGragen. View Post
ty shadow, will take a look at that for sure.


and to answer your question bro about full inv.


i am going to add a check for that,

since the quest will give more then 4 items, so i will add a check to make sure the inv have at list 5 empty spot open.

here is a exmaple for you if you like.



if (client.Inventory.Count < 37)
{
add item here
}
else
client.Send(new Message("You need to make atleast 3 free spots in your inventory.", System.Drawing.Color.Red, Message.TopLeft));
y do u add checker since its already existed
shadowman123 is offline  
Thanks
1 User
Old 04/12/2013, 16:15   #13


 
KraHen's Avatar
 
elite*gold: 0
Join Date: Jul 2006
Posts: 2,216
Received Thanks: 793
Using many if cases is acceptable IMO, you could wrap them in another function though. Don`t neglect using ifs just because you can use other stuff, conditionals are always one of the fastest parts of a programming language.
KraHen is offline  
Thanks
1 User
Old 04/12/2013, 17:26   #14
 
LordGragen.'s Avatar
 
elite*gold: 0
Join Date: Dec 2012
Posts: 606
Received Thanks: 67
Quote:
Originally Posted by shadowman123 View Post
y do u add checker since its already existed
oh i know it exist i just gived him a example how i can check other way.
LordGragen. is offline  
Reply


Similar Threads Similar Threads
SOMEONE MAKE A NO LAGG AND WORKING HACK!!!!!!!
07/14/2010 - Combat Arms Hacks, Bots, Cheats & Exploits - 4 Replies
someone make WORKING,NO LAGGING hack!!!
Coming Soon!! How to make a Lagg!!
03/15/2010 - S4 League - 6 Replies
Ich werde demnächst zeigen wie man im S4 League Laggen Kann. Man hat dem entsprechen Vorteile und Warum Meine Methote nicht Gepatch oder Gefixt werden kann.
How to make SV DC on all players
05/19/2007 - Conquer Online 2 - 16 Replies
as the topic says, how to make SV disconnect on every player? at the moment I can only write down names of when you see them you disconnect, but to make it more safe, I want to make it dc on all players How to do that? text2schild.php?smilienummer=1&text=Help Appreciated, and karma awarded =D' border='0' alt='Help Appreciated, and karma awarded =D' />
Make players go red
11/26/2005 - Lin2 Exploits, Hacks, Bots, Tools & Macros - 4 Replies
Ask some1 who can cast poison to do so on you. Let him poison you until you have very low HP and slow regenerate HP. Ask some1 to pvp and let him hit you first. Then you die lol. Then he goes red and everyone starts attacking him and he will drop items :D Make sure that a friend of you is near and can pick up the items :D Well, that's it



All times are GMT +2. The time now is 07:04.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.