![](images/misc/post_spacer.gif) |
Junior Member
|
![Old](images/statusicon/post_old.svg)
12-20-2020
, 14:40
Re: [CS:GO] Trying to make a script to change player's name, when they join
|
#7
|
Quote:
Originally Posted by Ilusion9
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(client, name, sizeof(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(aid, 0, group, sizeof(group)) // group id from target, this is useless, because we don't have a target
StrCat(group, sizeof(group), name) // this should be included in a "if" statatement.
if(gid) {
SetClientName(client, group)
}
}
Try this:
PHP Code:
public OnClientPutInServer(client) {
// get client name
char name[MAX_NAME_LENGTH];
GetClientName(client, name, sizeof(name));
// get admin id
AdminId adminId = GetUserAdmin(client);
if (adminId == INVALID_ADMIN_ID)
{
// this client is not admin
return;
}
// get group id
if (GetAdminGroup(adminId, 0, group, sizeof(group) == INVALID_GROUP_ID)
{
// this client doesnt have a group
return;
}
if (!StrEqual(name, group, true))
{
// client name is different than his group
SetClientName(client, group);
}
}
|
Sorry for giving resposne after 2h, but unfortunetely, it doesn't work
|
|
|
|