/changename help pl0x
#1

I need a /changename command, I have searched for hours?!
Reply
#2

Look in SeifAdmin, i know that had a good one.
Reply
#3

Here is it mate

Код:
	if(strcmp(cmd, "/changename", true) == 0)
	{
	  GetPlayerName(playerid, sendername, sizeof(sendername));
		new tmpp[256];
		tmpp = strtok(cmdtext, idx);
		if(!strlen(tmpp))
		{
			SendClientMessage(playerid, COLOR_DBLUE, "Correct SYNTAX: /changename [playerid] [new nick]");
			return 1;
		}
		giveplayerid = strval(tmpp);
		tmp = strtok(cmdtext, idx);
		GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
		GetPlayerName(playerid, sendername, sizeof(sendername));
		if(IsPlayerConnected(playerid))
		{
		  if(PlayerInfo[playerid][pAdmin] >= 1337)
		  {
		    if(IsPlayerConnected(giveplayerid))
		    {
					SetPlayerName(giveplayerid, tmp);
					format(string, sizeof(string), "AdmCMD: %s(%i) has changed Your name to %s", sendername, playerid, tmp);
					SendClientMessage(giveplayerid, COLOR_DBLUE, string);
					format(string, sizeof(string), "AdmCMD: You have changed ID %i's name to %s", giveplayerid, tmp);
					SendClientMessage(playerid, COLOR_DBLUE, string);
					format(string, 256, "AdmWarning: %s has changed %s's his name to %s.", sendername,giveplayer, tmp);
					ABroadCast(COLOR_YELLOW,string,1);
				}
				else
				{
				  format(string, sizeof(string), "%d is not an active player.", giveplayerid);
					SendClientMessage(playerid, COLOR_RED, string);
				}
			}
			else
			{
			  SendClientMessage(playerid, COLOR_RED, "You do not have permission to use that command!");
			}
		}
		else
		{
		  SendClientMessage(playerid, COLOR_RED, "You Must be logged in to use this command!");
		}
	 	return 1;
	}
Reply
#4

Quote:
Originally Posted by Lonka
Here is it mate

Код:
	if(strcmp(cmd, "/changename", true) == 0)
	{
	  GetPlayerName(playerid, sendername, sizeof(sendername));
		new tmpp[256];
		tmpp = strtok(cmdtext, idx);
		if(!strlen(tmpp))
		{
			SendClientMessage(playerid, COLOR_DBLUE, "Correct SYNTAX: /changename [playerid] [new nick]");
			return 1;
		}
		giveplayerid = strval(tmpp);
		tmp = strtok(cmdtext, idx);
		GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
		GetPlayerName(playerid, sendername, sizeof(sendername));
		if(IsPlayerConnected(playerid))
		{
		  if(PlayerInfo[playerid][pAdmin] >= 1337)
		  {
		    if(IsPlayerConnected(giveplayerid))
		    {
					SetPlayerName(giveplayerid, tmp);
					format(string, sizeof(string), "AdmCMD: %s(%i) has changed Your name to %s", sendername, playerid, tmp);
					SendClientMessage(giveplayerid, COLOR_DBLUE, string);
					format(string, sizeof(string), "AdmCMD: You have changed ID %i's name to %s", giveplayerid, tmp);
					SendClientMessage(playerid, COLOR_DBLUE, string);
					format(string, 256, "AdmWarning: %s has changed %s's his name to %s.", sendername,giveplayer, tmp);
					ABroadCast(COLOR_YELLOW,string,1);
				}
				else
				{
				  format(string, sizeof(string), "%d is not an active player.", giveplayerid);
					SendClientMessage(playerid, COLOR_RED, string);
				}
			}
			else
			{
			  SendClientMessage(playerid, COLOR_RED, "You do not have permission to use that command!");
			}
		}
		else
		{
		  SendClientMessage(playerid, COLOR_RED, "You Must be logged in to use this command!");
		}
	 	return 1;
	}
How can i Edit this so that Player's can use it..like on Redgies Roleplay
Reply
#5

Quote:
Originally Posted by x-ray313
Quote:
Originally Posted by Lonka
Here is it mate

