SA-MP Forums Archive
Commands to extra parameters return 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: Commands to extra parameters return Unknown Command (/showthread.php?tid=197173)



Commands to extra parameters return Unknown Command - admantis - 08.12.2010

Hello everybody, all commands I have like /ban [id], /slap [id], /givemoney [id], /makeadmin [id], etc.. when I type /makeadmin or any other command without the extra parameter (ID) it returns the correct usage, but If I type the ID it says 'SERVER: Unknown command'

This is the main template for the commands (for admins) that have extra parameters.
pawn Код:
if(strcmp(cmdtext, "/command", true)==0)
    {
        new tmp[256];
        tmp = strtok( cmdtext, idx );
        if (!strlen(tmp))
        {
            return SendClientMessage(playerid,COLOR_GRAY,"[SERVER]: /usage");
        }
        if(PlayerInfo[playerid][pAdminLevel] == 2)
        {
            return 1;
        }
        else SendClientMessage(playerid,COLOR_GRAY,"[SERVER]: You are not an admin !");
        if(strval(tmp) == playerid) SendClientMessage(playerid,COLOR_RED,"[ERROR] You cannot do this on yourself!");
        if(strval(tmp) == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"[ERROR]: Invalid ID.");
        return 1;
    }
Now a 'full command'
pawn Код:
if(strcmp(cmdtext, "/makegolden", true)==0)
    {
        new tmp[256];
        tmp = strtok( cmdtext, idx );
        if (!strlen(tmp))
        {
            return SendClientMessage(playerid,COLOR_GRAY,"[SERVER]: /makegolden");
        }
        if(PlayerInfo[playerid][pAdminLevel] == 2)
        {
            new string[50], string2[50], adminname[MAX_PLAYER_NAME], givename[MAX_PLAYER_NAME];
            GetPlayerName(playerid, adminname, sizeof(adminname));
            GetPlayerName(playerid, givename, sizeof(givename));
            format(string, sizeof(string), " Administrator %s has made you a Golden User. Thanks for donating!", adminname);
            format(string2, sizeof(string2), " You have made %s a Golden User.", givename);
            SendClientMessage(playerid,COLOR_YELLOW,string2);
            SendClientMessage(strval(tmp),COLOR_YELLOW,string);
            PlayerInfo[strval(tmp)][pIsGolden] = 1;
            return 1;
        }
        else SendClientMessage(playerid,COLOR_GRAY,"[SERVER]: You are not an admin !");
        if(strval(tmp) == playerid) SendClientMessage(playerid,COLOR_RED,"[ERROR] You cannot do this on yourself!");
        if(strval(tmp) == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"[ERROR]: Invalid ID.");
        return 1;
    }
Help is really appreciated.
P.S: I know I use 256 cells in a small var, dont remind it to me.


Re: Commands to extra parameters return Unknown Command - Mehtab - 08.12.2010

you can use xtreme admin filterscript. by the way if you don't know then come to my server 123.200.18.200. i will explain you


Re: Commands to extra parameters return Unknown Command - admantis - 08.12.2010

i dont know... i dont have SA-MP or San Andreas in this PC, and I dont want filterscripts at all.. Just fix the only command above and i'll fix every other command by myself.


Re: Commands to extra parameters return Unknown Command - Mehtab - 08.12.2010

That's my command. edit it. i dnt think this will work


