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



Carcolour help - MB@ - 20.08.2009

When i type

Код:
if(strcmp(cmdtext, "/carcolour", true) == 0)
	{
	new tmp[256];
	new tmp2[256];


	tmp = strtok(cmdtext, idx);
	tmp2 = strtok(cmdtext, idx);

	if(!strlen(tmp))
	{
	SendClientMessage(playerid, 0xAA3333AA ,"Usage: /color [first color ID] [second color ID]");
	}
	else if(!strlen(tmp2))
	{
	ChangeVehicleColor(GetPlayerVehicleID(playerid),strval(tmp),strval(tmp));
	GameTextForPlayer(playerid,"Vehicle color changed",2500,3);
	}
	else if(!IsPlayerInAnyVehicle(playerid))
	{
	SendClientMessage(playerid, 0xAA3333AA ,"You are not in any vehicle!");
	}
	else
	{
	ChangeVehicleColor(GetPlayerVehicleID(playerid),strval(tmp),strval(tmp2));
	GameTextForPlayer(playerid,"Vehicle color changed",2500,3);

	}
	return 1;
I get these erors


Код:
C:\Documents and Settings\Administrator\Desktop\Stunt-server\gamemodes\StuntWorld.pwn(579) : error 017: undefined symbol "strtok"
C:\Documents and Settings\Administrator\Desktop\Stunt-server\gamemodes\StuntWorld.pwn(579) : error 033: array must be indexed (variable "tmp")
C:\Documents and Settings\Administrator\Desktop\Stunt-server\gamemodes\StuntWorld.pwn(580) : error 017: undefined symbol "strtok"
C:\Documents and Settings\Administrator\Desktop\Stunt-server\gamemodes\StuntWorld.pwn(580) : error 033: array must be indexed (variable "tmp2")



Re: Carcolour help - MenaceX^ - 20.08.2009

Change the arrays sizes to 128 from 256, and strtok is here: https://sampwiki.blast.hk/wiki/Strtok


Re: Carcolour help - MB@ - 20.08.2009

I changed

Код:
  if(strcmp(cmdtext, "/carcolour",true) == 0)
	{
	new tmp[128];
	new tmp2[128];
	tmp = strtok(cmdtext, idx);
	tmp2 = strtok(cmdtext, idx);
	if(!strlen(tmp))
	{
	SendClientMessage(playerid, 0xAA3333AA ,"Usage: /color [first color ID] [second color ID]");
	}
	else if(!strlen(tmp2))
	{
	ChangeVehicleColor(GetPlayerVehicleID(playerid),strval(tmp),strval(tmp));
	GameTextForPlayer(playerid,"Vehicle color changed",2500,3);
	}
	else if(!IsPlayerInAnyVehicle(playerid))
	{
	SendClientMessage(playerid, 0xAA3333AA ,"You are not in any vehicle!");
	}
	else
	{
	ChangeVehicleColor(GetPlayerVehicleID(playerid),strval(tmp),strval(tmp2));
	GameTextForPlayer(playerid,"Vehicle color changed",2500,3);
	}
	return 1;
	}
But i still get eror

Код:
C:\Documents and Settings\Administrator\Desktop\Stunt-server\gamemodes\StuntWorld.pwn(572) : warning 225: unreachable code
C:\Documents and Settings\Administrator\Desktop\Stunt-server\gamemodes\StuntWorld.pwn(576) : error 017: undefined symbol "strtok"
C:\Documents and Settings\Administrator\Desktop\Stunt-server\gamemodes\StuntWorld.pwn(576) : error 033: array must be indexed (variable "tmp")
C:\Documents and Settings\Administrator\Desktop\Stunt-server\gamemodes\StuntWorld.pwn(577) : error 017: undefined symbol "strtok"
C:\Documents and Settings\Administrator\Desktop\Stunt-server\gamemodes\StuntWorld.pwn(577) : error 033: array must be indexed (variable "tmp2")
And i realy dont unerstand this
Код:
strtok




Re: Carcolour help - MenaceX^ - 20.08.2009

Just add that stock from the site I gave you, or it's written there as a public, don't remember.
pawn Код:
new cmd[128];
cmd=strtok(cmdtext,idx);
if(!strcmp(cmd,"/carcolour",true))
{
  if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xAA3333AA,"You have to be inside a vehicle.");
  cmd=strtok(cmdtext,idx);
  if(!strlen(cmd)) return SendClientMessage(playerid,0xAA3333AA,"usage: /color [first color] [second color]");
  new color1=strval(cmd);
  cmd=strtok(cmdtext,idx);
  if(!strlen(cmd)) return SendClientMessage(playerid,0xAA3333AA,"usage: /color [first color] [second color]");
  ChangeVehicleColor(GetPlayerVehicleID(playerid),color1,strval(cmd));
  GameTextForPlayer(playerid,"Vehicle color changed",2500,3);
  return 1;
}



Re: Carcolour help - MB@ - 20.08.2009

Ok iknow i'm boring and i cant script but

Код:
{
	new cmd[128];
	cmd = strtok(cmdtext, idx);

	if(strcmp(cmd, "/carcolour" ,true) == 0)
	{

	if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xAA3333AA,"You have to be inside a vehicle.");

	cmd = strtok(cmdtext, idx);

	if(!strlen(cmd)) return SendClientMessage(playerid,0xAA3333AA,"usage: /color [first color] [second color]");

	new color1=strval(cmd);
  cmd = strtok(cmdtext, idx);

	if(!strlen(cmd)) return SendClientMessage(playerid,0xAA3333AA,"usage: /color [first color] [second color]");
  ChangeVehicleColor(GetPlayerVehicleID(playerid),color1,strval(cmd));
  GameTextForPlayer(playerid,"Vehicle color changed",2500,3);
  return 1;
	}
Код:
C:\Documents and Settings\Administrator\Desktop\Stunt-server\gamemodes\StuntWorld.pwn(334) : error 017: undefined symbol "strtok"
C:\Documents and Settings\Administrator\Desktop\Stunt-server\gamemodes\StuntWorld.pwn(334) : error 033: array must be indexed (variable "cmd")
C:\Documents and Settings\Administrator\Desktop\Stunt-server\gamemodes\StuntWorld.pwn(341) : error 017: undefined symbol "strtok"
C:\Documents and Settings\Administrator\Desktop\Stunt-server\gamemodes\StuntWorld.pwn(341) : error 033: array must be indexed (variable "cmd")
C:\Documents and Settings\Administrator\Desktop\Stunt-server\gamemodes\StuntWorld.pwn(346) : error 017: undefined symbol "strtok"
C:\Documents and Settings\Administrator\Desktop\Stunt-server\gamemodes\StuntWorld.pwn(346) : error 033: array must be indexed (variable "cmd")



Re: Carcolour help - MenaceX^ - 20.08.2009

Oh god you gotta be kidding me...
https://sampwiki.blast.hk/wiki/Strtok