WhiteEagle Posted November 15, 2012 Group: Members Topic Count: 79 Topics Per Day: 0.02 Content Count: 480 Reputation: 67 Joined: 08/28/12 Last Seen: 29 minutes ago Share Posted November 15, 2012 Hi guys, know anyone how to script a npc, which display the /blacksmith and /alchemist ranking. Because I want give the first 3 ppls a bonus effect. Like: if (blacksmithrank == 3) { He got a luck bonus of 3 } if (blacksmithrank == 2) { He got a luck bonus of 4 } if (blacksmithrank == 1) { He got a luck bonus of 5 } Thanks in advance. Quote Link to comment Share on other sites More sharing options...
GmOcean Posted November 15, 2012 Group: Members Topic Count: 31 Topics Per Day: 0.01 Content Count: 666 Reputation: 93 Joined: 04/27/12 Last Seen: August 17, 2015 Share Posted November 15, 2012 That's not too hard, all the information needed is stored in the sale files if I'm not mistaken. The only tricky part is giving them the bonus indefinitely. But this is only because rA's current script engine will make those bonus reset upon adding stats. But thankfully we have freeloop() command. So we can just do: freeloop(bonus bLuk, 3;); Quote Link to comment Share on other sites More sharing options...
WhiteEagle Posted November 15, 2012 Group: Members Topic Count: 79 Topics Per Day: 0.02 Content Count: 480 Reputation: 67 Joined: 08/28/12 Last Seen: 29 minutes ago Author Share Posted November 15, 2012 Thanks for your answer. Thats help me much. But the question is, how I can do that the npc display the ranking. Example: if (blacksmithrank == 3) { I don't know the value to check this. Sorry for my questions. x_X Quote Link to comment Share on other sites More sharing options...
GmOcean Posted November 15, 2012 Group: Members Topic Count: 31 Topics Per Day: 0.01 Content Count: 666 Reputation: 93 Joined: 04/27/12 Last Seen: August 17, 2015 Share Posted November 15, 2012 Well, at my I'm at work, so I can't really go looking through my sql files. But, there is a database which stores ranking information. So try and run a sql query for the information and store it like that. eg: query_sql( "SELECT * FROM 'table' ORDER BY DESC LIMIT='3'",.@char_id,.@ranking); Something like that, I'd be able to help more when I get home. Quote Link to comment Share on other sites More sharing options...
WhiteEagle Posted November 15, 2012 Group: Members Topic Count: 79 Topics Per Day: 0.02 Content Count: 480 Reputation: 67 Joined: 08/28/12 Last Seen: 29 minutes ago Author Share Posted November 15, 2012 query_sql( "SELECT * FROM 'table' ORDER BY DESC LIMIT='3'",.@char_id,.@ranking); Something like this I searching, but nothing found. Many thanks that you try to help me. I hope you find a solution. Quote Link to comment Share on other sites More sharing options...
Aleos Posted November 15, 2012 Group: Development Manager Topic Count: 56 Topics Per Day: 0.01 Content Count: 732 Reputation: 525 Joined: 12/13/11 Last Seen: June 13, 2024 Share Posted November 15, 2012 (edited) // Blacksmith ranking list query_sql "SELECT `fame`,`name` FROM `char` WHERE `fame`>0 AND (`class`='10' OR `class`='4011' OR `class`='4033' OR `class`='4058' OR `class`='4064' OR `class`='4100') ORDER BY `fame` DESC LIMIT 0,3", .@fame, .@name); for( set .@i,0; .@i < 3; set .@i,.@i + 1 ) { mes "Top 3 Blacksmiths"; mes .@i + 1 + ". " + .@name + " with fame of: " + .@fame + "."; } // Alchemist ranking list query_sql "SELECT `fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='18' OR `class`='4019' OR `class`='4041' OR `class`='4071' OR `class`='4078' OR `class`='4107') ORDER BY `fame` DESC LIMIT 0,3", .@fame, .@name); for( set .@i,0; .@i < 3; set .@i,.@i + 1 ) { mes "Top 3 Blacksmiths"; mes .@i + 1 + ". " + .@name + " with fame of: " + .@fame + "."; } That prints out the top 3 Blacksmith and Alchemist classes from the fame list. You can do whatever you want with it from there. The two important parts are the queries. Edited November 15, 2012 by Aleos Quote Link to comment Share on other sites More sharing options...
WhiteEagle Posted November 15, 2012 Group: Members Topic Count: 79 Topics Per Day: 0.02 Content Count: 480 Reputation: 67 Joined: 08/28/12 Last Seen: 29 minutes ago Author Share Posted November 15, 2012 (edited) Wow nice. Thank you. I have test it now and added some own changes that it work. (.@name$ and .@fame$) algaia,205,161,4 script Test Rank 100,{ mes "[Ranker]"; mes "Which ranking you want to see?"; next; switch(select("Blacksmith:Alchemist")){ case 1: query_sql "SELECT `fame`,`name` FROM `char` WHERE `fame`>0 AND (`class`='10' OR `class`='4011' OR `class`='4033' OR `class`='4058' OR `class`='4064' OR `class`='4100') ORDER BY `fame` DESC LIMIT 0,3", .@fame$, .@name$; for( set .@i,0; .@i < 3; set .@i,.@i + 1 ) { mes "======================="; mes "Top 1 Blacksmith"; mes .@i + 1 + ". " + .@name$ + " with fame of: " + .@fame$ + "."; mes "======================="; mes "Top 2 Blacksmith"; mes .@i + 1 + ". " + .@name$ + " with fame of: " + .@fame$ + "."; mes "======================="; mes "Top 3 Blacksmith"; mes .@i + 1 + ". " + .@name$ + " with fame of: " + .@fame$ + "."; mes "======================="; close; } My problem is now, only one person will be displayed. Edited November 15, 2012 by WhiteEagle Quote Link to comment Share on other sites More sharing options...
GmOcean Posted November 15, 2012 Group: Members Topic Count: 31 Topics Per Day: 0.01 Content Count: 666 Reputation: 93 Joined: 04/27/12 Last Seen: August 17, 2015 Share Posted November 15, 2012 (edited) That's because, those variables, are not just regular vars, they are arrays. for( set .@i,0; .@i<3; set .@i,.@i+1){ mes "======================="; mes "Top "+ ( .@i + 1 ) +" Blacksmith"; mes ( .@i + 1 ) +". "+ .@name$[.@i] +" with fame of: "+ .@fame$[.@i] +"."; mes "=======================";} close; Edit: Also, i could have sworn, ' fame ' was stored as an integer in the sql_db. So, I really don't think you need to have stored into a str_variable. So, your sql_query should look like this: query_sql "SELECT `fame`,`name` FROM `char` WHERE `fame`>0 AND (`class`='10' OR `class`='4011' OR `class`='4033' OR `class`='4058' OR `class`='4064' OR `class`='4100') ORDER BY `fame` DESC LIMIT 0,3", .fame, .name$; The reason, i used .variables, is because you also said you wanted to give these players a bonus of 3 luk or w/e. So we'd need to be able to get this information. a .@scope variable, would dissapear as soon as the script ended. For getting the bonuses, i suggest, you use the NPC to do it, for a set time, such as give the stats to those who are #1-3 for 1day, then check for the new people lol. OnInit: //Just let it run to the next label =P donpcevent "npcname::OnFameLoop"; OnClock0000: query_sql "SELECT `fame`,`name` FROM `char` WHERE `fame`>0 AND (`class`='10' OR `class`='4011' OR `class`='4033' OR `class`='4058' OR `class`='4064' OR `class`='4100') ORDER BY `fame` DESC LIMIT 0,3", .fame, .name$; end; OnFameLoop: freeloop(1); while(1){ if( attachrid( getcharid(3, .name$[0]) ){ bonus bLuk,3; detachrid;} if( attachrid( getcharid(3, .name$[1]) ){ bonus bLuk,3; detachrid;} if( attachrid( getcharid(3, .name$[2]) ){ bonus bLuk,3; detachrid;} } end; In regards to the looping for bonuses, yea, it's pretty bad, i know, but unless you use a src edit (which is already out: Extra Bonuses), almost all scripts like this are gonna be costly. Edited November 15, 2012 by GmOcean Quote Link to comment Share on other sites More sharing options...
WhiteEagle Posted November 15, 2012 Group: Members Topic Count: 79 Topics Per Day: 0.02 Content Count: 480 Reputation: 67 Joined: 08/28/12 Last Seen: 29 minutes ago Author Share Posted November 15, 2012 It work perfectly. Thank you and thanks at all. I will try now, to add the first 3 ppls the "freeloop(bonus bLuk, 3;);" bonus per "OnPCLoginEvent:" Quote Link to comment Share on other sites More sharing options...
Aleos Posted November 15, 2012 Group: Development Manager Topic Count: 56 Topics Per Day: 0.01 Content Count: 732 Reputation: 525 Joined: 12/13/11 Last Seen: June 13, 2024 Share Posted November 15, 2012 Sorry, glad you got it going. I've been messing with PHP all day and switched over to eA NPC script and forgot some stuff. Quote Link to comment Share on other sites More sharing options...
WhiteEagle Posted November 15, 2012 Group: Members Topic Count: 79 Topics Per Day: 0.02 Content Count: 480 Reputation: 67 Joined: 08/28/12 Last Seen: 29 minutes ago Author Share Posted November 15, 2012 @Aleos Thanks. I changed it now like this: algaia,205,161,4 script Test Rank 100,{ mes "[blacksmith Ranking]"; query_sql "SELECT `fame`,`name` FROM `char` WHERE `fame`>0 AND (`class`='10' OR `class`='4011' OR `class`='4033' OR `class`='4058' OR `class`='4064' OR `class`='4100') ORDER BY `fame` DESC LIMIT 0,1", .@fame$, .@name$; query_sql "SELECT `fame`,`name` FROM `char` WHERE `fame`>0 AND (`class`='10' OR `class`='4011' OR `class`='4033' OR `class`='4058' OR `class`='4064' OR `class`='4100') ORDER BY `fame` DESC LIMIT 1,2", .@fame2$, .@name2$; query_sql "SELECT `fame`,`name` FROM `char` WHERE `fame`>0 AND (`class`='10' OR `class`='4011' OR `class`='4033' OR `class`='4058' OR `class`='4064' OR `class`='4100') ORDER BY `fame` DESC LIMIT 2,3", .@fame3$, .@name3$; mes "======================="; mes "Top 1 Blacksmith"; mes ""+ .@name$ +" with fame of: "+ .@fame$ +"."; set rank,1; mes "======================="; mes "Top 2 Blacksmith"; mes ""+ .@name2$ +" with fame of: "+ .@fame2$ +"."; set rank,2; mes "======================="; mes "Top 3 Blacksmith"; mes ""+ .@name3$ +" with fame of: "+ .@fame3$ +"."; mes "======================="; set rank,3; close; OnPCLoginEvent: if(rank == 1){ atcommand "@aura 701"; dispbottom "You are on the first place."; } if(rank == 2){ atcommand "@aura 701"; dispbottom "You are on the second place."; } if(rank == 3){ atcommand "@aura 701"; dispbottom "You are on the third place."; } end; } My problem is now, how to set set rank,1; , set rank,2; and set rank,3; each ppls without talking the npc. If I speak with the npc, I get the set rank,3; I need it to get automatic. X_X Sry for my english. Quote Link to comment Share on other sites More sharing options...
Emistry Posted November 15, 2012 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2370 Joined: 10/28/11 Last Seen: Sunday at 05:32 PM Share Posted November 15, 2012 (edited) try this.. http://pastebin.com/raw.php?i=rd1s8qid Edit : Some Mistake... change mes ""+.Name[.@i]+" - Fame : "+.Fame; into mes ""+.Name[.@i]+" - Fame : "+.Fame[.@i]; Edited November 15, 2012 by Emistry 1 Quote Link to comment Share on other sites More sharing options...
stydianx Posted November 15, 2012 Group: Members Topic Count: 105 Topics Per Day: 0.02 Content Count: 390 Reputation: 27 Joined: 07/12/12 Last Seen: October 24, 2022 Share Posted November 15, 2012 try this.. http://pastebin.com/raw.php?i=rd1s8qid does it still need SQL in this script? Quote Link to comment Share on other sites More sharing options...
WhiteEagle Posted November 15, 2012 Group: Members Topic Count: 79 Topics Per Day: 0.02 Content Count: 480 Reputation: 67 Joined: 08/28/12 Last Seen: 29 minutes ago Author Share Posted November 15, 2012 (edited) [/code]I don't know, what we do without you Emistry. It make me happy, that I learned today new stuff. Thanks (It works exactly how I wanted it.) @Emistry: Edit : Some Mistake... Yea, I have seen that. ^-^ But thanks. <3 And I need to change this: mes ""+.Name[.@i]+" - Fame : "+.Fame[.@i]; to mes ""+.Name$[.@i]+" - Fame : "+.Fame[.@i]; Edited November 15, 2012 by WhiteEagle Quote Link to comment Share on other sites More sharing options...
Question
WhiteEagle
Hi guys,
know anyone how to script a npc, which display
the /blacksmith and /alchemist ranking.
Because I want give the first 3 ppls a bonus effect.
Like:
if (blacksmithrank == 3) {
He got a luck bonus of 3
}
if (blacksmithrank == 2) {
He got a luck bonus of 4
}
if (blacksmithrank == 1) {
He got a luck bonus of 5
}
Thanks in advance.
Link to comment
Share on other sites
13 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.