little help please, thanks.
#1

PHP код:
YCMD:report(playeridparams[], help) {
    if(
help) {
        
SendClientMessage(playeridX11_WHITE"Used for reporting a player");
        return 
1;
    }
    if(
GetPVarInt(playerid"ReportBanned") == 1) {
        
SendClientMessage(playeridX11_TOMATO_2"You are report banned!");
        return 
1;
    }
    new 
input[128],msg[128];
    if(!
sscanf(params"s[128]"input)) {
        new 
time GetPVarInt(playerid"RequestChatCooldown");
        new 
timenow gettime();
        if(
REQUESTCHAT_COOLDOWN-(timenow-time) > 0) {
            
SendClientMessage(playeridX11_TOMATO_2"You must wait before sending another report!");
            return 
1;
        }
        
SetPVarInt(playerid"RequestChatCooldown"gettime());
        
format(msgsizeof(msg), "Report from [%d]%s: {EE0000}%s"playeridGetPlayerNameEx(playeridENameType_CharName), input);
        
ABroadcast(X11_ORANGEmsgEAdminFlags_All);
        
AdminLog(playeridmsg);
        
SendClientMessage(playeridX11_WHITE"Your report has been sent to the admins, please be patient and wait until an admin can help you.");
        
//SendClientMessage(playerid, X11_YELLOW, input);
        
SetPVarInt(playerid"SentReport"1);
        
SetPVarString(playerid"ReportText"input);
    } else {
        
SendClientMessage(playeridX11_WHITE"USAGE: /report [message]");
    }
    return 
1;

How can I restrict this command to only work when the player enters /report [playerid] then [message], like the playerid is must.. thank you.
Reply
#2

Код:
YCMD:report(playerid, params[], help) {
    if(help) {
        SendClientMessage(playerid, X11_WHITE, "Used for reporting a player");
        return 1;
    }
    if(GetPVarInt(playerid, "ReportBanned") == 1) {
        SendClientMessage(playerid, X11_TOMATO_2, "You are report banned!");
        return 1;
    }
    new input[128],msg[128],targetid;
    if(!sscanf(params, "is[128]",targetid,input)) {
      if(!IsPlayerConnected(targetid))
        return SendClientMessage(playerid,X11_TOMATO_2, "That player isn't connected");
        new time = GetPVarInt(playerid, "RequestChatCooldown");
        new timenow = gettime();
        if(REQUESTCHAT_COOLDOWN-(timenow-time) > 0) {
            SendClientMessage(playerid, X11_TOMATO_2, "You must wait before sending another report!");
            return 1;
        }
        SetPVarInt(playerid, "RequestChatCooldown", gettime());
        format(msg, sizeof(msg), "Report from [%d]%s Of %s Reason:{EE0000}%s", playerid,GetPlayerNameEx(targetid, ENameType_CharName), GetPlayerNameEx(playerid, ENameType_CharName), input);
        ABroadcast(X11_ORANGE, msg, EAdminFlags_All);
        AdminLog(playerid, msg);
        SendClientMessage(playerid, X11_WHITE, "Your report has been sent to the admins, please be patient and wait until an admin can help you.");
        //SendClientMessage(playerid, X11_YELLOW, input);
        SetPVarInt(playerid, "SentReport", 1);
        SetPVarString(playerid, "ReportText", input);
    } else {
        SendClientMessage(playerid, X11_WHITE, "USAGE: /report [playerid] [message]");
    }
    return 1;
}
Give it a try !
Reply
#3

Quote:
Originally Posted by FuNkYTheGreat
Посмотреть сообщение
Код:
YCMD:report(playerid, params[], help) {
    if(help) {
        SendClientMessage(playerid, X11_WHITE, "Used for reporting a player");
        return 1;
    }
    if(GetPVarInt(playerid, "ReportBanned") == 1) {
        SendClientMessage(playerid, X11_TOMATO_2, "You are report banned!");
        return 1;
    }
    new input[128],msg[128],targetid;
    if(!sscanf(params, "is[128]",targetid,input)) {
      if(!IsPlayerConnected(targetid))
        return SendClientMessage(playerid,X11_TOMATO_2, "That player isn't connected");
        new time = GetPVarInt(playerid, "RequestChatCooldown");
        new timenow = gettime();
        if(REQUESTCHAT_COOLDOWN-(timenow-time) > 0) {
            SendClientMessage(playerid, X11_TOMATO_2, "You must wait before sending another report!");
            return 1;
        }
        SetPVarInt(playerid, "RequestChatCooldown", gettime());
        format(msg, sizeof(msg), "Report from [%d]%s Of %s Reason:{EE0000}%s", playerid,GetPlayerNameEx(targetid, ENameType_CharName), GetPlayerNameEx(playerid, ENameType_CharName), input);
        ABroadcast(X11_ORANGE, msg, EAdminFlags_All);
        AdminLog(playerid, msg);
        SendClientMessage(playerid, X11_WHITE, "Your report has been sent to the admins, please be patient and wait until an admin can help you.");
        //SendClientMessage(playerid, X11_YELLOW, input);
        SetPVarInt(playerid, "SentReport", 1);
        SetPVarString(playerid, "ReportText", input);
    } else {
        SendClientMessage(playerid, X11_WHITE, "USAGE: /report [playerid] [message]");
    }
    return 1;
}
Give it a try !
Didn't work
Reply
#4

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.
Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)