SA-MP Forums Archive
Wrongs Messages - 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)
+--- Thread: Wrongs Messages (/showthread.php?tid=580902)



Wrongs Messages - SecretBoss - 09.07.2015

hello, I have this code

Код:
CMD:changecolor(playerid, params[])
{
	SetPlayerColor(playerid, RandomColors[random(200)]);
	
	new msg[175];
 	format(msg, sizeof (msg), "{%06x}You have successfully changed your color to this message's color", GetPlayerColor(playerid) >>> 8);
  	SendClientMessage(playerid, -1, msg);
  	return 1;
}
its working perfectly when there is only 1 member on server but when there are 2+ members it sends the message to random message, I don't know whats the problem, this is also happening with other commands also with my textdraws


Re: Wrongs Messages - Michael B - 09.07.2015

Try this code:

PHP код:
CMD:changecolor(playeridparams[])
{
    
SetPlayerColor(playeridRandomColors[random(200)]);
    
SendClientMessage(playerid, -1"{%06x}You have successfully changed your color to this message's color.",GetPlayerColor(playerid));
      return 
1;




Re: Wrongs Messages - SecretBoss - 09.07.2015

Quote:
Originally Posted by Michael B
Посмотреть сообщение
Try this code:

PHP код:
CMD:changecolor(playeridparams[])
{
    
SetPlayerColor(playeridRandomColors[random(200)]);
    
SendClientMessage(playerid0xFFFFFFFF"{%06x}You have successfully changed your color to this message's color.",GetPlayerColor(playerid));
      return 
1;

yea but the color "{%06x}" will not be displayed because its format anyway it was SendClientMessageToAll I changed it and its working now but I have another problem

I have this

Код:
	format(string, 15, "%s", pName(playerid));
	TextDrawSetString(Text:nameTD, string);
	TextDrawShowForPlayer(playerid, nameTD);
when you join its working perfectly but when another player joins it display his name

and the stock of pName

Код:
stock pName(playerid)
{
	new GetName[24];
	GetPlayerName(playerid, GetName, 24);
	return GetName;
}



Re: Wrongs Messages - Michael B - 09.07.2015

Try this code under OnPlayerSpawn callback.

PHP код:
public OnPlayerSpawn(playerid)
{
 
    new 
name[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));
 
    
format(stringsizeof(string), "%"name);
    
TextDrawSetString(Text:nameTDstring);
    
TextDrawShowForPlayer(playeridnameTD);
 
    return 
1;




Re: Wrongs Messages - SecretBoss - 09.07.2015

as you can see I already have a string

Код:
format(string, 15, "%s", pName(playerid));
	TextDrawSetString(Text:nameTD, string);
	TextDrawShowForPlayer(playerid, nameTD);
about the name I am using the stock pName so it will display all what you typed above still can't find the problem -_-


Re: Wrongs Messages - Michael B - 09.07.2015

Yeah, but you were supposed to replace it with the code I provided, in order to test it. The problem might encounter due to other factors, which are not listed above.


Re: Wrongs Messages - SecretBoss - 09.07.2015

Quote:
Originally Posted by Michael B
Посмотреть сообщение
Yeah, but you were supposed to replace it with the code I provided, in order to test it. The problem might encounter due to other factors, which are not listed above.
ok btw i think you missed a s

Код:
format(string, sizeof(string), "%", name);



Re: Wrongs Messages - Michael B - 09.07.2015

Yep, sorry, I typed that on Android.