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

String question


Post New Thread Reply   
 
Thread Tools Display Modes
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 01-03-2016 , 17:43   Re: String question
Reply With Quote #11

Quote:
Originally Posted by valio_skull View Post
I never heard about SetClientName...
It was a native added to either SM 1.6 or 1.7


uurbyrkdr can you check error logs to see if SetClientName reports any errors?
WildCard65 is offline
uurbyrkdr
Senior Member
Join Date: Apr 2015
Old 01-03-2016 , 19:28   Re: String question
Reply With Quote #12

Quote:
Originally Posted by WildCard65 View Post
uurbyrkdr can you check error logs to see if SetClientName reports any errors?
no error :/
uurbyrkdr is offline
valio_skull
Senior Member
Join Date: Jan 2013
Location: at home
Old 01-04-2016 , 05:05   Re: String question
Reply With Quote #13

Giving more code will be more helpful, from the first #include to the last brace.
__________________
valio_skull is offline
uurbyrkdr
Senior Member
Join Date: Apr 2015
Old 01-04-2016 , 15:18   Re: String question
Reply With Quote #14

Quote:
Originally Posted by valio_skull View Post
Giving more code will be more helpful, from the first #include to the last brace.
PHP Code:
#include <sourcemod>
#include <sdktools>
#pragma semicolon 1

public Plugin:myinfo =
{
    
name        "TEST",
    
author      "ImPossibLe`",
    
description "TEST",
    
version     "1.0",
};

public 
OnPluginStart()
{
    
RegAdminCmd("sm_nametest"Command_NameTestADMFLAG_KICK); 
}

