Jump to content

Question

Posted

hello i already try everything i can to fix this script im always having this error after i enter the map, can someone help me

[Error]: buildin_rid2name: invalid RID
[Error]: buildin_rid2name: invalid RID
[Error]: buildin_getmapxy: Player with nick '(null)' is not found.
[Error]: buildin_getmapxy: Player with map id '0' is not found.

 

Quote

-    script    dualclientkicker    -1,{
OnPCLoadMapEvent:
    set .@charmap$, strcharinfo(3);
    if(!compare(.tmp$, .@charmap$)) end;
    
    set .@len, query_sql("SELECT DISTINCT `account_id` FROM `char` WHERE `account_id` IN (SELECT `account_id` FROM `login` WHERE `last_ip` =(SELECT `last_ip` FROM `login` WHERE `account_id`="+getcharid(3)+")) AND `online` <> 0;", .@a);
    
    // Check for results from query_sql
    if (.@len == 0) end;
    
    for (set .@d, 0; .@d < .@len; set(.@d, .@d+1)) {
        // Ensure the account ID is valid before proceeding
        if (rid2name(.@a[.@d]) != "") {
            if (!getmapxy(.@map$, .@x, .@y, BL_PC, rid2name(.@a[.@d])) && .@charmap$ == .@map$)
                set .@c, .@c + 1;  
        }
    }
    
    if (.@c > .limitacc) {
        dispbottom "Dual accounts not allowed in this map.";
        warp "SavePoint",0,0;
    }    
    end;

OnInit:
    set .limitacc, 1;
    setarray .maps$, "pvp_y_1-2", "prt_pvp", "grandarena", "bombring", "gh10", "gh11", "prtg_cas01";
    set .lens, getarraysize(.maps$);
    
    for (set .a, 0; .a < .lens; set(.a, .a+1)) {
        setmapflag .maps$[.a], mf_loadevent;
        set .tmp$, .tmp$ + .maps$[.a] + ",";
    }
}
 

 

1 answer to this question

Recommended Posts

  • 0
Posted (edited)

You are encountering issues when trying to get information about players using their account IDs retrieved from the database. This can happen if the character associated with that account ID is not currently on the same map server as the script is running, leading to functions like rid2name and getmapxy failing.

This one is perfectly working on me.

-	script	dualclientkicker	-1,{
OnPCLoadMapEvent:
	// Check if the current map is one of the restricted maps
	set .@charmap$, strcharinfo(3);
	// Use inarray to check if the current map is in the list
	if (inarray(.maps$[0], .@charmap$) == -1) end;

	// Get the IP address of the triggering player
	set .@player_ip$, getcharip();
	set .@player_aid, getcharid(3); // Get the account ID of the triggering player

	set .@same_ip_count, 0;

	// Get a list of all players on the current map by their Account ID
	set .@num_players_on_map, getmapunits(BL_PC, .@charmap$, .@map_player_aids[0]);

	// Iterate through players on the map
	for (set .@i, 0; .@i < .@num_players_on_map; set(.@i, .@i + 1)) {
		set .@current_aid, .@map_player_aids[.@i];

		// Skip the triggering player themselves
		if (.@current_aid == .@player_aid) continue;

		// Get the IP address of the current player on the map
		set .@current_ip$, getcharip(.@current_aid);

		// Compare IP addresses
		if (.@current_ip$ == .@player_ip$) {
			set .@same_ip_count, .@same_ip_count + 1;
		}
	}

	// Check if the count of other players with the same IP exceeds the limit
	// .limitacc is the maximum allowed *additional* accounts (e.g., 1 means total 2 accounts allowed)
	if (.@same_ip_count >= .limitacc) {
		dispbottom "Dual accounts not allowed in this map.";
		warp "SavePoint",0,0;
	}
	end;

OnInit:
	// Maximum allowed additional accounts with the same IP on the restricted maps
	set .limitacc, 1; // Allows 1 additional account (total 2)

	// List of maps where dual-clienting is restricted
	setarray .maps$[0], "poring_w01", "quiz_01";

	// Set mf_loadevent flag on these maps
	set .@lens, getarraysize(.maps$);
	for (set .@a, 0; .@a < .@lens; set(.@a, .@a + 1)) {
		setmapflag .maps$[.@a], mf_loadevent;
	}
}

 

Edited by Jinun

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...