Players abusing SendClientMessage
#1

Recently players started exploiting the SendClientMessage function.
For example if you write /report %s the server will try to output , but as the string contains %s the server would crash .
I'm sorry for my english but i'm doing my best .
an example would be :
Report from TheDarkBlade [2, level 3]: %s"

So i'm hoping for a golbal fix
Reply
#2

Show the code you use for the report command.
Reply
#3

PHP код:
 if(PlayerInfo[playerid][pAdmin] == && PlayerInfo[playerid][pHelper] <= 0)
            {
            if(
ReportTime[playerid] == 4) return SCM(playeridCOLOR_WHITE,"{f03337}Dupa 4 minute poti folosi aceasta actiune.");
            
//new sendername[MAX_PLAYER_NAME], string[300];
            
GetPlayerName(playeridsendernamesizeof(sendername));
            
SendClientMessage(playeridCOLOR_YELLOW"Report submitted.");
            
format(stringsizeof(string), "Report from %s [%d, level %d]: %s"sendername,playerid,PlayerInfo[playerid][pLevel],inputtext);
            
format(reporttext[playerid], sizeof(string), string);
            
ABroadCast(COLOR_REPORT,string,1);
            
ReportTime[playerid] = 4;
              
timerreport[playerid] = SetTimerEx("Reportul"2400000"%d"playerid);
              }
            else return 
SendClientMessage(playeridCOLOR_WHITE"You are an admin/helper 
PHP код:
public ABroadCast(color,const string[],level)
{
    foreach(
Playeri)
    {
        if(
IsPlayerConnected(i))
        {
            if(
gPlayerLogged[i] == 1)
            {
                if (
PlayerInfo[i][pAdmin] >= level)
                {
                    
SendClientMessage(icolorstring);
                }
            }
        }
    }
    
printf("%s"string);
    return 
1;

Reply
#4

Let the players write the command's parameters in chat mode and not a dialog, it converts % automatically to #

Otherwise you'll need to search in inputtext for sign character and return an error for invalid character.
Reply
#5

As far as I know percent signs are replaced with pound signs (#) on the client before anything is even sent to the server for precisely this reason. Or perhaps this only works in OnPlayerText, not sure. Either way, should be an easy fix if you use strfind.
Reply
#6

%% - one % in the mainchat,%%%%- for 2 etc etc
Reply
#7

so something like
PHP код:
if(strfind(inputtext,"%%") == 0) return SendClientMessage(playerid,COLOR_RED1,"Nu mai fi taran"); 
would work ?
Reply
#8

I just tried on localhost and no metter how much i type %%% output is always #
Reply
#9

You use double percent sign in format function only, you search for a single in strfind.
Reply
#10

Quote:
Originally Posted by Micko123
Посмотреть сообщение
I just tried on localhost and no metter how much i type %%% output is always #
Код:
SendClientMessage(playerid, -1,"i'm a 100%% sure you didn't try this.");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)