Hey rAthena. I've been breaking my head about this for the past 2 hours. Someone care to take a look at it?
I'm using the online peak NPC but want that, when a new peak is reached, every player gets 5x one type of the items in ".@RandItem[0]" array. I use a query to store the items in their storage but it simply isn't happening.
The announcement is working fine and the server doesn't return any kind of error. What am I doing wrong here? I've tried different combinations of ".@RandItem"
Thanks in advance
- script Highest Peak -1,{
OnPCLoginEvent:
// Assign current number of online players
sleep 1000;
.onlineusers = getusers(1);
// Today's date
.date$ = gettime(DT_YEAR)+"-"+gettime(DT_MONTH)+"-"+gettime(DT_DAYOFMONTH);
// Query for the highest peak in the database
query_sql("SELECT `users` FROM `" + .sqltable$ + "` ORDER BY `users` LIMIT 1",.@countusers);
if(getarraysize(.@countusers) == 0) {
// There doesn't seem to be a row in our table, so lets create one
query_sql("INSERT INTO `" + .sqltable$ + "` (`users`, `date`) VALUES (" + .onlineusers + ", '" + .date$ + "')");
} else {
if(.onlineusers > .@countusers[0]) {
// This is where we check if we want to announce a new peak
if(.displaypeakannounce == 1){
announce "[ Server ] We have reached a new population peak, we now have "+.onlineusers+" online players! Therefore we've decided to give you all a little surprise, re-log and check your storage to find out what it is!~ ",bc_all;
// Replace the
query_sql "INSERT INTO `storage` (`id`, `account_id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `card0`, `card1`, `card2`, `card3`, `expire_time`, `unique_id`) "+
"SELECT NULL, `login`.`account_id`, '.@RandItem', '5', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0' FROM `login` WHERE `account_id` > 1";
}
// Now lets update the table with our new player peak
query_sql("UPDATE `" + .sqltable$ + "` SET `users` = '" + .onlineusers + "', `date` = '" + .date$ + "'");
}
}
end;
OnInit:
// CONFIGS
// We need an SQL table name first
.sqltable$ = "cp_onlinepeak";
// Would you like an announcement when you reach a higher peak?
// 1 = Yes
// 0 = No
.displaypeakannounce = 1;
// ITEM REWARD
// 14534 = Medium life potion
// 12299 = Mega resist potion
// 12354 = Buche de Noel
// 12196 = Plain Rice Cake
// 12123 = Honey Pastry
setarray .@RandItem[0],14534,12299,12354,12195,12123;
set .@RandItemCount,getarraysize(.@RandItem);
//getitem(.@Randitem[rand(.@RandItemCount)],5); - We will use SQL so this will not be important.
// END CONFIGS
}
Question
HristDead
Hey rAthena. I've been breaking my head about this for the past 2 hours. Someone care to take a look at it?
I'm using the online peak NPC but want that, when a new peak is reached, every player gets 5x one type of the items in ".@RandItem[0]" array. I use a query to store the items in their storage but it simply isn't happening.
The announcement is working fine and the server doesn't return any kind of error. What am I doing wrong here? I've tried different combinations of ".@RandItem"
Thanks in advance
- script Highest Peak -1,{ OnPCLoginEvent: // Assign current number of online players sleep 1000; .onlineusers = getusers(1); // Today's date .date$ = gettime(DT_YEAR)+"-"+gettime(DT_MONTH)+"-"+gettime(DT_DAYOFMONTH); // Query for the highest peak in the database query_sql("SELECT `users` FROM `" + .sqltable$ + "` ORDER BY `users` LIMIT 1",.@countusers); if(getarraysize(.@countusers) == 0) { // There doesn't seem to be a row in our table, so lets create one query_sql("INSERT INTO `" + .sqltable$ + "` (`users`, `date`) VALUES (" + .onlineusers + ", '" + .date$ + "')"); } else { if(.onlineusers > .@countusers[0]) { // This is where we check if we want to announce a new peak if(.displaypeakannounce == 1){ announce "[ Server ] We have reached a new population peak, we now have "+.onlineusers+" online players! Therefore we've decided to give you all a little surprise, re-log and check your storage to find out what it is!~ ",bc_all; // Replace the query_sql "INSERT INTO `storage` (`id`, `account_id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `card0`, `card1`, `card2`, `card3`, `expire_time`, `unique_id`) "+ "SELECT NULL, `login`.`account_id`, '.@RandItem', '5', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0' FROM `login` WHERE `account_id` > 1"; } // Now lets update the table with our new player peak query_sql("UPDATE `" + .sqltable$ + "` SET `users` = '" + .onlineusers + "', `date` = '" + .date$ + "'"); } } end; OnInit: // CONFIGS // We need an SQL table name first .sqltable$ = "cp_onlinepeak"; // Would you like an announcement when you reach a higher peak? // 1 = Yes // 0 = No .displaypeakannounce = 1; // ITEM REWARD // 14534 = Medium life potion // 12299 = Mega resist potion // 12354 = Buche de Noel // 12196 = Plain Rice Cake // 12123 = Honey Pastry setarray .@RandItem[0],14534,12299,12354,12195,12123; set .@RandItemCount,getarraysize(.@RandItem); //getitem(.@Randitem[rand(.@RandItemCount)],5); - We will use SQL so this will not be important. // END CONFIGS }
Link to comment
Share on other sites
2 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.