Jump to content
Dastgir

Permanant Group Changer

Recommended Posts

thumb-11b5c7b20283da7618f8cd3fcfca03cd-adjgroup2.png

File Name: Permanant Group Changer

File Submitter: Dastgir

File Submitted: 22 Jul 2014

File Category: Utility

 

This is a command "@adjgroup2" From which you can give a character new GroupID, no matter he is online or offline.

The New Group is changed permanently.

 

Usage:

@adjgroup2 <GroupID> <PlayerName>

If PlayerName contains Spaces, Just put it with spaces, without Quotes.

 

Click here to download this file

Share this post


Link to post
Share on other sites

As it's currently written, this won't function completely for a couple of reasons.

 

		.@p_name$ = .@atcmd_parameters$[1]; 

 

This only pulls the second position of the index. If you syntax is @adjgroup2 99 Player B, the script will only read it as @adjgroup2 99 Player. The biggest problem with this is that if there are two players online named Player A and Player B, the script might unintentionally change Player A's group; you won't immediately know for sure, since your variable .@p_name$ will only store "Player".

 
A proper way to determine the player's name would be to store additional values past index 1. When you type @adjgroup2 99 Player B, the following values are stored:

 

.@atcmd_command$ = "@adjgroup2";.@atcmd_parameters$[0] = "99";.@atcmd_parameters$[1] = "Player";.@atcmd_parameters$[2] = "B";.@atcmd_numparameters = 3;

 

Using this information, you can collect the additional player information by copying the array values and imploding them, separated by spaces:

 

for (.@i = 1; .@i < .@atcmd_numparameters; .@i++) {	.@name_data$[.@j++] = .@atcmd_parameters$[.@i];}.@p_name$ = implode(.@name_data$, " "); 

 

Now .@p_name$ will properly store the name Player B, or whatever name you send that has spaces in it.
 

 

		.@account_id = getcharid(3, .@p_name$); 

 

The problem here is that getcharid() will only return a value if the player is online and can be attached to the script (this would have been a problem with .@p_name$ anyway, since it was incorrectly storing player names);  if Player B is offline, .@account_id will have a value of 0. Normally, this would be fine, since you added a check to determine whether or not a player exists on the map server; however, it seems you're trying to update the account regardless of whether or not a player is online. A more efficient way of collecting a player's account ID would be to query the database using their (now properly stored) player name.

 

		.@account_id = query_sql("SELECT `account_id` FROM `char` WHERE `name` = '"+ .@p_name$ +"'"); 

 

Using the function query_sql() will return the value found; if the player truly does not exist at all, the function will return 0. In that case, you can replace this check with a simpler one:

 

		.@exist = query_sql("SELECT `group_id` FROM `login` WHERE `account_id`="+.@account_id, .@g_id);		if (!.@exist){			message strcharinfo(0), .@p_name$ +" Does not Exist.";			end;		}
		if (!.@account_id){			message strcharinfo(0), .@p_name$ +" does not exist.";			end;		}		query_sql "SELECT `group_id` FROM `login` WHERE `account_id` = '"+ .@account_id +"'", .@g_id;

 

With these changes made, the rest of the script and checks will run just fine.

 

 

Here's a debug script and some screenshots:

 

-	script	str_test	-1,{	OnInit:		bindatcmd "test", strnpcinfo(3) +"::OnCommand", 99, 99;		OnCommand:		// Collect string data		for (.@i = 0; .@i < .@atcmd_numparameters; .@i++) {			.@str_data$[.@j++] = .@atcmd_parameters$[.@i];		}				.@string$ = implode(.@str_data$, " ");	// Updated method		.@string2$ = .@atcmd_parameters$[0];	// Current method				message strcharinfo(0), "Updated : "+ .@string$;	// Updated output		message strcharinfo(0), "Current : "+ .@string2$;	// Current output		end;}

 

 

ReSRFNp.jpg

b37eykN.jpg

 

Share this post


Link to post
Share on other sites

Note from me, "This won't work if you have separated login-server with map-server (the database or host)"

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
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.