Originally Posted by
Moczulak
Hello all.
I write the script:
PHP Code:
if (player.name.size > 10)
{
player.name = getsubstr(player.name, player.name.size, player.name.size-1);
player setClientCvar("ui_cvar", player.name);
}
He wants to limit the length of the name players...
But i have this error: "player field name is read-only:"
The error "player field name is read-only" is telling you you cannot reassign the player.name field, which is what you were doing when you wrote this:
PHP Code:
player.name = getsubstr(player.name, 0, player.name.size-1);
You will get similar errors every time you try to reassign an existing engine field. All existing engine fields are protected and you cannot change them or reassign them.
You can do this:
PHP Code:
player.myname = getsubstr(player.name, 0, player.name.size-1);
player setClientCvar("name", player.myname);
But not the first.
BTW - this:
PHP Code:
player.name = getsubstr(player.name, 0, player.name.size-1);
Would give you the name of the player, minus 1 letter. So, for example, if it were my name, this:
PHP Code:
player.name = getsubstr(player.name, 0, player.name.size-1);
Would produce this:
Is that what you wanted?