Jump to content
  • 0

simplify scripts who's online


caspa

Question


  • Group:  Members
  • Topic Count:  194
  • Topics Per Day:  0.04
  • Content Count:  499
  • Reputation:   3
  • Joined:  03/11/12
  • Last Seen:  

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 .@size, 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", .@name$ );
        //-----------------------------------------------------------------------------------------------------------------
               for( set .@i,0; .@i < .@size; set .@i,.@i+1 ) {
        //---------------------------------------------------------------------------
        set .@cid, getcharid(0,.@name$[.@i]);
        set .@did, getcharid(0,.@name$[.@i]);
        set .@item1, 21026;
        set .@count1, countitem(21026);
        set .@item2, 21027;
        set .@count2, countitem(21027);
        //---------------------------------------------------------------------------
        query_sql("SELECT SUM(`amount`) FROM `inventory` WHERE `char_id` = "+.@cid+" AND `nameid` = "+.@item1,.@count1);    
        query_sql("SELECT SUM(`amount`) FROM `inventory` WHERE `char_id` = "+.@did+" AND `nameid` = "+.@item2,.@count2);
        //---------------------------------------------------------------------------
        mes "^0000ff"+( .@i+1 ) +".^000000 ^007700"+ .@name$[.@i] +" "+( .@count1 == 1 ? "(VIP)" : "" ) +""+( .@count2 == 1 ? "(VIP)" : "" ) +"^000000";
        }

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2346
  • Joined:  10/28/11
  • Last Seen:  

maybe something like this ?

prontera,155,181,5	script	Sample	4_F_KAFRA1,{
	.@current_aid = getcharid(3);
	.@sql$ = "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`";
	.@size = query_sql(.@sql$, .@aid, .@name$, .@online, .@count);
	mes "Found "+.@size+" Record(s)";
	for (.@i = 0; .@i < .@size; .@i++) {
		if (.@online[.@i]) {
			if (attachrid(.@aid[.@i]))
				.@count[.@i] = (countitem(21026) + countitem(210267));
			attachrid(.@current_aid);
		}
		mes "^0000FF"+(.@i+1) +". ^007700"+ .@name$[.@i] +" "+(.@count[.@i] ? "(VIP)" : "" )+" - ^007700"+(.@online[.@i] ? "Online":"Offline" )+"^000000";	
	}
	close;
}

it shall include offline players too.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  194
  • Topics Per Day:  0.04
  • Content Count:  499
  • Reputation:   3
  • Joined:  03/11/12
  • Last Seen:  

15 hours ago, Emistry said:

maybe something like this ?


prontera,155,181,5	script	Sample	4_F_KAFRA1,{
	.@current_aid = getcharid(3);
	.@sql$ = "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`";
	.@size = query_sql(.@sql$, .@aid, .@name$, .@online, .@count);
	mes "Found "+.@size+" Record(s)";
	for (.@i = 0; .@i < .@size; .@i++) {
		if (.@online[.@i]) {
			if (attachrid(.@aid[.@i]))
				.@count[.@i] = (countitem(21026) + countitem(210267));
			attachrid(.@current_aid);
		}
		mes "^0000FF"+(.@i+1) +". ^007700"+ .@name$[.@i] +" "+(.@count[.@i] ? "(VIP)" : "" )+" - ^007700"+(.@online[.@i] ? "Online":"Offline" )+"^000000";	
	}
	close;
}

it shall include offline players too.

solved thank you

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  150
  • Reputation:   11
  • Joined:  12/03/18
  • Last Seen:  

On 5/7/2019 at 8:54 AM, caspa said:

solved thank you

Can you please post how it was solved? thanks!

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

×
×
  • Create New...