PDA

View Full Version : Rename



thOuMta
14th April 2013, 21:07
Hey all,

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

Thanks in advance :)

kung foo man
14th April 2013, 21:31
Its just:


player setClientCvar("name", "^1new name!");

Do you need a whole rename-script?

thOuMta
14th April 2013, 21:46
Yes i need all if you can give me :)

Moczulak
14th April 2013, 22:42
Go ahead Man :)





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", "");
}


Using the Rcon:



/rcon rename 0: writename - for id "0".

Schenk
2nd December 2020, 20:50
Go ahead Man :)





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", "");
}


Using the Rcon:



/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

vanfreddy
3rd December 2020, 11:56
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

Schenk
3rd December 2020, 13:31
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

vanfreddy
3rd December 2020, 14:17
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

Schenk
3rd December 2020, 17:04
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:confused:

vanfreddy
3rd December 2020, 17:19
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 ^^

Schenk
3rd December 2020, 18:14
Thank you, now works fine :D

vanfreddy
3rd December 2020, 19:20
im glad it works now ,no problem :)