SA-MP Forums Archive
help for /name command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: help for /name command (/showthread.php?tid=86193)



help for /name command - [GF]sIdEkIcK - 12.07.2009

hey guys, i need the script for the command "/name" like if you type it (eg. /name blah) it will change your name to "blah" plz give me a script, thnx


Re: help for /name command - BLACK-RIDER-1692 - 12.07.2009

that talking about themselves or the name of the chosen?


Re: help for /name command - [GF]sIdEkIcK - 12.07.2009

Quote:
Originally Posted by BLACK-RIDER-1692
that talking about themselves or the name of the chosen?
ye themselves ..

like if i type "/name haha" it will change MY name to 'haha'


Re: help for /name command - BLACK-RIDER-1692 - 12.07.2009

Код:
if(strcmp(cmd, "/name", true)==0){
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))return SendClientMessage(playerid, COLOR, "Usage: /name (New Name)");
SetPlayerName(playerid, tmp);
return 1;
}



Re: help for /name command - [GF]sIdEkIcK - 12.07.2009

Quote:
Originally Posted by BLACK-RIDER-1692
Код:
if(strcmp(cmd, "/name", true)==0){
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))return SendClientMessage(playerid, COLOR, "Usage: /name (New Name)");
SetPlayerName(playerid, tmp);
return 1;
}
thnx, but what must i edit for it to work, i get errors that 'tmp' does not exsist

C:\SAMPSE~1\FILTER~1\server.pwn(119) : error 017: undefined symbol "tmp"
C:\SAMPSE~1\FILTER~1\server.pwn(120) : error 017: undefined symbol "tmp"
C:\SAMPSE~1\FILTER~1\server.pwn(121) : error 017: undefined symbol "tmp"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


3 Errors.



Re: help for /name command - BLACK-RIDER-1692 - 12.07.2009

use agin


Re: help for /name command - [GF]sIdEkIcK - 12.07.2009

Quote:
Originally Posted by BLACK-RIDER-1692
use agin
? it doesnt work..


Re: help for /name command - Rks25 - 12.07.2009

pawn Код:
new tmp[256], idx;



Re: help for /name command - BLACK-RIDER-1692 - 12.07.2009

try this

Код:
if(strcmp(cmd, "/nickname", true) ==0)
	{
	  if(IsPlayerConnected(playerid))
	  {
			GetPlayerName(playerid, sendername, sizeof(sendername));
			new length = strlen(cmdtext);
			while ((idx < length) && (cmdtext[idx] <= ' '))
			{
				idx++;
			}
			new offset = idx;
			new result[64];
			while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
			{
				result[idx - offset] = cmdtext[idx];
				idx++;
			}
			result[idx - offset] = EOS;
			if(!strlen(result))
			{
				SendClientMessage(playerid, color_dgreen, "Server_CommandCheck: /nickname [name]");
				SendClientMessage(playerid, color_dgreen, "Server_CommandCheck: This name will be what others see you as.");
				return 1;
			}
			SetPlayerName(playerid, result);
			OnPlayerUpdate(playerid);

    	format(str, sizeof(str), "Your nickname has been set to '%s'", result);
    	SendClientMessage(playerid, color_white, str);
			return 1;
	  }
	  return 1;
	}



Re: help for /name command - Gergo1352 - 12.07.2009

Don't forget to define color_dgreen and color_white.