Код:
	if(strcmp(cmd, "/changename", true) == 0)
	{
	  GetPlayerName(playerid, sendername, sizeof(sendername));
		new tmpp[256];
		tmpp = strtok(cmdtext, idx);
		if(!strlen(tmpp))
		{
			SendClientMessage(playerid, COLOR_DBLUE, "Correct SYNTAX: /changename [playerid] [new nick]");
			return 1;
		}
		giveplayerid = strval(tmpp);
		tmp = strtok(cmdtext, idx);
		GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
		GetPlayerName(playerid, sendername, sizeof(sendername));
		if(IsPlayerConnected(playerid))
		{
		  if(PlayerInfo[playerid][pAdmin] >= 1337)
		  {
		    if(IsPlayerConnected(giveplayerid))
		    {
					SetPlayerName(giveplayerid, tmp);
					format(string, sizeof(string), "AdmCMD: %s(%i) has changed Your name to %s", sendername, playerid, tmp);
					SendClientMessage(giveplayerid, COLOR_DBLUE, string);
					format(string, sizeof(string), "AdmCMD: You have changed ID %i's name to %s", giveplayerid, tmp);
					SendClientMessage(playerid, COLOR_DBLUE, string);
					format(string, 256, "AdmWarning: %s has changed %s's his name to %s.", sendername,giveplayer, tmp);
					ABroadCast(COLOR_YELLOW,string,1);
				}
				else
				{
				  format(string, sizeof(string), "%d is not an active player.", giveplayerid);
					SendClientMessage(playerid, COLOR_RED, string);
				}
			}
			else
			{
			  SendClientMessage(playerid, COLOR_RED, "You do not have permission to use that command!");
			}
		}
		else
		{
		  SendClientMessage(playerid, COLOR_RED, "You Must be logged in to use this command!");
		}
	 	return 1;
	}
How can i Edit this so that Player's can use it..like on Redgies Roleplay
Also Will this make the name permanent?
Reply
#6

Quote:
Originally Posted by x-ray313
Quote:
Originally Posted by Lonka
Here is it mate

Код:
	if(strcmp(cmd, "/changename", true) == 0)
	{
	  GetPlayerName(playerid, sendername, sizeof(sendername));
		new tmpp[256];
		tmpp = strtok(cmdtext, idx);
		if(!strlen(tmpp))
		{
			SendClientMessage(playerid, COLOR_DBLUE, "Correct SYNTAX: /changename [playerid] [new nick]");
			return 1;
		}
		giveplayerid = strval(tmpp);
		tmp = strtok(cmdtext, idx);
		GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
		GetPlayerName(playerid, sendername, sizeof(sendername));
		if(IsPlayerConnected(playerid))
		{
		  if(PlayerInfo[playerid][pAdmin] >= 1337)
		  {
		    if(IsPlayerConnected(giveplayerid))
		    {
					SetPlayerName(giveplayerid, tmp);
					format(string, sizeof(string), "AdmCMD: %s(%i) has changed Your name to %s", sendername, playerid, tmp);
					SendClientMessage(giveplayerid, COLOR_DBLUE, string);
					format(string, sizeof(string), "AdmCMD: You have changed ID %i's name to %s", giveplayerid, tmp);
					SendClientMessage(playerid, COLOR_DBLUE, string);
					format(string, 256, "AdmWarning: %s has changed %s's his name to %s.", sendername,giveplayer, tmp);
					ABroadCast(COLOR_YELLOW,string,1);
				}
				else
				{
				  format(string, sizeof(string), "%d is not an active player.", giveplayerid);
					SendClientMessage(playerid, COLOR_RED, string);
				}
			}
			else
			{
			  SendClientMessage(playerid, COLOR_RED, "You do not have permission to use that command!");
			}
		}
		else
		{
		  SendClientMessage(playerid, COLOR_RED, "You Must be logged in to use this command!");
		}
	 	return 1;
	}
How can i Edit this so that Player's can use it..like on Redgies Roleplay
This is a stupid code! You use wasted arrays for nothing!
pawn Код:
new
  string[128];
if(!strcmp(cmdtext,"/changename",true))
{
  new name[MAX_PLAYER_NAME];
  if(cmdtext[idx++]!=32||cmdtext[idx]=='\0') return SendClientMessage(playerid,color,"/changename [new name]");
  GetPlayerName(playerid,name,MAX_PLAYER_NAME);
  format(string,sizeof(string),"%s changed name to %s.",name,cmdtext[idx]);
  SendClientMessageToAll(color,string);
  SetPlayerName(playerid,cmdtext[idx]);
  return 1;
}
Tell me if I missed something.
Reply
#7