public 
Action Command_NameTest(int clientint args

    if (
args 1
    {
        
ReplyToCommand(client"[SM] Usage: sm_nametest name"); 
    }

    
char arg1[32]; 
    
GetCmdArg(1arg1sizeof(arg1)); 

    
int target FindTarget(clientarg1); 
    if (
target == -1
    {
        return 
Plugin_Handled;
    }
    
    
decl String:name[64];
    
GetClientName(targetnamesizeof(name));
    
ReplaceString(namesizeof(name), "e""E"true);
    
Format(namesizeof(name), "%s*"name);
    
PrintToChat(client"[TEST] Target: %d , name: %s"targetname);
    
SetClientName(targetname); 
    return 
Plugin_Handled


Last edited by uurbyrkdr; 01-04-2016 at 15:23.
uurbyrkdr is offline
Disowned
Member
Join Date: Oct 2015
Old 01-06-2016 , 07:06   Re: String question
Reply With Quote #15

Quote:
Originally Posted by uurbyrkdr View Post
-snape-
Your script works perfectly fine in tf2 with a small tweak.

Heres the working script:

PHP Code:
#include <sourcemod>
#include <sdktools>
#pragma semicolon 1

public Plugin:myinfo =
{
    
name        "TEST",
    
author      "ImPossibLe`",
    
description "TEST",
    
version     "1.0",
};

public 
OnPluginStart()
{
    
RegAdminCmd("sm_nametest"Command_NameTestADMFLAG_KICK); 
}

public 
Action Command_NameTest(int clientint args

    if (
args 1
    {
        
ReplyToCommand(client"[SM] Usage: sm_nametest name"); 
        return 
Plugin_Handled;
    }

    
char arg1[64]; 
    
GetCmdArg(1arg164); 

    
int target FindTarget(clientarg1); 
    if (
target == -1
    {
        
ReplyToCommand(client"[SM] Could not find player");
        return 
Plugin_Handled;
    }
    
    
char name[64];
    
GetClientName(targetnamesizeof(name));
    
ReplaceString(namesizeof(name), "e""E"true);
    
Format(namesizeof(name), "%s*"name);
    if(
client == 0) {
        
PrintToConsole(client"[TEST] Target: %d , name: %s"targetname);
    } else {
        
PrintToChat(client"[TEST] Target: %d , name: %s"targetname);
    }
    
SetClientName(targetname); 
    return 
Plugin_Handled


Last edited by Disowned; 01-06-2016 at 07:09.
Disowned is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 01-06-2016 , 08:10   Re: String question
Reply With Quote #16

Quote:
Originally Posted by Disowned View Post
Your script works perfectly fine in tf2 with a small tweak.

Heres the working script:

PHP Code:
#include <sourcemod>
#include <sdktools>
#pragma semicolon 1

public Plugin:myinfo =
{
    
name        "TEST",
    
author      "ImPossibLe`",
    
description "TEST",
    
version     "1.0",
};

public 
OnPluginStart()
{
    
RegAdminCmd("sm_nametest"Command_NameTestADMFLAG_KICK); 
}

public 
Action Command_NameTest(int clientint args

    if (
args 1
    {
        
ReplyToCommand(client"[SM] Usage: sm_nametest name"); 
        return 
Plugin_Handled;
    }

    
char arg1[64]; 
    
GetCmdArg(1arg164); 

    
int target FindTarget(clientarg1); 
    if (
target == -1
    {
        
ReplyToCommand(client"[SM] Could not find player");
        return 
Plugin_Handled;
    }
    
    
char name[64];
    
GetClientName(targetnamesizeof(name));
    
ReplaceString(namesizeof(name), "e""E"true);
    
Format(namesizeof(name), "%s*"name);
    if(
client == 0) {
        
PrintToConsole(client"[TEST] Target: %d , name: %s"targetname);
    } else {
        
PrintToChat(client"[TEST] Target: %d , name: %s"targetname);
    }
    
SetClientName(targetname); 
    return 
Plugin_Handled

Um, client == 0 should really be calling PrintToServer as that prints to the server console, I think PrintToConsole only works with a real client(id > 0 and <= MaxClients), Anyway you should really be using ReplyToCommand, as that auto does PrintToServer if server used command/PrintToChat on a real client.
WildCard65 is offline
uurbyrkdr
Senior Member
Join Date: Apr 2015
Old 01-06-2016 , 10:48   Re: String question
Reply With Quote #17

Quote:
Originally Posted by Disowned View Post
Your script works perfectly fine in tf2 with a small tweak.

Heres the working script:

PHP Code:
#include <sourcemod>
#include <sdktools>
#pragma semicolon 1

public Plugin:myinfo =
{
    
name        "TEST",
    
author      "ImPossibLe`",
    
description "TEST",
    
version     "1.0",
};

public 
OnPluginStart()
{
    
RegAdminCmd("sm_nametest"Command_NameTestADMFLAG_KICK); 
}

public 
Action Command_NameTest(int clientint args

    if (
args 1
    {
        
ReplyToCommand(client"[SM] Usage: sm_nametest name"); 
        return 
Plugin_Handled;
    }

    
char arg1[64]; 
    
GetCmdArg(1arg164); 

    
int target FindTarget(clientarg1); 
    if (
target == -1
    {
        
ReplyToCommand(client"[SM] Could not find player");
        return 
Plugin_Handled;
    }
    
    
char name[64];
    
GetClientName(targetnamesizeof(name));
    
ReplaceString(namesizeof(name), "e""E"true);
    
Format(namesizeof(name), "%s*"name);
    if(
client == 0) {
        
PrintToConsole(client"[TEST] Target: %d , name: %s"targetname);
    } else {
        
PrintToChat(client"[TEST] Target: %d , name: %s"targetname);
    }
    
SetClientName(targetname); 
    return 
Plugin_Handled

again, didn't work on CS:GO.
idk why
uurbyrkdr is offline
Disowned
Member
Join Date: Oct 2015
Old 01-06-2016 , 20:49   Re: String question
Reply With Quote #18

Quote:
Originally Posted by uurbyrkdr View Post
again, didn't work on CS:GO.
idk why
I've confirmed this doesn't work in CS:GO. The exact same code works in TF2, so I'm going to guess that the function is broken in some manner, because all other resources on CS:GO name changing point to using SetClientName.

This didn't work either.
https://forums.alliedmods.net/showthread.php?t=161025

I just freshly installed a CS:GO dedicated server locally and tried it.
MetaMod:Source 1.10.6
SM: 1.7 - build 5286
Disowned is offline
Disowned
Member
Join Date: Oct 2015
Old 01-06-2016 , 20:53   Re: String question
Reply With Quote #19

Quote:
Originally Posted by WildCard65 View Post
Um, client == 0 should really be calling PrintToServer as that prints to the server console, I think PrintToConsole only works with a real client(id > 0 and <= MaxClients), Anyway you should really be using ReplyToCommand, as that auto does PrintToServer if server used command/PrintToChat on a real client.
Good catch, fixed code:

Spoiler
Disowned is offline
uurbyrkdr
Senior Member
Join Date: Apr 2015
Old 01-06-2016 , 21:31   Re: String question
Reply With Quote #20

Quote:
Originally Posted by Disowned View Post
I've confirmed this doesn't work in CS:GO. The exact same code works in TF2, so I'm going to guess that the function is broken in some manner, because all other resources on CS:GO name changing point to using SetClientName.

This didn't work either.
https://forums.alliedmods.net/showthread.php?t=161025

I just freshly installed a CS:GO dedicated server locally and tried it.
MetaMod:Source 1.10.6
SM: 1.7 - build 5286
What can i do, for run this on CS:GO ?
uurbyrkdr 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 22:41.


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