SendClientMessage doesn't show
#1

Hi. I have two different commands.

1. /report ID reason.
2. /re reason.

i want the format [REF:#UniqueID] Your report has been sent.
[REF:#UniqueID]: Hey, Admin! Player has sent a report.


uniqueid = ID row from mysql database which is Autoincrement


But, in game, the report it SAVES in MYSQL (I can check it via /reports) but it doesn't send SendClientMessage and I can spam /re or /report, which doesn't follow pReported.


PHP код:
forward OnPlayerReport(playeridtargetidreason); 
public 
OnPlayerReport(playeridtargetidreason

    new 
rowsfields
    
cache_get_data(rowsfieldshandle); 
    new  
reportid
    new 
count cache_num_rows(); 
    if(
count 0
    { 
        new 
reportstring[250],reportstring2[250]; 
           
reportid cache_get_field_content_int(0"ID"handle); 
        
format(reportstring2,sizeof(reportstring2), ""chat""COL_YELLOW"[REF:#%d]: Your report upon %s(%d) has been sent "COL_WHITE" (Reason: %s)",reportidPlayerName(targetid),targetidreason); 
        
SendClientMessage(playerid,-1,reportstring2); 
        
format(reportstring,sizeof(reportstring), ""chat""COL_YELLOW"[REF:#%d]: Player %s(ID:%d) has reported %s(ID:%d)"COL_WHITE" (Reason: %s)",reportidPlayerName(playerid),playerid,PlayerName(targetid),targetid,reason); 
        
SendMessageToAllAdmins(reportstring,-1); 
          
pInfo[playerid][pReported] = 1
          
timeras[playerid] = SetTimerEx("Report"600000"i"playerid); 
    } 

forward OnPlayerReporte(playeridreason); 
public 
OnPlayerReporte(playeridreason

    new 
rowsfields
    
cache_get_data(rowsfieldshandle); 
    new  
reportid
    new 
count cache_num_rows(); 
    if(
count 0
    { 
        new 
reportstring[250],reportstring2[250]; 
           
reportid cache_get_field_content_int(0"ID"handle); 
        
format(reportstring2,sizeof(reportstring2), ""chat""COL_YELLOW"[REF:#%d]: Your report was sent. "COL_WHITE" Title: [%s].",reportidreason); 
        
SendClientMessage(playerid,-1,reportstring2); 
        
format(reportstring,sizeof(reportstring), ""chat""COL_YELLOW"[REF:#%d]: Player %s(ID:%d) has reported an error. "COL_WHITE" (Title: %s)",reportidPlayerName(playerid),playerid,reason); 
        
SendMessageToAllAdmins(reportstring,-1); 
          
pInfo[playerid][pReported] = 1
          
timeras[playerid] = SetTimerEx("Report"600000"i"playerid); 
    } 

PHP код:
CMD:report(playerid,params[]) 

    new 
targetid,reason[250]; 
    if(
sscanf(params"us[105]"targetid,reason)) return SendClientMessage(playerid,-1,""chat" /report [playerid] [Reason]"); 
    if(!
IsPlayerConnected(targetid)) return SendClientMessage(playerid,-1,""COL_RED"Not online"); 
     if(
targetid == playerid) return SendClientMessage(playerid,-1""COL_RED"EROARE:  Can report yourself."); 
    if(!
IsPlayerNPC(targetid)) 
    { 
        if(
pInfo[playerid][pReported] == 0
        { 
            
format(jQueryMAX_QUERY_LENGTH"INSERT INTO `"#reportlog"` (Username, Targetname, Report, Data) VALUES ('%s', '%s', '%s', CURRENT_TIMESTAMP)",PlayerName(playerid),PlayerName(targetid), reason); 
            
mysql_tquery(handlejQuery""""); 
            
mysql_tquery(handle"SELECT * FROM `reportlog` ORDER BY ID DESC LIMIT 1""OnPlayerReport""uus[80]"playeridtargetidreason); 
        } 
        else { 
            
SendClientMessage(playerid,-1,""COL_RED"Wait 1 minute"); 
        } 
    } 
    else return 
SendClientMessage(playerid,-1,""COL_RED"can't report npc !"); 
    return 
1

CMD:re(playerid,params[]) 

        new 
reason[250]; 
        if(
sscanf(params"s[80]",reason)) return SendClientMessage(playerid,-1,""chat" /(re)port [Reason]"); 
        if(
pInfo[playerid][pReported] == 0
        { 
            
format(jQueryMAX_QUERY_LENGTH"INSERT INTO `"#reportlog"` (Username, Report, Data) VALUES ('%s', '%s', CURRENT_TIMESTAMP)",PlayerName(playerid), reason); 
            
mysql_tquery(handlejQuery""""); 
            
mysql_tquery(handle"SELECT * FROM `reportlog` ORDER BY ID DESC LIMIT 1""OnPlayerReporte""s[80]"playeridreason); 
        } 
        else { 
            
SendClientMessage(playerid,-1,""COL_RED"Wait one minute"); 
        } 
        return 
1

Reply
#2

If a message is longer than 144 characters, it will not be sent. Truncation can be used to prevent this. Displaying a message on multiple lines will also solve this issue.
Reply
#3

Quote:
Originally Posted by DaniceMcHarley
Посмотреть сообщение
If a message is longer than 144 characters, it will not be sent. Truncation can be used to prevent this. Displaying a message on multiple lines will also solve this issue.
Well then why can I use /report or /re without waiting 1 minute?

Beside that, even if message is 1 character long doesn't show it.
Reply
#4

Don't use timers for time limitations, use UNIX timestamp instead.

Код:
forward OnPlayerReport(playerid, targetid, reason);  
public OnPlayerReport(playerid, targetid, reason)  
{  
    new rows, fields;  
    cache_get_data(rows, fields, handle);  
    new  reportid;  
    new count = cache_num_rows();  
    if(count > 0)  
    {  
        new reportstring[144],reportstring2[144];  
           reportid = cache_get_field_content_int(0, "ID", handle);  
        format(reportstring2,sizeof(reportstring2), ""chat""COL_YELLOW"[REF:#%d]: Your report upon %s(%d) has been sent "COL_WHITE" (Reason: %s)",reportid, PlayerName(targetid),targetid, reason);  
        SendClientMessage(playerid,-1,reportstring2);  
        format(reportstring,sizeof(reportstring), ""chat""COL_YELLOW"[REF:#%d]: Player %s(ID:%d) has reported %s(ID:%d)"COL_WHITE" (Reason: %s)",reportid, PlayerName(playerid),playerid,PlayerName(targetid),targetid,reason);  
        SendMessageToAllAdmins(reportstring,-1);  
        pInfo[playerid][pReported] = gettime()+60;  
    }  
}  

forward OnPlayerReporte(playerid, reason);  
public OnPlayerReporte(playerid, reason)  
{  
    new rows, fields;  
    cache_get_data(rows, fields, handle);  
    new  reportid;  
    new count = cache_num_rows();  
    if(count > 0)  
    {  
        new reportstring[250],reportstring2[250];  
        reportid = cache_get_field_content_int(0, "ID", handle);  
        format(reportstring2,sizeof(reportstring2), ""chat""COL_YELLOW"[REF:#%d]: Your report was sent. "COL_WHITE" Title: [%s].",reportid, reason);  
        SendClientMessage(playerid,-1,reportstring2);  
        format(reportstring,sizeof(reportstring), ""chat""COL_YELLOW"[REF:#%d]: Player %s(ID:%d) has reported an error. "COL_WHITE" (Title: %s)",reportid, PlayerName(playerid),playerid,reason);  
        SendMessageToAllAdmins(reportstring,-1);  
        pInfo[playerid][pReported] = gettime()+60; 
    }  
} 

CMD:report(playerid,params[])  
{  
    new targetid,reason[105];  
    if(sscanf(params, "us[105]", targetid,reason)) return SendClientMessage(playerid,-1,""chat" /report [playerid] [Reason]");  
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,-1,""COL_RED"Not online");  
     if(targetid == playerid) return SendClientMessage(playerid,-1, ""COL_RED"EROARE:  Can report yourself.");  

    if(!IsPlayerNPC(targetid))  
    {  
        if(pInfo[playerid][pReported] < gettime()) 
        {  
            format(jQuery, MAX_QUERY_LENGTH, "INSERT INTO `"#reportlog"` (Username, Targetname, Report, Data) VALUES ('%s', '%s', '%s', CURRENT_TIMESTAMP)",PlayerName(playerid),PlayerName(targetid), reason);  
            mysql_tquery(handle, jQuery, "", "");  
            mysql_tquery(handle, "SELECT * FROM `reportlog` ORDER BY ID DESC LIMIT 1", "OnPlayerReport", "uus[80]", playerid, targetid, reason);  
        }  
        else SendClientMessage(playerid,-1,""COL_RED"Wait 1 minute");  
    }  
    else return SendClientMessage(playerid,-1,""COL_RED"can't report npc !");  
    return 1;  
}  


CMD:re(playerid,params[])  
{  
        new reason[80];  
        if(sscanf(params, "s[80]",reason)) return SendClientMessage(playerid,-1,""chat" /(re)port [Reason]");  
        if(pInfo[playerid][pReported] < gettime())  
        {  
            format(jQuery, MAX_QUERY_LENGTH, "INSERT INTO `"#reportlog"` (Username, Report, Data) VALUES ('%s', '%s', CURRENT_TIMESTAMP)",PlayerName(playerid), reason);  
            mysql_tquery(handle, jQuery, "", "");  
            mysql_tquery(handle, "SELECT * FROM `reportlog` ORDER BY ID DESC LIMIT 1", "OnPlayerReporte", "s[80]", playerid, reason);  
        }  
        else SendClientMessage(playerid,-1,""COL_RED"Wait one minute");  
        return 1;  
}
There is no point in defining the strings with 250 cells, because the maximum amount of cells that SendClientMessage can display is 144. Unless you want to use a dialog to display the messages, that would work.
Reply
#5

The same error. It's not about string size. It's something about MYSQL but i don't know what
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)