Код:
if(strcmp(cmd, "/setadminlevel", true) == 0 || strcmp(cmd, "/sal", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /[s]et[a]dmin[l]evel [playerid/PartOfName] [level(1-1338)]");
				return 1;
			}
			new para1;
			new level;
			new playerlevel;
			para1 = ReturnUser(tmp);
			tmp = strtok(cmdtext, idx);
			level = strval(tmp);
			playerlevel = PlayerInfo[para1][pAdmin];
			if(PlayerInfo[playerid][pAdmin] >= 1337 || IsPlayerAdmin(playerid))
			{
			    if(IsPlayerConnected(para1))
			    {
			        if(para1 != INVALID_PLAYER_ID)
			        {
 						if(level == playerlevel)
						{
							SendClientMessage(playerid, COLOR_GREY, "** Player is already that level");
							return 1;
						}
						if(level >= 7 && level <= 1336) return SendClientMessage(playerid, COLOR_GREY,"* Only levels 0-6 and 1337-1338 Are allowed!");
						if(level < 0 || level > 1338) return SendClientMessage(playerid, COLOR_GREY,"* Only levels 0-6 and 1337-1338 Are allowed!");
						if(level > 4 && PlayerInfo[playerid][pAdmin] == 1337) return SendClientMessage(playerid, COLOR_GREY, "You can only promote admins to lvl 4 or below");
						if(playerlevel >= 5 && PlayerInfo[playerid][pAdmin] == 1337) return SendClientMessage(playerid, COLOR_GREY, "You can not demote Main Administrators or Above.");
						GetPlayerName(para1, giveplayer, sizeof(giveplayer));
						new Float:X, Float:Y, Float:Z;
						GetPlayerPos(para1, X,Y,Z);
						format(string, sizeof(string),"[ADMIN]: %s has set %s (%d)'s Level to: [%d]", sendername, giveplayer, para1, level);
						ABroadCast(COLOR_LIGHTRED, string, 5);
						format(string, sizeof(string), "** %s Gave You Admin Level: %d",sendername, level);
						SendClientMessage(para1, TEAM_GROVE_COLOR, string);
						if(level > PlayerInfo[para1][pAdmin])
						{
							format(string, sizeof(string), "Congratulations to %s. He is now Level: %d Admin !!!!",giveplayer, level);
							SendClientMessageToAll(COLOR_LIGHTBLUE, string);
                            PlayerPlaySound(para1, 1056, X, Y, Z);
                            GameTextForPlayer(para1, "~y~Promoted!",7500,3);
                            format(string, sizeof(string), "** You have promoted %s (%d) to level %d.", giveplayer, para1, level);
							SendClientMessage(playerid, COLOR_LIGHTRED, string);
							PlayerInfo[para1][pAdmin] = level;
							PlayerInfo[para1][pHelper] = 3;
							if(playerlevel == 0 && level >= 1)
							{
							    admins ++;
							}
						}
						else
						{
                            PlayerPlaySound(para1, 1055, X, Y, Z);
                            GameTextForPlayer(para1, "~r~Demoted!",7500,3);
                            format(string, sizeof(string), "** You have demoted %s (%d) to admin level %d.", giveplayer, para1, level);
							SendClientMessage(playerid, COLOR_LIGHTRED, string);
							PlayerInfo[para1][pAdmin] = level;
       						if(level == 0)
							{
								PlayerInfo[para1][pHelper] = 1;
								admins --;
							}
						}
						new y, m, d;
						new h,mi,s;
						getdate(y,m,d);
						gettime(h,mi,s);
						format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s Gave to %s Admin Level: [%d].",d,m,y,h,mi,s,sendername,giveplayer,level);
						AdminLog(string);
						ChatLog(string);
						LoginLog(string);
					}
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD1, "   you are not authorized to use that command!");
				return 1;
			}
		}
		return 1;
	}



Re: Commands to extra parameters return Unknown Command - admantis - 08.12.2010

I'm sorry to waste your time, but can you just edit the /makegolden command above and that's all? Dont change the string names, just fix it so it wont return Unknown Command always.

maybe I'm being a bit assy, but It's really urgent I need it.


Re: Commands to extra parameters return Unknown Command - Mean - 08.12.2010

I kno you said we don't remind you, but, you use 256 cells in a that small var, you are gonna get this warning MSG:

Код:
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase

Header size:           6332 bytes
Code size:           403896 bytes
Data size:           179436 bytes
Stack/heap size:       2000 bytes; estimated max. usage=578 cells (2312 bytes)
Total requirements:  591664 bytes
or something like that