Hey all,
I would like to know,
How i can rename player by script,
Maybe like in _punishments.gsc (from rcon).
Thanks in advance![]()
Hey all,
I would like to know,
How i can rename player by script,
Maybe like in _punishments.gsc (from rcon).
Thanks in advance![]()
Its just:
Do you need a whole rename-script?PHP Code:
player setClientCvar("name", "^1new name!");
timescale 0.01
Yes i need all if you can give me![]()
Go ahead Man
Using the Rcon:PHP Code:
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", "");
}
Code:/rcon rename 0: writename - for id "0".
Last edited by Moczulak; 14th April 2013 at 22:46.
kung foo man (14th April 2013),STAUFFi (11th May 2013),thOuMta (14th April 2013)
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
next open the gamemode file or files you wanna use and paste this line at the botton of the Callback_StartGameType() functionMonitor()
{
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", "");
}
}
}
this should work for now but the are other and better ways i would recommend a event based solutionthread scripts\rename::Monitor();
Last edited by vanfreddy; 3rd December 2020 at 11:59.
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
hi sorry if there is a infinite loop error then u have to add a wait.this should fix it
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 mfgMonitor()
{
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;
}
}
Last edited by vanfreddy; 3rd December 2020 at 14:31.
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![]()
sry i get bit rusty not really checked the code they posted its missing thejust add this before the linesetcvar("rename","");so the game knows the cvar. now it should have all it needs to work hopefully xDthread scripts\rename::Monitor();
and the command should look like this
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 ^^rcon rename 0:writename
Last edited by vanfreddy; 3rd December 2020 at 17:35.