Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Shortening nick player

  1. #1
    Private
    Join Date
    Aug 2012
    Posts
    78
    Thanks
    20
    Thanked 10 Times in 5 Posts

    Shortening nick player

    Hello all.
    I write the script:

    PHP Code:
    if (player.name.size 10)
    {
        
    player.name getsubstr(player.nameplayer.name.sizeplayer.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:"

  2. #2
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    getsubstr(string, start, end)

    Your start is not 0, but is player.name.size. fix it.

    Also: dont write to player.name, write to player cvar "name"

  3. The Following User Says Thank You to IzNoGoD For This Useful Post:

    kung foo man (21st March 2013)

  4. #3
    Private
    Join Date
    Aug 2012
    Posts
    78
    Thanks
    20
    Thanked 10 Times in 5 Posts
    So what if I do this calculation? I do not know exactly how it works getsubstr function () I only know its possible...

  5. #4
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    That should be enough:

    PHP Code:

    if (player.name.size 10)
    {
        
    newName getsubstr(player.name010);
        
    player setClientCvar("ui_cvar"newName); // whatever this is for
        
    player setClientCvar("name"newName); // set new name to player

    timescale 0.01

  6. The Following User Says Thank You to kung foo man For This Useful Post:

    Moczulak (21st March 2013)

  7. #5
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by Moczulak View Post
    Hello all.
    I write the script:

    PHP Code:
    if (player.name.size 10)
    {
        
    player.name getsubstr(player.nameplayer.name.sizeplayer.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.name0player.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.name0player.name.size-1);
    player setClientCvar("name"player.myname); 
    But not the first.

    BTW - this:

    PHP Code:
    player.name getsubstr(player.name0player.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.name0player.name.size-1); 
    Would produce this:

    PHP Code:
    Tall 
    Is that what you wanted?
    Last edited by Tally; 21st March 2013 at 12:15.

  8. The Following 2 Users Say Thank You to Tally For This Useful Post:

    kung foo man (21st March 2013),Moczulak (21st March 2013)

  9. #6
    Private
    Join Date
    Aug 2012
    Posts
    78
    Thanks
    20
    Thanked 10 Times in 5 Posts
    Very thanks Tally and Kung Foo Man

  10. #7
    Private
    Join Date
    Aug 2012
    Posts
    78
    Thanks
    20
    Thanked 10 Times in 5 Posts
    Shortened nickname player has to see self ,please help me..
    This script not work:

    PHP Code:
    player.myname getsubstr(player.name0player.name.size-1);
    self setClientCvar("ui_dvarmenu"player.myname); 

  11. #8
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    I dont understand your goal
    timescale 0.01

  12. #9
    Sergeant EvoloZz's Avatar
    Join Date
    Sep 2012
    Location
    Helsinki, Finland
    Posts
    360
    Thanks
    314
    Thanked 167 Times in 120 Posts
    player setClientCvar() instead of self setClientCvar()

  13. #10
    Private
    Join Date
    Aug 2012
    Posts
    78
    Thanks
    20
    Thanked 10 Times in 5 Posts
    I open the menu.
    I see the name of a player.
    I would like to shorten the player name to 10 characters.

    I think I explained clearly enough what effect I would get... :P
    Last edited by Moczulak; 21st March 2013 at 17:25.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •