SA-MP Forums Archive
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)
+--- Thread: Unknown command? (/showthread.php?tid=544607)

Pages: 1 2


Unknown command? - Gogorakis - 02.11.2014

Hello.
I got this command:
Код:
CMD:makeadmin(playerid, params[])
{
    new targetid, level, string[100];
    if(!IsPlayerAdmin(playerid)||PlayerInfo[playerid][pAdmin] < 7) return SendClientMessage(playerid,0xFF0000FF,"{FF0000}[SERVER]You're not authorized to use that command.");
    if(sscanf(params, "ud", targetid, level)) return SendClientMessage(playerid, COLOR_RED, "{FF0000}[SERVER]Usage: /makeadmin [playerid] [adminlevel]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "{FF0000}[SERVER]{BABABA} Player is not connected!");
    PlayerInfo[targetid][pAdmin] = level;
    format(string, sizeof(string), "{FF0000}[SERVER]{FFFFFF}%s {BABABA}set your {FFFFFF}Admin {BABABA}Level to{FF0000} %d", GetName(playerid), level);
    SendClientMessage(targetid, COLOR_GREEN, string);
    format(string, sizeof(string), "{FF0000}[SERVER]{BABABA}You set {FFFFFF}%s's {FFFFFF}Admin {BABABA}Level to{FF0000} %d", GetName(targetid), level);
    SendClientMessage(playerid, COLOR_GREEN, string);
    return 1;
}
When I type in game /makeadmin it says "SERVER: Unknown command.". Any ideas?


Re: Unknown command? - [HiC]TheKiller - 02.11.2014

Try putting random prints each line and see if it puts anything into the console:

pawn Код:
CMD:makeadmin(playerid, params[])
{
    new targetid, level, string[100];
    print("A");
    if(!IsPlayerAdmin(playerid)||PlayerInfo[playerid][pAdmin] < 7) return SendClientMessage(playerid,0xFF0000FF,"{FF0000}[SERVER]You're not authorized to use that command.");
    print("B");
    if(sscanf(params, "ud", targetid, level)) return SendClientMessage(playerid, COLOR_RED, "{FF0000}[SERVER]Usage: /makeadmin [playerid] [adminlevel]");
    print("C");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "{FF0000}[SERVER]{BABABA} Player is not connected!");
    print("D");
    PlayerInfo[targetid][pAdmin] = level;
    print("E");
    format(string, sizeof(string), "{FF0000}[SERVER]{FFFFFF}%s {BABABA}set your {FFFFFF}Admin {BABABA}Level to{FF0000} %d", GetName(playerid), level);
    print("F");
    SendClientMessage(targetid, COLOR_GREEN, string);
    print("G");
    format(string, sizeof(string), "{FF0000}[SERVER]{BABABA}You set {FFFFFF}%s's {FFFFFF}Admin {BABABA}Level to{FF0000} %d", GetName(targetid), level);
    print("H");
    SendClientMessage(playerid, COLOR_GREEN, string);
    return 1;
}
See what letter it gets up to if any.


Re: Unknown command? - Gogorakis - 02.11.2014

Quote:
Originally Posted by [HiC]TheKiller
Посмотреть сообщение
Try putting random prints each line and see if it puts anything into the console:

pawn Код:
CMD:makeadmin(playerid, params[])
{
    new targetid, level, string[100];
    print("A");
    if(!IsPlayerAdmin(playerid)||PlayerInfo[playerid][pAdmin] < 7) return SendClientMessage(playerid,0xFF0000FF,"{FF0000}[SERVER]You're not authorized to use that command.");
    print("B");
    if(sscanf(params, "ud", targetid, level)) return SendClientMessage(playerid, COLOR_RED, "{FF0000}[SERVER]Usage: /makeadmin [playerid] [adminlevel]");
    print("C");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "{FF0000}[SERVER]{BABABA} Player is not connected!");
    print("D");
    PlayerInfo[targetid][pAdmin] = level;
    print("E");
    format(string, sizeof(string), "{FF0000}[SERVER]{FFFFFF}%s {BABABA}set your {FFFFFF}Admin {BABABA}Level to{FF0000} %d", GetName(playerid), level);
    print("F");
    SendClientMessage(targetid, COLOR_GREEN, string);
    print("G");
    format(string, sizeof(string), "{FF0000}[SERVER]{BABABA}You set {FFFFFF}%s's {FFFFFF}Admin {BABABA}Level to{FF0000} %d", GetName(targetid), level);
    print("H");
    SendClientMessage(playerid, COLOR_GREEN, string);
    return 1;
}
See what letter it gets up to if any.
When I type /makeadmin it doesn't print anything to the console..


Re: Unknown command? - Gogeta - 02.11.2014

Make sure you installed ZCMD also your script seems okay.


Re: Unknown command? - Gogorakis - 02.11.2014

Commands like this, work:

Код:
CMD:god(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid,0xFF0000FF,"{FF0000}[SERVER]{BABABA}You're not authorized to use that command.");
	SetPlayerHealth(playerid, 100000);
	return 1;
}



Re: Unknown command? - [HiC]TheKiller - 02.11.2014

Do you happen to have makeadmin in any other scripts of yours?


Re: Unknown command? - Gogorakis - 02.11.2014

I don't get it?


Re: Unknown command? - Gogorakis - 02.11.2014

Btw, simple commands like this, don't work:

Код:
COMMAND:kill(playerid, params[])
{
	SetPlayerHealth(playerid, 0.0);
	return 1;
}



Re: Unknown command? - [HiC]TheKiller - 02.11.2014

Interesting, do you happen to have OnPlayerCommandText within your script as well?


Re: Unknown command? - Gogorakis - 02.11.2014

Yes I do..

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/mycommand", cmdtext, true, 10) == 0)
	{
		// Do something here
		return 1;
	}
	return SendClientMessage(playerid, 0xFF0000,"{BABABA}Invalid Command: Type /help for more information.");
}
**Ignore this:
Quote:

return SendClientMessage(playerid, 0xFF0000,"{BABABA}Invalid Command: Type /help for more information.");

Btw, I don't think that it cause that error because commands like:
Код:
COMMAND:god(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid,0xFF0000FF,"{FF0000}[SERVER]{BABABA}You're not authorized to use that command.");
	SetPlayerHealth(playerid, 100000);
	return 1;
}
, work.


Re: Unknown command? - [HiC]TheKiller - 02.11.2014

Do some commands happen to be above OnPlayerCommandText and some below OnPlayerCommandText? Try removing OnPlayerCommandText and trying again.


Re: Unknown command? - Gogorakis - 02.11.2014

Quote:
Originally Posted by [HiC]TheKiller
Посмотреть сообщение
Do some commands happen to be above OnPlayerCommandText and some below OnPlayerCommandText? Try removing OnPlayerCommandText and trying again.
Same..


Re: Unknown command? - M0HAMMAD - 02.11.2014

Change
pawn Код:
if(sscanf(params, "ud", targetid, level))
To
pawn Код:
if(sscanf(params, "ui", targetid, level))



Re: Unknown command? - Gogorakis - 02.11.2014

Quote:
Originally Posted by M0HAMMAD
Посмотреть сообщение
Change
pawn Код:
if(sscanf(params, "ud", targetid, level))
To
pawn Код:
if(sscanf(params, "ui", targetid, level))
I don't think that this cause it..Look the comments..There are also commands like: /kill which don't work.

Код:
COMMAND:kill(playerid, params[])
{
	SetPlayerHealth(playerid, 0.0);
	return 1;
}



Re: Unknown command? - DanishHaq - 02.11.2014

Quote:
Originally Posted by M0HAMMAD
Посмотреть сообщение
Change
pawn Код:
if(sscanf(params, "ud", targetid, level))
To
pawn Код:
if(sscanf(params, "ui", targetid, level))
That won't make any difference.

Are you sure you've not got the command makeadmin in other filterscripts or your gamemode? Maybe that's what's causing the problem. Try this, rescripted:

pawn Код:
CMD:makeadmin(playerid, params[])
{
    if(!IsPlayerAdmin(playerid) && PlayerInfo[playerid][pAdmin] < 7) return SendClientMessage(playerid, 0xFF0000FF, "{FF0000}[SERVER]You're not authorized to use that command.");
    new targetid, level;
    if(sscanf(params, "ui", targetid, level)) return SendClientMessage(playerid, COLOR_WHITE, "{FF0000}[SERVER]Usage /makeadmin [playerid] [adminlevel]");
    if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_WHITE, "{FF0000}[SERVER]{BABABA} Player is not connected!");
    PlayerInfo[targetid][pAdmin] = level;
    new string[150];
    format(string, sizeof(string), "{FF0000}[SERVER]{FFFFFF}%s {BABABA}set your {FFFFFF}Admin {BABABA}Level to {FF0000}%d", GetName(playerid), level);
    SendClientMessage(targetid, COLOR_GREEN, string);
    format(string, sizeof(string), "{FF0000}[SERVER]{BABABA}You set {FFFFFF}%s's Admin {BABABA}Level to {FF0000}%d", GetName(targetid), level);
    SendClientMessage(playerid, COLOR_GREEN, string);
    return 1;
}



Re: Unknown command? - Gogorakis - 02.11.2014

I told you guys..
Commands which don't work:
/pm, /dnd, /reply, /stopradio, /radio, /kill, /godoff, /clearchat, /makeadmin

Commands which work: /makevip, /god, /ct, /hey, /youidiot (lol;p), /never, /punk, /stats, /vipmenu, /stopmaps, /gotopos, /jetpack

Example of commands which don't work:
(/kill)
Код:
COMMAND:kill(playerid, params[])
{
	SetPlayerHealth(playerid, 0.0);
	return 1;
}
Example of commands which work:
(/god)
Код:
COMMAND:god(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid,0xFF0000FF,"{FF0000}[SERVER]{BABABA}You're not authorized to use that command.");
	SetPlayerHealth(playerid, 100000);
	return 1;
}
It's simple. Some commands work and some others don't.


Re: Unknown command? - [HiC]TheKiller - 02.11.2014

Try changing the name of the command from makeadmin to makeadmintest or something. See if it works.


Re: Unknown command? - Gogorakis - 02.11.2014

Quote:
Originally Posted by [HiC]TheKiller
Посмотреть сообщение
Try changing the name of the command from makeadmin to makeadmintest or something. See if it works.
I made some new commands and the same happens. Btw, I don't think that it makes sense..?


Re: Unknown command? - Alex Magaсa - 02.11.2014

Hmm have you tried recompiling + updating includes?
On the top of script what's your include definitions.


Re: Unknown command? - Beckett - 03.11.2014

You have a filterscript that uses strcmp.

Quote:
Originally Posted by [HiC]TheKiller
Посмотреть сообщение
Try changing the name of the command from makeadmin to makeadmintest or something. See if it works.
. . . .