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:
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; }
Code:
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.