pastebin - collaborative debugging tool
rathena.kpaste.net RSS


has_char_from_same_ip
Posted by Anonymous on Tue 10th Apr 2012 17:47
raw | new post

  1. poring_c01,100,100,0    script  test    910,{
  2.         if (callfunc("has_char_from_same_ip")) {
  3.                 mes "There is already a char from your IP in Battlegrounds.";
  4.         } else {
  5.                 mes "You may enter BG.";
  6.         }
  7.         close;
  8. }
  9.  
  10.  
  11. function        script  has_char_from_same_ip   {
  12.         set .bg_maps$, "schg_cas06,schg_cas07,schg_cas08,arug_cas06,arug_cas07," +
  13.                        "arug_cas08,rush_cas01,rush_cas02,rush_cas03,rush_cas04," +
  14.                        "bat_room,prt_are01,job3_war01,job3_war02," +
  15.                        "job3_sha01,job3_rang01,job3_arch01,job3_rune02,job3_guil01," +
  16.                        "bat_a01,bat_a02,bat_b01,bat_b02,bat_c01,bat_c02,bat_c03," +
  17.                        "2@cata,force_1-1,force_2-1,force_3-1,force_1-3,job3_arch03";
  18.        
  19.         // check whitelist
  20.         for (set .@i,0; .@i<getarraysize($bgexceptions); set .@i,.@i+1) {
  21.                 if (getcharid(3) == $bgexceptions[.@i])
  22.                         return 0; // always allow
  23.         }
  24.        
  25.         // get array of char names who are online from the same IP
  26.         query_sql "SELECT `char`.`name` FROM `char` LEFT JOIN login ON `char`.account_id=login.account_id " +
  27.                   "WHERE last_ip=(SELECT last_ip FROM login WHERE account_id="+playerattached()+") AND online AND `char`.account_id!=" + playerattached(), .@name$;
  28.         // check each char, and see if they are on a BG map
  29.         for (set .@i,0; .@i<getarraysize(.@name$); set .@i,.@i+1) {
  30.                 getmapxy .@map$, .@x, .@y, 0, .@name$[0];
  31.                 if (compare(.bg_maps$, .@map$))
  32.                         return 1; // another char from this IP is on map
  33.         }
  34.         return 0; // no other chars from this IP on that map
  35. }

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at