SA-MP Forums Archive
simplifying - 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: simplifying (/showthread.php?tid=103916)



simplifying - [HKS]dlegend - 21.10.2009

just wondring is there any way to simplify this


Code:
	dcmd_drift(playerid, params[])
	{
		new pName[MAX_PLAYER_NAME];
		new tString[128];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
		SetPlayerPos(playerid,-307.062805,1538.853515,78.099159);
		format(tString, sizeof(tString), "(News) %s has teleport to drift do /drift to join",pName);
 		SendClientMessageToAll(COLOR_DARKGREEN, tString);
		GameTextForPlayer(playerid,"Welcome to drift",2500,3);
		#pragma unused params
		return 1;
  }



Re: simplifying - saiberfun - 21.10.2009

Quote:
Originally Posted by dlegend
just wondring is there any way to simplify this


Code:
	dcmd_drift(playerid, params[])
	{
		new pName[MAX_PLAYER_NAME];
		new tString[128];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
		SetPlayerPos(playerid,-307.062805,1538.853515,78.099159);
		format(tString, sizeof(tString), "(News) %s has teleport to drift do /drift to join",pName);
 		SendClientMessageToAll(COLOR_DARKGREEN, tString);
		GameTextForPlayer(playerid,"Welcome to drift",2500,3);
		#pragma unused params
		return 1;
  }
well u got 50 characters in ur string + the name which can be max 20
so new tString[128]
only needs to be new tString[70];

and u could use
instead of MAX_PLAYER_NAME in GetPlayerName
sizeof(pName)

but to "simplify it there ain'T much more.


Re: simplifying - [HKS]dlegend - 21.10.2009

ok thanks alot man jw thats all



Re: simplifying - yom - 21.10.2009

Your variable pName is useless, you can use tString to store the player's name.


Re: simplifying - [HKS]dlegend - 21.10.2009

im not that good so how do i do that


Re: simplifying - Correlli - 21.10.2009

Quote:
Originally Posted by dlegend
im not that good so how do i do that
Example:
pawn Code:
new tString[80];
GetPlayerName(playerid, tString, MAX_PLAYER_NAME);
format(tString, sizeof(tString), "(News) %s has teleport to drift do /drift to join", tString);
SendClientMessageToAll(0xFFFFFFAA, tString);



Re: simplifying - [HKS]dlegend - 21.10.2009

thanks dom