Jump to content
  • 0
Sign in to follow this  
icabit

for improvement

Question

i basically have this script working but i want to improve it

http://pastebin.com/gDrhMyU8

this script that i made is composed of 3 npc's in one 
freebies
daily reward
hourly reward

and referral system

line 325-337 checks if his recruiter has the same mac address

i wanted to make additional query checks for harmony
where you can check if the newbie is already recruited in his/her other account by checking if his current mac address is already registered in table 'mac' in totaltime table

 

for freebies if newbee's mac address is already in the totaltime table then no freebies

Edited by icabit

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

change

 query_sql "SELECT `last_mac` FROM `login` WHERE `account_id`="+getcharid(3),.@lastmac1$;query_sql "SELECT `last_mac` FROM `login` WHERE `account_id`="+.@accid,.@lastmac2$;if(.@lastmac1$==.@lastmac2$) {

into

 if ( query_sql( "select 1 from totaltime where last_mac = ( select last_mac from login where account_id = "+ getcharid(3) +" ) and account_id != "+ getcharid(3), .@dummy ) ) {

--edited--

.

.

btw this kind of script uses way too many query_sql in a single npc click

its better that you optimized the SQL query, like I did above ( squeezing 2 Sql_handle into 1),

otherwise this script might produce lag when used on a live server

 


 

example like the one below

 query_sql "SELECT `time` FROM `totaltime` WHERE `account_id`="+.@accid,.@rtime;//gets the time of the recruiterquery_sql "SELECT `time` FROM `totaltime` WHERE `account_id`="+getcharid(3),.@rtime2;//gets the the of the newbieif (.@rtime2>=.@rtime) //compare both times 

change into

 query_sql "select ( select time from totaltime where account_id = "+ getcharid(3) +" ) - ( select time from totaltime where account_id = "+ .@accid +" )", .@time_diff;if ( .@time_diff > 0 ) //compare both times ... if positive numbers

Edited by AnnieRuru

Share this post


Link to post
Share on other sites
  • 0

 

change

query_sql "SELECT `last_mac` FROM `login` WHERE `account_id`="+getcharid(3),.@lastmac1$;query_sql "SELECT `last_mac` FROM `login` WHERE `account_id`="+.@accid,.@lastmac2$;if(.@lastmac1$==.@lastmac2$) {
into

if ( query_sql( "select 1 from login where last_mac = ( select last_mac from login where account_id = "+ getcharid(3) +" ) and account_id != "+ getcharid(3), .@dummy ) ) {
.

.

btw this kind of script uses way too many query_sql in a single npc click

its better that you optimized the SQL query, like I did above ( squeezing 2 Sql_handle into 1),

otherwise this script might produce lag when used on a live server

 


 

example like the one below

query_sql "SELECT `time` FROM `totaltime` WHERE `account_id`="+.@accid,.@rtime;//gets the time of the recruiterquery_sql "SELECT `time` FROM `totaltime` WHERE `account_id`="+getcharid(3),.@rtime2;//gets the the of the newbieif (.@rtime2>=.@rtime) //compare both times
change into

query_sql "select ( select time from totaltime where account_id = "+ getcharid(3) +" ) - ( select time from totaltime where account_id = "+ .@accid +" )", .@time_diff;if ( .@time_diff > 0 ) //compare both times ... if positive numbers

 

thx annie ill test these things and try to understand how it works

im noob with queries using athena style

 

 

after checking out the things you gave me i learned something new :D

 

now i can finally check if the mac address of the newbee has already have a recruiter

so a mac address can only be recruited once :D

 

into

 

[cbox]if ( query_sql( "select 1 from totaltime where mac = ( select last_mac from login where account_id = "+ getcharid(3) +" ) and account_id != "+ getcharid(3), .@dummy ) ) {[/cbox]

 

thx a lot annie!

Edited by icabit

Share this post


Link to post
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.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.