little help please, thanks.
#5

Quote:
Originally Posted by RIDE2DAY
Посмотреть сообщение
PHP код:
YCMD:report(playeridparams[], help)
{
    if(
help)
    {
        
SendClientMessage(playeridX11_WHITE"Used for reporting a player");
    }
    else
    {
        new 
targetid;
        new 
reason[57];
        new 
message[144];
        if(
GetPVarInt(playerid"ReportBanned"))
        {
            
SendClientMessage(playeridX11_TOMATO_2"You are report banned!");
            return 
1;
        }
    
        if(
sscanf(params"is[57]"targetidreason))
        {
            
SendClientMessage(playeridX11_WHITE"USAGE: /report [playerid] [reason]");
            return 
1;
        }
        if(!
IsPlayerConnected(targetid))
        {
            
SendClientMessage(playerid,X11_TOMATO_2"That player isn't connected");
            return 
1;
        }
        if(
REQUESTCHAT_COOLDOWN - (gettime() - GetPVarInt(playerid"RequestChatCooldown")) > 0)
        {
            
SendClientMessage(playeridX11_TOMATO_2"You must wait before sending another report!");
            return 
1;
        }
        
SetPVarInt(playerid"RequestChatCooldown"gettime());
        
format(messagesizeof(message), "Report from [%d]%s of %s Reason: {EE0000}%s"playeridGetPlayerNameEx(playeridENameType_CharName), GetPlayerNameEx(targetidENameType_CharName), reason);
        
ABroadcast(X11_ORANGEmessageEAdminFlags_All);
        
AdminLog(playeridmessage);
        
SendClientMessage(playeridX11_WHITE"Your report has been sent to the admins, please be patient and wait until an admin can help you.");
    }
    return 
1;

It should work now, but allow me to ask you something:
  • Why the reason array has the same amount of characters as the message array?
    The formatted message without the reason might use a max. of 87 characters. So 128 - 87 = 41 characters left for the reason string. Anyway, now a client message might be 144 characters long, so use 144 for the message if you want, that way you'll get some extra cells for the reason message (144 - 87 = 57).

  • Why are you using PVars there?
    Check out this. You don't need them in this case, unless you're accesing them in another script. You might replace the "ReportBanned" PVar with a char array, much better! Search for "char-arrays" here.
Oh.. thank you very much for such useful information , will follow that.. and thanks again +REP
Reply


Messages In This Thread
little help please, thanks. - by Puff - 08.10.2017, 18:08
Re: little help please, thanks. - by FuNkYTheGreat - 08.10.2017, 18:35
Re: little help please, thanks. - by Puff - 09.10.2017, 06:27
Re: little help please, thanks. - by RIDE2DAY - 09.10.2017, 09:58
Re: little help please, thanks. - by Puff - 09.10.2017, 10:38

Forum Jump:


Users browsing this thread: 1 Guest(s)