SA-MP Forums Archive
chat colour change - 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: chat colour change (/showthread.php?tid=150795)



chat colour change - Kar - 27.05.2010

i need a command where like u do /tagcolors to change the colour of ur name i tried to make one on my own but i phailed epicly


Re: chat colour change - omgunoobjk - 27.05.2010

Ohhk? You just want to change your players color. (In default chat, the color of yourself will be the same when you talk too)

Simple as this.

Код:
	if(strcmp(cmd, "/changemycolour", true) == 0)
	{
SetPlayerColor(playerid, CHOOSEACOLOR);
}
		return 1;
	}



Re: chat colour change - ipsBruno - 28.05.2010

Quote:
Originally Posted by iRape
Ohhk? You just want to change your players color. (In default chat, the color of yourself will be the same when you talk too)

Simple as this.

Код:
	if(strcmp(cmd, "/changemycolour", true) == 0)
	{
SetPlayerColor(playerid, CHOOSEACOLOR);
}
		return 1;
	}
oh My God, is strtok

Here Code Strtok and Command:

pawn Код:
public OnPlayerCommandText(playerid,cmdtext[]) {
  new index, cmd[128];
  cmd = strtok(cmdtext, index);
  if (!strcmp("/color",cmd,true,6)) {
    SetPlayerColor(playerid,Color);//COLOR = COLOR
    return 1;
  }
  return 0;
}
//-----------------------------------------
strtok(const string[], &index)
{
  new length = strlen(string);
  while ((index < length) && (string[index] <= ' '))
  {
    index++;
  }
  new offset = index;
  new result[20];
  while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  {
    result[index - offset] = string[index];
    index++;
  }
  result[index - offset] = EOS;
  return result;
}



Re: chat colour change - Kar - 28.05.2010

Код:
	if(strcmp(cmd, "/changemycolour", true) == 0)
	{
SetPlayerColor(playerid, CHOOSEACOLOR);
}
		return 1;
	}
2 errors
Код:
C:\DOCUME~1\Karim\MYDOCU~1\GRANDT~1\SAMPSE~1\GAMEMO~1\COPSNR~1.PWN(161) : error 010: invalid function or declaration
C:\DOCUME~1\Karim\MYDOCU~1\GRANDT~1\SAMPSE~1\GAMEMO~1\COPSNR~1.PWN(165) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.



Re: chat colour change - (SF)Noobanatior - 28.05.2010

post lines 160-170



Re: chat colour change - ColdXX - 28.05.2010

Should work now

pawn Код:
if(strcmp(cmd, "/changemycolour", true) == 0)
        {
        SetPlayerColor(playerid, CHOOSEACOLOR);
        return 1;
        }
But use this better....

pawn Код:
public OnPlayerCommandText(playerid,cmdtext[]) {
  new index, cmd[128];
  cmd = strtok(cmdtext, index);
  if (!strcmp("/color",cmd,true,6)) {
    SetPlayerColor(playerid,Color);//COLOR = COLOR
    return 1;
  }
  return 0;
}
//-----------------------------------------
strtok(const string[], &index)
{
  new length = strlen(string);
  while ((index < length) && (string[index] <= ' '))
  {
    index++;
  }
  new offset = index;
  new result[20];
  while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  {
    result[index - offset] = string[index];
    index++;
  }
  result[index - offset] = EOS;
  return result;
}



Re: chat colour change - Kar - 28.05.2010

Код:
  if(strcmp(cmd, "/changemycolour", true) == 0)
    {
    SetPlayerColor(playerid, CHOOSEACOLOR);
    return 1;
}
doesnt work still look what i have
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if(strcmp("/drift1", cmdtext, true) == 0)
{
	if(IsPlayerInAnyVehicle(playerid) == 1)
	{
	SetVehiclePos(GetPlayerVehicleID(playerid), -334.0647,1528.6570,75.0189);
	}
	else
	{
	SetPlayerPos(playerid, -329.3348,1536.3771,76.6117);
	}
}
	if(strcmp("/AA", cmdtext, true) == 0)
{
	if(IsPlayerInAnyVehicle(playerid) == 1)
	{
	SetVehiclePos(GetPlayerVehicleID(playerid),406.9412,2437.8621,16.3950);
	new pvehicleid;
	SetVehicleZAngle(pvehicleid, 406);
	}
	else
	{
	SetPlayerPos(playerid,406.9412,2437.8621,16.3950);
	}
	}
	return 1;
}
  if(strcmp(cmd, "/changemycolour", true) == 0)
    {
    SetPlayerColor(playerid, CHOOSEACOLOR);
    return 1;
}
thats line 133-165
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if(strcmp("/drift1", cmdtext, true) == 0)
{
	if(IsPlayerInAnyVehicle(playerid) == 1)
	{
	SetVehiclePos(GetPlayerVehicleID(playerid), -334.0647,1528.6570,75.0189);
	}
	else
	{
	SetPlayerPos(playerid, -329.3348,1536.3771,76.6117);
	}
}
	if(strcmp("/AA", cmdtext, true) == 0)
{
	if(IsPlayerInAnyVehicle(playerid) == 1)
	{
	SetVehiclePos(GetPlayerVehicleID(playerid),406.9412,2437.8621,16.3950);
	new pvehicleid;
	SetVehicleZAngle(pvehicleid, 406);
	}
	else
	{
	SetPlayerPos(playerid,406.9412,2437.8621,16.3950);
	}
	}
	return 1;
}
  if(strcmp(cmd, "/changemycolour", true) == 0)
    {
    SetPlayerColor(playerid, CHOOSEACOLOR);
    return 1;
}
gives me 1 error cant define "color"



Re: chat colour change - (SF)Noobanatior - 28.05.2010

can you post all of OnPlayerCommandText(playerid, cmdtext[]) and ill try compile it


Re: chat colour change - ColdXX - 28.05.2010

Post the whole error here...:S



Re: chat colour change - aircombat - 28.05.2010

guys u are all answering him wrong do u really think this ::

Код:
public OnPlayerCommandText(playerid,cmdtext[]) {
  new index, cmd[128]; 
  cmd = strtok(cmdtext, index);
  if (!strcmp("/color",cmd,true,6)) {
    SetPlayerColor(playerid,Color);//COLOR = COLOR 
    return 1;
  }
  return 0;
}
//----------------------------------------- 
strtok(const string[], &index)
{
  new length = strlen(string);
  while ((index < length) && (string[index] <= ' '))
  {
    index++;
  }
  new offset = index;
  new result[20];
  while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  {
    result[index - offset] = string[index];
    index++;
  }
  result[index - offset] = EOS;
  return result;
}
will work?? it doesn't even use strtok

Topic Poster : i sent u a pm of my email , i can help u creating the command and fixing ur errors buddy