19.09.2015, 11:54
Hello, today i'am going to make a IC Email system and i have a small problem, so i want when player use /email command he got a dialog like this format " Email Title - Sender " and it's load this from database ( load when player do /email not when gamemode launched or player connect ) , but now i don't have really idea how to make when player select one of the Emails he got the text, check my code :
Load from database :
Response callback:
Thank's for advance.
PHP код:
CMD:email(playerid, params[])
{
new option[24], string[24];
if(sscanf(params, "s[24]S()[128]", option, string))
{
Usage(playerid, "/email [action]");
Usage(playerid, "[ACTIONS] write, view.");
}
if (!strcmp(option, "write", true))
{
/* static
email[24], text;
if (sscanf(string, "s[24]s[255]", email, text))
return Usage(playerid, "/email [send] [Email destination] [text]");
if(strfind(string, DEFAULT_DOMAIN, true) != -1)
{
-- COMING SOON --
}*/
return 1;
}
if (!strcmp(option, "giew", true))
{
ListPlayerEmail(playerid);
}
return 1;
}
PHP код:
ListPlayerEmail(playerid)
{
static
query[160];
format(query, sizeof(query), "SELECT * FROM `emails` WHERE `Receiver` = %s", pInfo[playerid][pICEmail]);
return mysql_tquery(dbHandle, query, "OnEmailFind", "d", playerid);
}
PHP код:
public OnEmailFind(playerid)
{
new emailtitle[50], emailsender[50], string[1024], emailstatus;
new rows = cache_num_rows();
if(rows)
{
new loaded;
for (loaded = 0; loaded != rows; ++loaded)
{
cache_get_field_content(loaded, "Sender", emailsender, 50);
cache_get_field_content(loaded, "Title", emailtitle, 255);
emailstatus = cache_get_field_content_int(loaded, "Status");
pInfo[playerid][EmailChoice] = rows;
if(emailstatus == 1) format(string, sizeof(string), "%s "COL_RED" Title : %s - By : %s\n", emailtitle, emailsender);
else format(string, sizeof(string), "%s "COL_WHITE" Title: %s - by : %s\n", emailtitle, emailsender);
}
Dialog_Show(playerid, DialogEmail, DIALOG_STYLE_TABLIST, pInfo[playerid][pICEmail], string, "Select", "Close");
}
else return Server(playerid, "You don't have any Email.");
return 1;
}