Quote:
Originally Posted by MenaceX^
Quote:
Originally Posted by x-ray313
Quote:
Originally Posted by Lonka
Here is it mate

Код:
	if(strcmp(cmd, "/changename", true) == 0)
	{
	  GetPlayerName(playerid, sendername, sizeof(sendername));
		new tmpp[256];
		tmpp = strtok(cmdtext, idx);
		if(!strlen(tmpp))
		{
			SendClientMessage(playerid, COLOR_DBLUE, "Correct SYNTAX: /changename [playerid] [new nick]");
			return 1;
		}
		giveplayerid = strval(tmpp);
		tmp = strtok(cmdtext, idx);
		GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
		GetPlayerName(playerid, sendername, sizeof(sendername));
		if(IsPlayerConnected(playerid))
		{
		  if(PlayerInfo[playerid][pAdmin] >= 1337)
		  {
		    if(IsPlayerConnected(giveplayerid))
		    {
					SetPlayerName(giveplayerid, tmp);
					format(string, sizeof(string), "AdmCMD: %s(%i) has changed Your name to %s", sendername, playerid, tmp);
					SendClientMessage(giveplayerid, COLOR_DBLUE, string);
					format(string, sizeof(string), "AdmCMD: You have changed ID %i's name to %s", giveplayerid, tmp);
					SendClientMessage(playerid, COLOR_DBLUE, string);
					format(string, 256, "AdmWarning: %s has changed %s's his name to %s.", sendername,giveplayer, tmp);
					ABroadCast(COLOR_YELLOW,string,1);
				}
				else
				{
				  format(string, sizeof(string), "%d is not an active player.", giveplayerid);
					SendClientMessage(playerid, COLOR_RED, string);
				}
			}
			else
			{
			  SendClientMessage(playerid, COLOR_RED, "You do not have permission to use that command!");
			}
		}
		else
		{
		  SendClientMessage(playerid, COLOR_RED, "You Must be logged in to use this command!");
		}
	 	return 1;
	}
How can i Edit this so that Player's can use it..like on Redgies Roleplay
This is a stupid code! You use wasted arrays for nothing!
pawn Код:
new
  string[128];
if(!strcmp(cmdtext,"/changename",true))
{
  new name[MAX_PLAYER_NAME];
  if(cmdtext[idx++]!=32||cmdtext[idx]=='\0') return SendClientMessage(playerid,color,"/changename [new name]");
  GetPlayerName(playerid,name,MAX_PLAYER_NAME);
  format(string,sizeof(string),"%s changed name to %s.",name,cmdtext[idx]);
  SendClientMessageToAll(color,string);
  SetPlayerName(playerid,cmdtext[idx]);
  return 1;
}
Tell me if I missed something.
Will That change the Player's Name in the scriptfiles? or just till he logs off?
Reply
#8

Use frename.
You should also add a check if the characters are valid. Otherwise it will crash (localhost server, most hosted got protection) your server.
Reply
#9

Quote:
Originally Posted by x-ray313
Quote:
Originally Posted by MenaceX^
Quote:
Originally Posted by x-ray313
Quote:
Originally Posted by Lonka
Here is it mate

Код:
	if(strcmp(cmd, "/changename", true) == 0)
	{
	  GetPlayerName(playerid, sendername, sizeof(sendername));
		new tmpp[256];
		tmpp = strtok(cmdtext, idx);
		if(!strlen(tmpp))
		{
			SendClientMessage(playerid, COLOR_DBLUE, "Correct SYNTAX: /changename [playerid] [new nick]");
			return 1;
		}
		giveplayerid = strval(tmpp);
		tmp = strtok(cmdtext, idx);
		GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
		GetPlayerName(playerid, sendername, sizeof(sendername));
		if(IsPlayerConnected(playerid))
		{
		  if(PlayerInfo[playerid][pAdmin] >= 1337)
		  {
		    if(IsPlayerConnected(giveplayerid))
		    {
					SetPlayerName(giveplayerid, tmp);
					format(string, sizeof(string), "AdmCMD: %s(%i) has changed Your name to %s", sendername, playerid, tmp);
					SendClientMessage(giveplayerid, COLOR_DBLUE, string);
					format(string, sizeof(string), "AdmCMD: You have changed ID %i's name to %s", giveplayerid, tmp);
					SendClientMessage(playerid, COLOR_DBLUE, string);
					format(string, 256, "AdmWarning: %s has changed %s's his name to %s.", sendername,giveplayer, tmp);
					ABroadCast(COLOR_YELLOW,string,1);
				}
				else
				{
				  format(string, sizeof(string), "%d is not an active player.", giveplayerid);
					SendClientMessage(playerid, COLOR_RED, string);
				}
			}
			else
			{
			  SendClientMessage(playerid, COLOR_RED, "You do not have permission to use that command!");
			}
		}
		else
		{
		  SendClientMessage(playerid, COLOR_RED, "You Must be logged in to use this command!");
		}
	 	return 1;
	}
