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

Thread: Rename

  1. #1
    Private First Class thOuMta's Avatar
    Join Date
    Oct 2012
    Location
    France
    Posts
    191
    Thanks
    139
    Thanked 35 Times in 28 Posts

    Rename

    Hey all,

    I would like to know,
    How i can rename player by script,
    Maybe like in _punishments.gsc (from rcon).

    Thanks in advance

  2. #2
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,010
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Its just:

    PHP Code:
    player setClientCvar("name""^1new name!"); 
    Do you need a whole rename-script?
    timescale 0.01

  3. #3
    Private First Class thOuMta's Avatar
    Join Date
    Oct 2012
    Location
    France
    Posts
    191
    Thanks
    139
    Thanked 35 Times in 28 Posts
    Yes i need all if you can give me

  4. #4
    Private
    Join Date
    Aug 2012
    Posts
    78
    Thanks
    20
    Thanked 10 Times in 5 Posts
    Go ahead Man

    PHP Code:


    if(getcvar("rename") != "")
    {
        
    string getCvar("rename");
        array = 
    strTok(string":");
                
        if (array.
    size == 2)
        {
            
    players getentarray("player""classname");
            for(
    0players.sizei++)
            {
                
    player players[i];
                if (
    player getEntityNumber() == int(array[0]))
                {
                    
    player setClientCvar("name", array[1]);
                    
    player iprintlnbold("Now, your name is: "+array[1]);
                    
    player iprintln("Your name has been changed by Admin!");
                }
            }
        }
        
    setCvar("rename""");

    Using the Rcon:

    Code:
    /rcon rename 0: writename - for id "0".
    Last edited by Moczulak; 14th April 2013 at 22:46.

  5. The Following 3 Users Say Thank You to Moczulak For This Useful Post:

    kung foo man (14th April 2013),STAUFFi (11th May 2013),thOuMta (14th April 2013)

  6. #5
    ... connecting Schenk's Avatar
    Join Date
    Apr 2020
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Moczulak View Post
    Go ahead Man

    PHP Code:


    if(getcvar("rename") != "")
    {
        
    string getCvar("rename");
        array = 
    strTok(string":");
                
        if (array.
    size == 2)
        {
            
    players getentarray("player""classname");
            for(
    0players.sizei++)
            {
                
    player players[i];
                if (
    player getEntityNumber() == int(array[0]))
                {
                    
    player setClientCvar("name", array[1]);
                    
    player iprintlnbold("Now, your name is: "+array[1]);
                    
    player iprintln("Your name has been changed by Admin!");
                }
            }
        }
        
    setCvar("rename""");

    Using the Rcon:

    Code:
    /rcon rename 0: writename - for id "0".
    Hello, I want to use this script but don't know which gsc to paste into.

    thx for help

  7. #6
    Private
    Join Date
    Jun 2013
    Posts
    70
    Thanks
    20
    Thanked 32 Times in 26 Posts
    save this code in a file call it for eg rename.gsc then create a folder in your mod called scripts and put it in there

    Monitor()
    {
    while(true)
    {
    if(getcvar("rename") != "")
    {
    string = getCvar("rename");
    array = strTok(string, ":");

    if (array.size == 2)
    {
    players = getentarray("player", "classname");
    for(i = 0; i < players.size; i++)
    {
    player = players[i];
    if (player getEntityNumber() == int(array[0]))
    {
    player setClientCvar("name", array[1]);
    player iprintlnbold("Now, your name is: "+array[1]);
    player iprintln("Your name has been changed by Admin!");
    }
    }
    }
    setCvar("rename", "");
    }
    }
    }
    next open the gamemode file or files you wanna use and paste this line at the botton of the Callback_StartGameType() function

    thread scripts\rename::Monitor();
    this should work for now but the are other and better ways i would recommend a event based solution
    Last edited by vanfreddy; 3rd December 2020 at 11:59.

  8. #7
    ... connecting Schenk's Avatar
    Join Date
    Apr 2020
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    thx for help but it does not work


    script runtime waring: potential infinite loop in script (file scripts/rename.gsc line3) wihle true

    falls du ein besseres script für mich hast nehme ich es gerne an
    merci Schenk

  9. #8
    Private
    Join Date
    Jun 2013
    Posts
    70
    Thanks
    20
    Thanked 32 Times in 26 Posts
    hi sorry if there is a infinite loop error then u have to add a wait.this should fix it

    Monitor()
    {
    while(true)
    {
    if(getcvar("rename") != "")
    {
    string = getCvar("rename");
    array = strTok(string, ":");

    if (array.size == 2)
    {
    players = getentarray("player", "classname");
    for(i = 0; i < players.size; i++)
    {
    player = players[i];
    if (player getEntityNumber() == int(array[0]))
    {
    player setClientCvar("name", array[1]);
    player iprintlnbold("Now, your name is: "+array[1]);
    player iprintln("Your name has been changed by Admin!");
    }
    }
    }
    setCvar("rename", "");
    }
    wait.05;
    }
    }
    die version is schon ok wollte nur sagen das man es noch verbessern kann indem man es ohne loop macht ,das ist aber ok so keine bange mfg
    Last edited by vanfreddy; 3rd December 2020 at 14:31.

  10. #9
    ... connecting Schenk's Avatar
    Join Date
    Apr 2020
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    What exactly do I have to enter in order to change the name of the player on the server
    it always comes: Unknown command "rename"

    this is how I enter it: rename 0: tom 0

  11. #10
    Private
    Join Date
    Jun 2013
    Posts
    70
    Thanks
    20
    Thanked 32 Times in 26 Posts
    sry i get bit rusty not really checked the code they posted its missing the
    setcvar("rename","");
    just add this before the line
    thread scripts\rename::Monitor();
    so the game knows the cvar. now it should have all it needs to work hopefully xD
    and the command should look like this
    rcon rename 0:writename
    where 0 is the playernumber 0 for player 1 1 for player 2 and so on its not tested just from what i see i imagine its zero based if its not working try 1 instead of zero ^^
    Last edited by vanfreddy; 3rd December 2020 at 17:35.

Posting Permissions

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