Bin4ry Posted September 29, 2012 Posted September 29, 2012 Here's my script, the beginning few ID works but ID at behind doesn't drop. No error at all. Tried to raise rate to 5000 to test, still the same. - script MobExtraDrops -1,{ OnNPCKillEvent: // Configuration setarray .@MobID[0], 1374, 1370, 1754, 1492, 1871, 1150, 1147, 1243, 1039, 1115, 1148, 1167, 1159, 1163, 1276, 1685, 1369, 1110; // Monsters ID setarray .@DropID[0], 28307, 28308, 28108, 28304, 28209, 28114, 28102, 28319, 28134, 28135, 28136, 28137, 28142, 28143, 28143, 28221, 28322, 28132; // Items ID setarray .@Chance[0], 75, 75, 250, 250, 250, 250, 250, 75, 250, 250, 100, 75, 250, 75, 75, 250, 75, 75; // Drop Rate, as in percentage (100 = 1%) // End of Config for(set @c,0; @c < getarraysize(.@MobID); set @c, @c + 1) { if (killedrid == .@MobID[@c]){ set @d, rand(0,10000); if (@d <= .@Chance[@c]) { getitem .@DropID[@c],1; } } end; } } // MVP ID Backup // setarray @MobID,1038,1039,1046,1150,1511,1647,1785,1630,1874,1272, // 1719,1389,1112,1115,1418,1871,1252,1768,1086,1990, // 1649,1651,1832,1492,1734,1779,1251,1688,1646,1373, // 1147,1059,1150,1087,1190,1157,1159,1623,1650,1708, // 1583,1991,1312,1751,1685,1658,1648,1917,1885; Quote
GmOcean Posted September 29, 2012 Posted September 29, 2012 - script MobExtraDrops -1,{ OnNPCKillEvent: // Configuration setarray .@MobID[0], 1374, 1370, 1754, 1492, 1871, 1150, 1147, 1243, 1039, 1115, 1148, 1167, 1159, 1163, 1276, 1685, 1369, 1110; // Monsters ID setarray .@DropID[0], 28307, 28308, 28108, 28304, 28209, 28114, 28102, 28319, 28134, 28135, 28136, 28137, 28142, 28143, 28143, 28221, 28322, 28132; // Items ID setarray .@Chance[0], 75, 75, 250, 250, 250, 250, 250, 75, 250, 250, 100, 75, 250, 75, 75, 250, 75, 75; // Drop Rate, as in percentage (100 = 1%) // End of Config for(set .@c,0; .@c < getarraysize(.@MobID); set .@c, .@c + 1) { if (killedrid == .@MobID[.@c]){ set .@d, rand(0,10000); if (.@d <= .@Chance[.@c]) { getitem .@DropID[.@c],1; } } } end; } // MVP ID Backup // setarray @MobID,1038,1039,1046,1150,1511,1647,1785,1630,1874,1272, // 1719,1389,1112,1115,1418,1871,1252,1768,1086,1990, // 1649,1651,1832,1492,1734,1779,1251,1688,1646,1373, // 1147,1059,1150,1087,1190,1157,1159,1623,1650,1708, // 1583,1991,1312,1751,1685,1658,1648,1917,1885; Firstly since your using an OnNPCKillEvent, it'll be better to use temporary variables, in this case, .@c & .@d. No need to store the data if you don't need to. Secondly i changed the end; command to AFTER the for() command, to stop it from ending prematurely thus not reaching the other monsters. Because from what i can see your script was doing this: Kill monster -> Check to see if monster == information in array ->if yes: work properly -> if no: end; -> no more checks. Quote
Bin4ry Posted September 29, 2012 Author Posted September 29, 2012 (edited) Is it better if I implement a src function instead using script check on every NPCKill? Sounds better for resource-wise. (Of course with a file in /db) Edited September 29, 2012 by darristan Quote
Euphy Posted September 29, 2012 Posted September 29, 2012 Why not just add them as mob drops? o.o Quote
GmOcean Posted September 29, 2012 Posted September 29, 2012 It might be for event purposes were they only drop at blah blah time / MAP. Also, alot of monsters have their drop slots filled. So to add more we'd need to edit the src. Quote
Bin4ry Posted September 29, 2012 Author Posted September 29, 2012 Some mob drop slots are filled and I don't wanna touch mob_db how much can an array hold? Quote
GmOcean Posted September 29, 2012 Posted September 29, 2012 256 if i remember correctly. Which is why most people have made the conversion to SQL. Since SQL can hold well over 1,000 different rows/columns. In short, i could make a database where 1 monster could drop over 1,000 items, and each of them have their own drop rate. Quote
Bin4ry Posted September 29, 2012 Author Posted September 29, 2012 That sounds like querying the db a lot Quote
GmOcean Posted September 29, 2012 Posted September 29, 2012 Yes, but if your script is written correctly, you can easily just ping a specific part of your db producing everything as needed. But its still no different than killing a mob normally. See right now it'll do this without a sql db. Kill monster -> Ping db to get drop info -> calculate chane -> give item. if you added another sql db file for your custom script it'll do this. Kill monster -> ping db to get drop info -> calculate chance -> give item -> ping custom db to get drop info -> calculate chance -> give item. It's basically the same as having 2x your player count. So if you had 100 people kiling stuff, its the same as if you had 200 people killing stuff. Not that bad really, considering most hosting packages offer you more than the needed amount for players. Example: a Hosting pack of 1-200 players can easily host 500 players without lag. In short,if you write the script correctly, your server won't even feel it. Quote
Euphy Posted September 29, 2012 Posted September 29, 2012 @GMOcean: Arrays hold 128 values, not 256. @darristan: You can have duplicate entries in mob_db2, which will overwrite anything in mob_db. Another way to do this without looping through arrays is by creating NPC variables based on array name, then doing a single comparison: - script MobExtraDrops -1,{ OnNPCKillEvent: if (getd("."+killedrid) && rand(10000) <= getd("."+killedrid+"[1]")) getitem getd("."+killedrid+"[0]"),1; end; OnInit: setarray .@MobID[0], 1374, 1370, 1754, 1492, 1871, 1150, 1147, 1243, 1039, 1115, 1148, 1167, 1159, 1163, 1276, 1685, 1369, 1110; // Monsters ID setarray .@DropID[0],28307,28308,28108,28304,28209,28114,28102,28319,28134,28135,28136,28137,28142,28143,28143,28221,28322,28132; // Items ID setarray .@Chance[0], 75, 75, 250, 250, 250, 250, 250, 75, 250, 250, 100, 75, 250, 75, 75, 250, 75, 75; // Drop Rate, as in percentage (100 = 1%) set .@j, getarraysize(.@MobID); for(set .@i,0; .@i<.@j; set .@i,.@i+1) setarray getd("."+.@MobID[.@i]+"[0]"),.@DropID[.@i],.@Chance[.@i]; end; } Quote
GmOcean Posted September 29, 2012 Posted September 29, 2012 O.o; Then where the hell did i get the value of 256.... Maybe from my military work lol, 8months on learning internet protocol for 16hours a day probably did it for me @.@ Quote
Question
Bin4ry
Here's my script, the beginning few ID works but ID at behind doesn't drop. No error at all. Tried to raise rate to 5000 to test, still the same.
10 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.