View Single Post
Kazafka
Junior Member
Join Date: Dec 2020
Old 12-20-2020 , 14:40   Re: [CS:GO] Trying to make a script to change player's name, when they join
Reply With Quote #7

Quote:
Originally Posted by Ilusion9 View Post
What is wrong with your code:
PHP Code:
public OnClientPutInServer(client) {
    
    
char name[MAX_NAME_LENGTH], group[MAX_NAME_LENGTH];
    
// FindTarget is used in commands (example: sm_ban) to find a target from a a given string.
    // this is useless
    
new target FindTarget(client""// remove this
    
    
GetClientName(clientnamesizeof(name)) // this get the clients name, nothing wrong
    
AdminId aid GetUserAdmin(target// AdminId from target, this is useless, because we don't have a target
    
GroupId gid GetAdminGroup(aid0groupsizeof(group)) // group id from target, this is useless, because we don't have a target
    
    
StrCat(groupsizeof(group), name// this should be included in a "if" statatement.
    
    
if(gid) {
        
SetClientName(clientgroup)
    }

Try this:
PHP Code:

public OnClientPutInServer(client) {
    
    
// get client name
    
char name[MAX_NAME_LENGTH];
    
GetClientName(clientnamesizeof(name));

    
// get admin id
    
AdminId adminId GetUserAdmin(client);
    if (
adminId == INVALID_ADMIN_ID)
    {
        
// this client is not admin
        
return;
    }

    
// get group id
    
if (GetAdminGroup(adminId0groupsizeof(group) == INVALID_GROUP_ID)
    {
        
// this client doesnt have a group
        
return;
    }
    
    if (!
StrEqual(namegrouptrue))
    {
        
// client name is different than his group
        
SetClientName(clientgroup);
    }

Sorry for giving resposne after 2h, but unfortunetely, it doesn't work
Kazafka is offline