My /local dosn't work
#1

I just get two errors when i try to add /b.

Here is the script.

Код:
	if(!strcmp(cmdtext, "/b", true))
	{
	  if(GetDistanceBetweenPlayers(playerid, i) <= 20)
	  {
	    if(cmdtext[2] == 32 || cmdtext[3] != EOS)
	    {
	      new str[128];
	      format(str, 128, "%s: %s", Name(playerid), cmdtext[3]);
	      SendClientMessage(i, COLOR_WHITE, str);
			}
		}
	}
	return true;
}
And at the bottom of the script:

Код:
Name(i)
{
  new n[24];
  GetPlayerName(i, n, 24);
  return n;
}
The errors:

error 017: undefined symbol "GetDistanceBetweenPlayers"
error 017: undefined symbol "i"






Reply
#2

It's better if you use 'playerid' instead of 'i' here:
pawn Код:
Name(playerid)
{
new n[24];
GetPlayerName(playerid, n, 24);
return n;
}
This is correct:
pawn Код:
if(!strcmp(cmdtext, "/b", true))
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(GetDistanceBetweenPlayers(playerid, i) <= 20)
{
if(cmdtext[2] == 32 || cmdtext[3] != EOS)
{
new str[128];
format(str, 128, "%s: %s", Name(playerid), cmdtext[3]);
SendClientMessage(i, COLOR_WHITE, str);
}
}
}
return true;
}
And you also need 'GetDistanceBetweenPlayers' function. Search in scripting-boards for it.
Reply
#3

Quote:
Originally Posted by Don Correlli
It's better if you use 'playerid' instead of 'i' here:
pawn Код:
Name(playerid)
{
new n[24];
GetPlayerName(playerid, n, 24);
return n;
}
This is correct:
pawn Код:
if(!strcmp(cmdtext, "/b", true))
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(GetDistanceBetweenPlayers(playerid, i) <= 20)
{
if(cmdtext[2] == 32 || cmdtext[3] != EOS)
{
new str[128];
format(str, 128, "%s: %s", Name(playerid), cmdtext[3]);
SendClientMessage(i, COLOR_WHITE, str);
}
}
}
return true;
}
And you also need 'GetDistanceBetweenPlayers' function. Search in scripting-boards for it.
Cant find the GetDistanceBetweenPlayers function... do you?
Reply
#4

pawn Код:
stock GetDistanceBetweenPlayers(playerid, playerid2)
{
new Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2;
new Float:tmpdis;
GetPlayerPos(playerid, x1, y1, z1);
GetPlayerPos(playerid2, x2, y2, z2);
tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2, x1)), 2)
+ floatpower(floatabs(floatsub(y2, y1)), 2)
+ floatpower(floatabs(floatsub(z2, z1)), 2));
return floatround(tmpdis);
}
Reply
#5

Now all errors disapeard, but it gives me a warning and /b dosn't work.

warning 202: number of arguments does not match definition



Reply
#6

Quote:
Originally Posted by FreddeN
Now all errors disapeard, but it gives me a warning and /b dosn't work.

warning 202: number of arguments does not match definition
pawn Код:
if (strcmp("/b", cmdtext, true, 10) == 0)
Instead of yours.
Reply
#7

Quote:
Originally Posted by Klutty
Quote:
Originally Posted by FreddeN
Now all errors disapeard, but it gives me a warning and /b dosn't work.

warning 202: number of arguments does not match definition
pawn Код:
if (strcmp("/b", cmdtext, true, 10) == 0)
Instead of yours.
Sorry, it just says "SERVER: Unknown command" and still gives the warning...
Reply
#8

pawn Код:
if(!strcmp(cmdtext, "/b", true, 10) == 0)
This?
Reply
#9

Quote:
Originally Posted by Klutty
pawn Код:
if(!strcmp(cmdtext, "/b", true, 10) == 0)
This?
Now it gives me two warnings and is still dont work

warning 213: tag mismatch
warning 202: number of arguments does not match definition

Here is my script, look through it.

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/kill", cmdtext, true, 10) == 0)
	{
		SetPlayerHealth(playerid,0.0);
		return 1;
	}
	
	if(!strcmp(cmdtext, "/ooc", true, 3))
	{
		new str[256], pname[256];
		GetPlayerName(playerid, pname, 256);
		format(str, 256, "(( Ooc: %s:%s ))", pname, cmdtext[4]);
		SendClientMessageToAll(0xFFFFFFAA, str);
 		return 1;
	}

  if(!strcmp(cmdtext, "/b", true, 10) == 0)
	{
	  for(new i = 0; i < MAX_PLAYERS; i++)
	  {
	  	if(GetDistanceBetweenPlayers(playerid) <= 20)
	  	{
	    	if(cmdtext[2] == 32 || cmdtext[3] != EOS)
	    	{
	      	new str[128];
	      	format(str, 128, "%s: %s", Name(playerid), cmdtext[3]);
	      	SendClientMessage(playerid, 0xFFFFFFAA, str);
				}
			}
		}
	}
	return true;
}

public OnPlayerInfoChange(playerid)
{
	return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
	return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
	return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
	return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
	return 1;
}

public OnRconCommand(cmd[])
{
	return 1;
}

public OnObjectMoved(objectid)
{
	return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
	return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
	return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
	return 1;
}

public OnPlayerExitedMenu(playerid)
{
	return 1;
}

Name(playerid)
{
  new n[24];
  GetPlayerName(playerid, n, 24);
  return n;
}

stock GetDistanceBetweenPlayers(playerid, playerid2)
{
new Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2;
new Float:tmpdis;
GetPlayerPos(playerid, x1, y1, z1);
GetPlayerPos(playerid2, x2, y2, z2);
tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2, x1)), 2)
+ floatpower(floatabs(floatsub(y2, y1)), 2)
+ floatpower(floatabs(floatsub(z2, z1)), 2));
return floatround(tmpdis);
}
Reply
#10

pawn Код:
if(GetDistanceBetweenPlayers(playerid,i) <= 20)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)