Let's use in here script_commands.txt example: https://github.com/rathena/rathena/blob/master/doc/script_commands.txt#L9179
you use it like this:
totalCards = query_sql("SELECT COUNT(*) FROM player_cards WHERE account_id = '" + getcharid(3) + "'");
basically totalCards will receive 1 if the query_sql is executed successfully or 0 in case of failure, now the values to which you are doing the SELECT need a scope in which they will always be an array of values, in your case as a sum of all the values in the table referring to the account id, so the array will only have one index with the result, so you would have to do it like this:
prontera,140,174,4 script Personal storage2#prt 113,{
OnInit:
// Query of obtained cards
query_sql("SELECT COUNT(*) FROM player_cards WHERE account_id = '" + getcharid(3) + "'",.@totalCards);
// totalCards = query_sql("SELECT COUNT(card_id) FROM player_cards WHERE account_id = '" + getcharid(3) + "'");
mes "[Card Album]";
mes "Here, let me open";
mes "your Card record.";
//Ex1
mes "You have collected " + .@totalCards + " cards out of 1009.";
//Ex2
mes "You have collected " + .@totalCards[0] + " cards out of 1009.";
mes "Thank you for using";
mes "the Kafra Service.";
close;
}
Remembering that you cannot use the OnInit label and then use commands that are common to rid (player) without attaching rid (player) as in the case of the "mes","getcharid(3)" and "close" commands, this will cause an error on the stating emulator that there is no rid attached, I hope you understand what I tried to explain