How can i Edit this so that Player's can use it..like on Redgies Roleplay
This is a stupid code! You use wasted arrays for nothing!
pawn Код:
new
  string[128];
if(!strcmp(cmdtext,"/changename",true))
{
  new name[MAX_PLAYER_NAME];
  if(cmdtext[idx++]!=32||cmdtext[idx]=='\0') return SendClientMessage(playerid,color,"/changename [new name]");
  GetPlayerName(playerid,name,MAX_PLAYER_NAME);
  format(string,sizeof(string),"%s changed name to %s.",name,cmdtext[idx]);
  SendClientMessageToAll(color,string);
  SetPlayerName(playerid,cmdtext[idx]);
  return 1;
}
Tell me if I missed something.
Will That change the Player's Name in the scriptfiles? or just till he logs off?
Depends how you save the player's name.
Reply
#10

Quote:
Originally Posted by MenaceX^
Quote:
Originally Posted by x-ray313
Quote:
Originally Posted by MenaceX^
Quote:
Originally Posted by x-ray313
Quote:
Originally Posted by Lonka
Here is it mate

Код:
	if(strcmp(cmd, "/changename", true) == 0)
	{
	  GetPlayerName(playerid, sendername, sizeof(sendername));
		new tmpp[256];
		tmpp = strtok(cmdtext, idx);
		if(!strlen(tmpp))
		{
			SendClientMessage(playerid, COLOR_DBLUE, "Correct SYNTAX: /changename [playerid] [new nick]");
			return 1;
		}
		giveplayerid = strval(tmpp);
		tmp = strtok(cmdtext, idx);
		GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
		GetPlayerName(playerid, sendername, sizeof(sendername));
		if(IsPlayerConnected(playerid))
		{
		  if(PlayerInfo[playerid][pAdmin] >= 1337)
		  {
		    if(IsPlayerConnected(giveplayerid))
		    {
					SetPlayerName(giveplayerid, tmp);
					format(string, sizeof(string), "AdmCMD: %s(%i) has changed Your name to %s", sendername, playerid, tmp);
					SendClientMessage(giveplayerid, COLOR_DBLUE, string);
					format(string, sizeof(string), "AdmCMD: You have changed ID %i's name to %s", giveplayerid, tmp);
					SendClientMessage(playerid, COLOR_DBLUE, string);
					format(string, 256, "AdmWarning: %s has changed %s's his name to %s.", sendername,giveplayer, tmp);
					ABroadCast(COLOR_YELLOW,string,1);
				}
				else
				{
				  format(string, sizeof(string), "%d is not an active player.", giveplayerid);
					SendClientMessage(playerid, COLOR_RED, string);
				}
			}
			else
			{
			  SendClientMessage(playerid, COLOR_RED, "You do not have permission to use that command!");
			}
		}
		else
		{
		  SendClientMessage(playerid, COLOR_RED, "You Must be logged in to use this command!");
		}
	 	return 1;
	}
How can i Edit this so that Player's can use it..like on Redgies Roleplay
This is a stupid code! You use wasted arrays for nothing!
pawn Код:
new
  string[128];
if(!strcmp(cmdtext,"/changename",true))
{
  new name[MAX_PLAYER_NAME];
  if(cmdtext[idx++]!=32||cmdtext[idx]=='\0') return SendClientMessage(playerid,color,"/changename [new name]");
  GetPlayerName(playerid,name,MAX_PLAYER_NAME);
  format(string,sizeof(string),"%s changed name to %s.",name,cmdtext[idx]);
  SendClientMessageToAll(color,string);
  SetPlayerName(playerid,cmdtext[idx]);
  return 1;
}
Tell me if I missed something.
Will That change the Player's Name in the scriptfiles? or just till he logs off?
Depends how you save the player's name.
I'm using a Gf edit. So can u please give me a example...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)