for improvement

icabit

New member
Messages
45
Points
0
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

 
Last edited by a moderator:
change

Code:
 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

Code:
 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

Code:
 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

Code:
 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
 
Last edited by a moderator:
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
Code:
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 timeschange into
Code:
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
default_biggrin.png


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
default_biggrin.png


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!

 
Last edited by a moderator:
Back
Top