• 0
Sign in to follow this  
caspa

simplify scripts who's online

Question

hi this is part of the script that lets you see and display all online characters on the server right now

what i'm trying to do is if a character has a VIP ticket there would be a "(VIP)" next to his name.. so far i have done this... however is there a much more efficient?

mes "[ Control Panel ]";
mes "^ff0000Online Users^000000 :";
        //----------------------------------------------------------------------------------------------------------------
        set [email protected], query_sql( "SELECT `name` FROM `char` WHERE `online` = 1 AND `account_id` NOT IN ( SELECT `account_id` FROM `login` WHERE `level` > 0 ) ORDER BY `name` DESC LIMIT 128", [email protected]$ );
        //-----------------------------------------------------------------------------------------------------------------
               for( set [email protected],0; [email protected] < [email protected]; set [email protected],[email protected]+1 ) {
        //---------------------------------------------------------------------------
        set [email protected], getcharid(0,[email protected]$[[email protected]]);
        set [email protected], getcharid(0,[email protected]$[[email protected]]);
        set [email protected], 21026;
        set [email protected], countitem(21026);
        set [email protected], 21027;
        set [email protected], countitem(21027);
        //---------------------------------------------------------------------------
        query_sql("SELECT SUM(`amount`) FROM `inventory` WHERE `char_id` = "[email protected]+" AND `nameid` = "[email protected],[email protected]);    
        query_sql("SELECT SUM(`amount`) FROM `inventory` WHERE `char_id` = "[email protected]+" AND `nameid` = "[email protected],[email protected]);
        //---------------------------------------------------------------------------
        mes "^0000ff"+( [email protected]+1 ) +".^000000 ^007700"+ [email protected]$[[email protected]] +" "+( [email protected] == 1 ? "(VIP)" : "" ) +""+( [email protected] == 1 ? "(VIP)" : "" ) +"^000000";
        }

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

maybe something like this ?

prontera,155,181,5	script	Sample	4_F_KAFRA1,{
	[email protected]_aid = getcharid(3);
	[email protected]$ = "SELECT c.`account_id`,c.`name`,c.`online`, SUM(ISNULL(i.`amount`, 0)) "
		+ "FROM `char` c "
		+ "INNER JOIN `inventory` i ON c.`char_id` = i.`char_id` AND i.`nameid` IN (21026, 210267) "
		+ "WHERE c.`account_id` IN (SELECT `account_id` FROM `login` WHERE `level` > 0) "
		// + "AND c.`online` = 1 "
		+ "GROUP BY i.`char_id` "
		+ "ORDER BY c.`name`";
	[email protected] = query_sql([email protected]$, [email protected], [email protected]$, [email protected], [email protected]);
	mes "Found "[email protected]+" Record(s)";
	for ([email protected] = 0; [email protected] < [email protected]; [email protected]++) {
		if ([email protected][[email protected]]) {
			if (attachrid([email protected][[email protected]]))
				[email protected][[email protected]] = (countitem(21026) + countitem(210267));
			attachrid([email protected]_aid);
		}
		mes "^0000FF"+([email protected]+1) +". ^007700"+ [email protected]$[[email protected]] +" "+([email protected][[email protected]] ? "(VIP)" : "" )+" - ^007700"+([email protected][[email protected]] ? "Online":"Offline" )+"^000000";	
	}
	close;
}

it shall include offline players too.

Share this post


Link to post
Share on other sites
  • 0
15 hours ago, Emistry said:

maybe something like this ?

prontera,155,181,5	script	Sample	4_F_KAFRA1,{
	[email protected]_aid = getcharid(3);
	[email protected]$ = "SELECT c.`account_id`,c.`name`,c.`online`, SUM(ISNULL(i.`amount`, 0)) "
		+ "FROM `char` c "
		+ "INNER JOIN `inventory` i ON c.`char_id` = i.`char_id` AND i.`nameid` IN (21026, 210267) "
		+ "WHERE c.`account_id` IN (SELECT `account_id` FROM `login` WHERE `level` > 0) "
		// + "AND c.`online` = 1 "
		+ "GROUP BY i.`char_id` "
		+ "ORDER BY c.`name`";
	[email protected] = query_sql([email protected]$, [email protected], [email protected]$, [email protected], [email protected]);
	mes "Found "[email protected]+" Record(s)";
	for ([email protected] = 0; [email protected] < [email protected]; [email protected]++) {
		if ([email protected][[email protected]]) {
			if (attachrid([email protected][[email protected]]))
				[email protected][[email protected]] = (countitem(21026) + countitem(210267));
			attachrid([email protected]_aid);
		}
		mes "^0000FF"+([email protected]+1) +". ^007700"+ [email protected]$[[email protected]] +" "+([email protected][[email protected]] ? "(VIP)" : "" )+" - ^007700"+([email protected][[email protected]] ? "Online":"Offline" )+"^000000";	
	}
	close;
}

it shall include offline players too.

solved thank you

Share this post


Link to post
Share on other sites
  • 0
On 5/7/2019 at 8:54 AM, caspa said:

solved thank you

Can you please post how it was solved? thanks!

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.   Paste as plain text instead

  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