iZeal Posted August 1, 2014 Group: Members Topic Count: 10 Topics Per Day: 0.00 Content Count: 55 Reputation: 2 Joined: 06/09/14 Last Seen: August 15, 2014 Share Posted August 1, 2014 Hello Guys, I'm trying to modify a script for max level reward but I'm stuck on sql query. regarding checking if how many key entry are already inside acc_reg_num_db like for example it will check if there is already 50 entry of #99reward Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Euphy Posted August 1, 2014 Group: Members Topic Count: 72 Topics Per Day: 0.02 Content Count: 2997 Reputation: 1132 Joined: 05/27/12 Last Seen: June 1, 2017 Share Posted August 1, 2014 SQL has a 'COUNT()' function: http://www.w3schools.com/sql/sql_func_count.asp Though I suggest you just keep a global variable instead (and sync it with SQL if necessary once when the server starts), since there's no point running the query repeatedly--that'd be much slower than checking a global. Quote Link to comment Share on other sites More sharing options...
iZeal Posted August 1, 2014 Group: Members Topic Count: 10 Topics Per Day: 0.00 Content Count: 55 Reputation: 2 Joined: 06/09/14 Last Seen: August 15, 2014 Author Share Posted August 1, 2014 I'm doing this for my race to lvl 99 reward because it's only for 1 claim per account., and it's only meant for 100 players else if 100 players already claimed the npc will hide. that's why I'm using #99reward because I restrict for account. Quote Link to comment Share on other sites More sharing options...
Euphy Posted August 1, 2014 Group: Members Topic Count: 72 Topics Per Day: 0.02 Content Count: 2997 Reputation: 1132 Joined: 05/27/12 Last Seen: June 1, 2017 Share Posted August 1, 2014 So use a global variable ($var) to keep track of how many players have gotten the reward, i.e. increment it every time you give one. Much simpler than counting database entries. Quote Link to comment Share on other sites More sharing options...
iZeal Posted August 2, 2014 Group: Members Topic Count: 10 Topics Per Day: 0.00 Content Count: 55 Reputation: 2 Joined: 06/09/14 Last Seen: August 15, 2014 Author Share Posted August 2, 2014 if i use that maybe it will not be 1 per account.? Quote Link to comment Share on other sites More sharing options...
Cydh Posted August 2, 2014 Group: Developer Topic Count: 153 Topics Per Day: 0.03 Content Count: 2285 Reputation: 747 Joined: 06/16/12 Last Seen: February 21 Share Posted August 2, 2014 if i use that maybe it will not be 1 per account.? $ <- global var # <- account var Quote Link to comment Share on other sites More sharing options...
Capuche Posted August 2, 2014 Group: Developer Topic Count: 10 Topics Per Day: 0.00 Content Count: 2407 Reputation: 616 Joined: 07/05/12 Last Seen: March 20 Share Posted August 2, 2014 sth like this if ( #reward_account ) { mes "already claimed"; close; } getitem ... $total_claimed++; if ( $total_claimed > 100 ) disablenpc Quote Link to comment Share on other sites More sharing options...
Question
iZeal
Hello Guys, I'm trying to modify a script for max level reward
but I'm stuck on sql query.
regarding checking if how many key entry are already inside acc_reg_num_db
like for example it will check if there is already 50 entry of #99reward
Thanks in advance.
Link to comment
Share on other sites
6 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.