• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] I need some help with my /whois command.
#1
So I am trying to create a /whois command that does the following:



You type '/whois character Sean_Johnson' for example.



As a result, you get this string/msgbox:



SQLID: 10

Account: Stefhan

Characters: Sean_Johnson, Carl_Johnson, Kendl_Johnson

CHRIDS: 40, 41, 49

Level: 10, 5, 8



However, the info required is in two seperate tables (accounts & characters), which is where I get stuck. I simply don't know how to proceed. Can anyone guide me further? What is an?efficient way to do this??Am I even doing it right? I appreciate the assistance.



PHP Code:
CMD:whois(playerid, params[]) { ? ? if(Account[playerid][Admin] >= 2) ? ? { ? ? ? ? new subcmd[30], scmd_params[30]; ? ? ? ? if(sscanf(params, "s[30]S()[30]",subcmd, scmd_params)) ? ? ? ? ? ? return SendClientMessage(playerid, COLOR_INFO, "/whois [character/chrid/account/sqlid]"); ? ? ? ? // whois character subcmd ? ? ? ? if(strmatch(subcmd, "character")) ? ? ? ? { ? ? ? ? ? ? new target[MAX_PLAYER_NAME], str[128]; ? ? ? ? ? ? if(sscanf(params, "s[30]s[24]",subcmd, target)) ? ? ? ? ? ? ? ? return SendClientMessage(playerid, COLOR_INFO, "/whois character [Character_Name(case sensitive)]"); ? ? ? ? ? ? new query[250]; ? ? ? ? ? ? mysql_format(MHRP_SQL, query, sizeof(query), "SELECT SQLID FROM characters WHERE CharName = '%e'",target); ? ? ? ? ? ? mysql_tquery(MHRP_SQL, query, "OnWhoIsCharacter", "is", playerid, target); ? ? ? ? } ? ? ? ? // whois chrid subcmd ? ? ? ? if(strmatch(subcmd, "chrid")) ? ? ? ? { ? ? ? ? } ? ? ? ? // whois account subcmd ? ? ? ? if(strmatch(subcmd, "account")) ? ? ? ? { ? ? ? ? ? ?? ? ? ? ? } ? ? ? ? // whois sqlid subcmd ? ? ? ? if(strmatch(subcmd, "sqlid")) ? ? ? ? { ? ? ? ? ? ?? ? ? ? ? } ? ? ? ? // if no strmatch ? ? ? ? else return SendClientMessage(playerid, COLOR_ERROR, "That subcommand does not exist."); ? ? } ? ? else return SendClientMessage(playerid,COLOR_ERROR,"You do not have the required access to execute this command."); ? ? return 1; } forward OnWhoIsCharacter(playerid, target[]); public OnWhoIsCharacter(playerid, target[]) { ? ? if(cache_num_rows() != 1) ? ? ? ? return SendClientMessage(playerid, COLOR_ERROR, "That character does not exist."); ? ? new targetid; ? ? cache_get_value_name_int(0, "SQLID", targetid); ? ? mysql_format(MHRP_SQL, query, sizeof(query), "SELECT CHRID, CharName, Level FROM characters WHERE SQLID = %d LIMIT 3", targetid); ? ? mysql_tquery(MHRP_SQL, query, "OnWhoIsCharacterProcess", "ii", playerid, targetid); ? ? return 1; } forward OnWhoIsCharacterProcess(playerid, targetid); public OnWhoIsCharacterProcess(playerid, targetid) { ? ? new str[500], C_ID, C_Name[MAX_PLAYER_NAME], C_LVL; ? ? for( new id = 0; id < cache_num_rows(); id) ? ? { ? ? ? ? cache_get_value_name_int(id, "CHRID", C_ID); ? ? ? ? cache_get_value_name(id, "CharName", C_Name); ? ? ? ? cache_get_value_name_int(id, "Level", C_LVL); ? ? ? ? format(str, sizeof(str), "%d %s %d\n", C_ID, C_Name, C_LVL); ? ? ? ? SendClientMessage(playerid, str); ? ? } ? ? new query[250]; ? ? mysql_format(MHRP_SQL, query, sizeof(query), "SELECT Username FROM accounts WHERE SQLID = %d", targetid); ? ? mysql_tquery(MHRP_SQL, query); ? ? new A_Name[MAX_PLAYER_NAME]; ? ? cache_get_value_name(0, "Username", A_Name[24]); ? ? return 1; }
  Reply


Messages In This Thread
I need some help with my /whois command. - by Stefhan - 2019-04-17, 07:20 PM