Raised This Month: $51 Target: $400
 12% 

4 strings in one


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
einsfuhrer
Member
Join Date: Jun 2019
Old 09-30-2019 , 14:54   4 strings in one
Reply With Quote #1

I want the reason on the gag to looks like this: "Trusted: TheGuyToGagged | Reason: Ar2"

This is the code, but I get two errors, what am I doing wrong?

Errors:
Code:
scripting\a_trusted.sp(33) : error 035: argument type mismatch (argument 3)
scripting\a_trusted.sp(38) : error 008: must be a constant expression; assumed zero

Code:
PHP Code:
public Action Command_tGag(int clientint args)
{

    
char name[64];
    
GetCmdArg(1namesizeof(name)); // get first argument, arg1 holds the argument

    
char reason[64];
    
GetCmdArg(2reasonsizeof(reason)); // get second argument, arg2 holds the argument

    
char target FindTarget(clientnamefalsefalse);

    
char baseReason[64] = "Trusted: ";
    
StrCat(baseReasonsizeof(baseReason), client);

    
char baseReason2[64] = "| Reason: ";
    
StrCat(baseReason2sizeof(baseReason2), reason);

    
char baseReason3[64] = baseReason;
    
StrCat(baseReasonsizeof(baseReason), baseReason2);

    if (
args 2)
    {
        
ReplyToCommand(client" \x0C[TURF]⠀\x08Usage: sm_tgag <name> <reason>");
        return 
Plugin_Handled;
    }

    
SourceComms_SetClientGag(targettrue30truebaseReason3);

    return 
Plugin_Handled;

einsfuhrer is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 09-30-2019 , 15:04   Re: 4 strings in one
Reply With Quote #2

1. You should check the numbers of arguments at the beginning of the function.
2. You should check if the target is invalid.
3. You are concatenating strings with ints, use IntToString on ints before that.

PHP Code:

public Action Command_tGag(int clientint args)
{
    if (
args 2)
    {
        
ReplyToCommand(client" \x0C[TURF]⠀\x08Usage: sm_tgag <name> <reason>");
        return 
Plugin_Handled;
    }

    
char name[64];
    
GetCmdArg(1namesizeof(name));

    
int target FindTarget(clientnamefalsefalse);
    if (
target == -1) return Plugin_Handled;

    
char reason[128];
    
GetCmdArg(2reasonsizeof(reason));

    
Format(reasonsizeof(reason), "Trusted: %N | Reason: %s"clientreason);
    
SourceComms_SetClientGag(targettrue30truereason);

    return 
Plugin_Handled;

__________________

Last edited by Ilusion9; 09-30-2019 at 15:04.
Ilusion9 is offline
einsfuhrer
Member
Join Date: Jun 2019
Old 10-03-2019 , 16:01   Re: 4 strings in one
Reply With Quote #3

I solved it.
einsfuhrer is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:14.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode