2 Commands returning "SERVER: Unknown command"
#1

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

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

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

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

return 0; makes them say that.
Reply
#5

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

Код:
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
Reply
#7

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


Forum Jump:


Users browsing this thread: 2 Guest(s)