Wrongs Messages
#1

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
Reply
#2

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;

Reply
#3

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;
}
Reply
#4

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;

Reply
#5

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 -_-
Reply
#6

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.
Reply
#7

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);
Reply
#8

Yep, sorry, I typed that on Android.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)