Dastgir 1246 Posted July 22, 2014 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 2 Legend and Vanquiser reacted to this Quote Share this post Link to post Share on other sites
Mumbles 193 Posted July 26, 2014 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;} 1 Mhalicot reacted to this Quote Share this post Link to post Share on other sites
Dastgir 1246 Posted July 27, 2014 @Mumbles, Updated the script.(I really have overlooked the Quotes Part) Quote Share this post Link to post Share on other sites
Cydh 9 Posted September 10, 2014 Note from me, "This won't work if you have separated login-server with map-server (the database or host)" Quote Share this post Link to post Share on other sites
alibabasaluuja 0 Posted April 5, 2015 Where can I put this script txt? which folder?Thanks. Quote Share this post Link to post Share on other sites
Dastgir 1246 Posted April 7, 2015 @@alibabasaluuja Just put this as you do for other scripts Quote Share this post Link to post Share on other sites
Danzon 4 Posted April 15, 2015 Very nice , thank you +1 Quote Share this post Link to post Share on other sites
Legend 43 Posted April 17, 2015 omg this is awesome thanks much Quote Share this post Link to post Share on other sites