SA-MP Forums Archive
2 Commands returning "SERVER: Unknown command" - 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: 2 Commands returning "SERVER: Unknown command" (/showthread.php?tid=119367)



2 Commands returning "SERVER: Unknown command" - _Vortex - 08.01.2010

Now before we get started, the commands are returning 1.

I'm trying to make an invisible command (saw a discussuion on another topic a wile back that returning 0 under OnPlayerUpdate will desync you, basically making you invisible.) But when I try to enter the commands they return "SERVER: Unknown command."

Here's the codes..

Код:
dcmd_invisible(playerid, cmdtext[])
{
	#pragma unused cmdtext
	if(pInfo[playerid][Level] < 2) return SendClientMessage(playerid,COLOR_RED,"ERROR: You must be level 2 to become invisible");
	SetPlayerPos(playerid,0.00,0.00,0.00);
	Invisible[playerid] = 1;
	SendClientMessage(playerid,COLOR_LIGHTGREEN,"You are now invisible");
	return 1;
}

dcmd_invisibleoff(playerid, cmdtext[])
{
	#pragma unused cmdtext
	if(pInfo[playerid][Level] < 2) return SendClientMessage(playerid,COLOR_RED,"ERROR: You're not invisible!");
	if(Invisible[playerid] == 0) return SendClientMessage(playerid,COLOR_RED,"ERROR: You're not invisible!");
	Invisible[playerid] = 0;
	SendClientMessage(playerid,COLOR_LIGHTGREEN,"You are now visible!");
	return 1;
public OnPlayerUpdate(playerid)
{
	if(GetPlayerPing(playerid) >= 750)
	{
	[...]
	}
	if(GetPlayerWeapon(playerid) == 38)
	{
	[...]
	}
	if(Invisible[playerid])return 0;
	return 1;
}
}



Re: 2 Commands returning "SERVER: Unknown command" - [HiC]TheKiller - 08.01.2010

pawn Код:
dcmd_invisible(playerid, cmdtext[])
Should be

pawn Код:
dcmd_invisible(playerid, params[])
And do you have it defined under OnPlayerCommandText?



Re: 2 Commands returning "SERVER: Unknown command" - _Vortex - 08.01.2010

Quote:
Originally Posted by [HiC
TheKiller ]
pawn Код:
dcmd_invisible(playerid, cmdtext[])
Should be

pawn Код:
dcmd_invisible(playerid, params[])
And do you have it defined under OnPlayerCommandText?
I have tons of other commands that have cmdtext[] instead of params[], and of course I have it defined under OnPlayerCommandText.


Re: 2 Commands returning "SERVER: Unknown command" - KnooL - 08.01.2010

return 0; makes them say that.


Re: 2 Commands returning "SERVER: Unknown command" - Miguel - 08.01.2010

Quote:
Originally Posted by _Vortex
pawn Код:
if(pInfo[playerid][Level] < 2) return SendClientMessage(playerid,COLOR_RED,"ERROR: You're not invisible!");
I don't see the point of returning that message...


pawn Код:
if(Invisible[playerid])return 0;
return 1;
Is that right?

I would've done something like this:

pawn Код:
// invisible == 0
// not invisible == 1

OnPlayerUpdate(playerid)
{
  return invisible; // would return 1 is he's not and 0 if he is.
}
But I'm not sure if that works...


Re: 2 Commands returning "SERVER: Unknown command" - Deat_Itself - 08.01.2010

Код:
dcmd_invisible(playerid, cmdtext[])
{
	#pragma unused cmdtext
	if(pInfo[playerid][Level] < 2) return SendClientMessage(playerid,COLOR_RED,"ERROR: You must be level 2 to become invisible");
    else
	SetPlayerPos(playerid,0.00,0.00,0.00);
	Invisible[playerid] = 1;
	SendClientMessage(playerid,COLOR_LIGHTGREEN,"You are now invisible");
	return 1;
}

dcmd_invisibleoff(playerid, cmdtext[])
{
	#pragma unused cmdtext
	if(pInfo[playerid][Level] < 2) return SendClientMessage(playerid,COLOR_RED,"ERROR: You're not invisible!");
    else
	if(Invisible[playerid] == 0) return SendClientMessage(playerid,COLOR_RED,"ERROR: You're not invisible!");
    else
	Invisible[playerid] = 0;
	SendClientMessage(playerid,COLOR_LIGHTGREEN,"You are now visible!");
	return 1;
public OnPlayerUpdate(playerid)
{
	if(GetPlayerPing(playerid) >= 750)
	{
	[...]
	}
	if(GetPlayerWeapon(playerid) == 38)
	{
	[...]
	}
	if(Invisible[playerid])return 0;
	return 1;
}
}
thats the right code


Re: 2 Commands returning "SERVER: Unknown command" - _Vortex - 08.01.2010

Quote:
Originally Posted by _Saif_
Код:
dcmd_invisible(playerid, cmdtext[])
{
	#pragma unused cmdtext
	if(pInfo[playerid][Level] < 2) return SendClientMessage(playerid,COLOR_RED,"ERROR: You must be level 2 to become invisible");
    else
	SetPlayerPos(playerid,0.00,0.00,0.00);
	Invisible[playerid] = 1;
	SendClientMessage(playerid,COLOR_LIGHTGREEN,"You are now invisible");
	return 1;
}

dcmd_invisibleoff(playerid, cmdtext[])
{
	#pragma unused cmdtext
	if(pInfo[playerid][Level] < 2) return SendClientMessage(playerid,COLOR_RED,"ERROR: You're not invisible!");
    else
	if(Invisible[playerid] == 0) return SendClientMessage(playerid,COLOR_RED,"ERROR: You're not invisible!");
    else
	Invisible[playerid] = 0;
	SendClientMessage(playerid,COLOR_LIGHTGREEN,"You are now visible!");
	return 1;
public OnPlayerUpdate(playerid)
{
	if(GetPlayerPing(playerid) >= 750)
	{
	[...]
	}
	if(GetPlayerWeapon(playerid) == 38)
	{
	[...]
	}
	if(Invisible[playerid])return 0;
	return 1;
}
}
thats the right code
Same problem "else" isn't needed. I have all my other commands like that and there's no problem.