18.12.2016, 16:50
(
Последний раз редактировалось HidroDF; 18.12.2016 в 19:57.
)
Hello, I'm making a phone system and I'm trying to get the Message value from DB. With integer characters I don't have that problem, works fine but with the string I'm having a problem.
Let's suppose I have 4 messages:
Message 1: Hello
Message 2: Good job
Message 3: Nice
Message 4: Works
When I try to see message 1, the string shows:
HGNWorks
When I try to see message 2, the string shows:
GNWorks
When I try to see message 3, the string shows:
NWorks
When I try to see message 4, the string shows:
Works
Seems like load the first word of every message and the complete the message with the last message.
Here is my code:
Tried some new code but nothing.. ANYONE PLEASE?
Let's suppose I have 4 messages:
Message 1: Hello
Message 2: Good job
Message 3: Nice
Message 4: Works
When I try to see message 1, the string shows:
HGNWorks
When I try to see message 2, the string shows:
GNWorks
When I try to see message 3, the string shows:
NWorks
When I try to see message 4, the string shows:
Works
Seems like load the first word of every message and the complete the message with the last message.
Here is my code:
Код:
forward LoadUserSMS(playerid, phone);
public LoadUserSMS(playerid, phone)
{
new query[240];
mysql_format(handle, query, sizeof(query), "SELECT * FROM `SMS` WHERE `Phone` = '%d'", phone);
mysql_tquery(handle, query, "OnSmsUserLoad", "id", playerid, telefono);
return 1;
}
forward OnSmsUserLoad(playerid, phone);
public OnSmsUserLoad(playerid, phone)
{
new total;
for(new i = 0; i < cache_num_rows(); i++)
{
if(total < 15)
{
pSMS[playerid][ID][i] = cache_get_field_content_int(i, "ID");
pSMS[playerid][Telep][i] = cache_get_field_content_int(i, "Phone");
pSMS[playerid][From][i] = cache_get_field_content_int(i, "From");
cache_get_field_content(i, "Message", pSMS[playerid][Message][i], .max_len = 128);
pSMS[playerid][Stats][i] = cache_get_field_content_int(i, "Stats");
total++;
if(pSMS[playerid][Stats][i] == 2)
{
SendClientMessage(playerid, -1, "You have unread messages.");
}
}
}
}
//Command viewmessages:
new sms[1024];
for(new i = 0; i < MAX_SMS; i++)
{
if(MyNumber[playerid] == pSMS[playerid][Phone][i])
{
new status[30];
status = "new";
if(pSMS[playerid][Stats][i] == 1) format(status, sizeof(status), "new");
format(sms, sizeof(sms), "%sFrom %i (%s)\n", sms, pSMS[playerid][From][i], status);
}
}
ShowPlayerDialog(playerid, DIALOG_PHONE_SMS, DIALOG_STYLE_LIST, "My messages", sms, "View", "Close");
// On dialog response
if(dialogid == DIALOG_PHONE_SMS)
{
if(!response) return 1;
new title[100];
new message[128];
ActionSMS[playerid] = pSMS[playerid][ID][listitem];
format(title, sizeof(title), "From #%i", pSMS[playerid][From][listitem]);
format(message, sizeof(message), "%s", pSMS[playerid][Message][listitem]);
new query[400];
mysql_format(handle, query, sizeof(query), "UPDATE `SMS` SET Stats= '1' WHERE ID = '%d'", ActionSMS[playerid]);
mysql_query(handle, query);
ShowPlayerDialog(playerid, DIALOG_PHONE_SMS2, DIALOG_STYLE_MSGBOX, title, message, "Delete", "Save");
return 1;
}
if(dialogid == DIALOG_PHONE_SMS2)
{
if(response)
{
new query[400];
mysql_format(handle, query, sizeof(query), "DELETE FROM `SMS` WHERE ID = '%d'", ActionSMS[playerid]);
mysql_query(handle, query);
ActionSMS[playerid] = 0;
ResetPhonesUser(playerid);
LoadUserPhones(playerid);
}
else
{
ActionSMS[playerid] = 0;
ResetPhonesUser(playerid);
LoadUserPhones(playerid);
return 1;
}
return 1;
}


