SA-MP Forums Archive
(Question) 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: (Question) Unknown Command (/showthread.php?tid=148632)



(Question) Unknown Command - Almighty Socrates - 18.05.2010

Hello guys, I'm new in here and also in the scripting world and I really like to learn, could someone tell me what's wrong with this script please, thanks a lot.

Depositing command,

Код:
if(strcmp(cmdtext,"/deposit",true) == 0)
    {
        new ammount;
        tmp = strtok(cmdtext,idx);
        if(banklogged[playerid] == 0)
        	{
					SendClientMessage(playerid,0xF5DEB3FF,"You are not logged in on your bank account!");
					return 1;
   			}
        if(!strlen(tmp))
        	{
        		SendClientMessage(playerid,0xFF0000FF,"USAGE: /deposit (ammount)");
					return 1;
   			}
        ammount = strval(tmp);
        new currentm = GetPlayerMoney(playerid);
        if(currentm <= ammount)
        	{
        	SendClientMessage(playerid,0xF5DEB3FF,"You cannot deposit more money than you have!");
					return 1;
  				}
        if(PlayerToPoint(3,playerid,2308.7920,-13.5103,26.7422))
        	{
        	bankmoney[playerid] += ammount;
         	format(string, sizeof(string),"You have deposited $%d.00 to your bank account.",ammount);
         	SendClientMessage(playerid,0xF5DEB3FF,string);
          	GivePlayerMoney(playerid,-ammount);
          return 1;
        	}
        else
        	{
        	SendClientMessage(playerid,0xF5DEB3FF,"You are not at the Bank!");
					return 1;
   			}
    }
Withdrawal command,

Код:
if(strcmp(cmdtext,"/withdraw",true) == 0)
    {
        new wammount;
        tmp = strtok(cmdtext,idx);
        if(banklogged[playerid] == 0)
        {
        	SendClientMessage(playerid,0xF5DEB3FF,"You are not logged in into your bank account!");
					return 1;
        }
        if(!strlen(tmp))
        {
        	SendClientMessage(playerid,0xFF0000FF,"USAGE: /withdraw (ammount)");
					return 1;
        }
        wammount = strval(tmp);
        new bank = bankmoney[playerid];
        if(bank <= wammount-1)
        {
        	SendClientMessage(playerid,0xF5DEB3FF,"You cannot withdraw more money than you have!");
					return 1;
        }
        if(PlayerToPoint(3,playerid,2308.7920,-13.5103,26.7422))
        {
        	bankmoney[playerid] -= wammount;
         	format(string,sizeof(string),"You have withdrawed $%d.00 from your bank account.",wammount);
         	SendClientMessage(playerid,0xF5DEB3FF,string);
          	GivePlayerMoney(playerid,wammount);
          return 1;
        }
        else
        {
          SendClientMessage(playerid,0xF5DEB3FF,"You are not in the bank!");
					return 1;
				}
It's only part of the script, well when I play it in game, everything goes well, except when I type /withdraw 100, it keeps saying SERVER: Unknown command. But when I only type /withdraw, it works well saying USAGE: /withdraw (ammount). Goes the same with /deposit.

Код:
C:\Documents and Settings\Super Dude\Desktop\bonecounty.pwn(129) : warning 204: symbol is assigned a value that is never used: "pincode"
C:\Documents and Settings\Super Dude\Desktop\bonecounty.pwn(158) : warning 204: symbol is assigned a value that is never used: "pincode"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Warnings.



Re: (Question) Unknown Command - aircombat - 18.05.2010

you should have a return 1; at the end of ur command
Код:
if(strcmp(cmdtext,"/deposit",true) == 0)
    {
        new ammount;
        tmp = strtok(cmdtext,idx);
        if(banklogged[playerid] == 0)
        	{
					SendClientMessage(playerid,0xF5DEB3FF,"You are not logged in on your bank account!");
					return 1;
   			}
        if(!strlen(tmp))
        	{
        		SendClientMessage(playerid,0xFF0000FF,"USAGE: /deposit (ammount)");
					return 1;
   			}
        ammount = strval(tmp);
        new currentm = GetPlayerMoney(playerid);
        if(currentm <= ammount)
        	{
        	SendClientMessage(playerid,0xF5DEB3FF,"You cannot deposit more money than you have!");
					return 1;
  				}
        if(PlayerToPoint(3,playerid,2308.7920,-13.5103,26.7422))
        	{
        	bankmoney[playerid] += ammount;
         	format(string, sizeof(string),"You have deposited $%d.00 to your bank account.",ammount);
         	SendClientMessage(playerid,0xF5DEB3FF,string);
          	GivePlayerMoney(playerid,-ammount);
          return 1;
        	}
        else
        	{
        	SendClientMessage(playerid,0xF5DEB3FF,"You are not at the Bank!");
					return 1;
   			}
     return 1;
    }



Re: (Question) Unknown Command - Almighty Socrates - 18.05.2010

Yes sir, I have it. This is the whole script.

Код:
#include <a_samp>
#include <dini>
#include <dudb>
new pname[MAX_PLAYER_NAME];
new banklogged[MAX_PLAYERS];
new bankmoney[MAX_PLAYERS];

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print(" Blank Filterscript by your name here");
	print("--------------------------------------\n");
	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

#else

main()
{
	print("\n----------------------------------");
	print(" Blank Gamemode by your name here");
	print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
  DisableInteriorEnterExits();
	CreatePickup(1239,1,-217.7988,979.1361,19.5038); // Department
	CreatePickup(1239,1,246.7975,62.8494,1003.6406);
	CreatePickup(1239,1,254.0610,73.9032,1003.6406);
	CreatePickup(1239,1,-181.1324,1034.7759,19.7422); // Supermarket
	CreatePickup(1239,1,-26.7067,-57.9067,1003.5469);
	CreatePickup(1239,1,-179.6478,1133.1523,19.7422); // Bank
 	CreatePickup(1239,1,2305.2908,-16.1280,26.7422);
 	CreatePickup(1239,1,2308.7920,-13.5103,26.7422);
 	CreatePickup(1239,1,-318.7509,1048.5924,20.3403); // Hospital
	AddPlayerClass(161,-207.5484,1119.1932,20.4297,272.3628,0,0,0,0,0,0); // Civilian
	AddPlayerClass(198,-207.5484,1119.1932,20.4297,272.3628,0,0,0,0,0,0);
	AddPlayerClass(128,-207.5484,1119.1932,20.4297,272.3628,0,0,0,0,0,0);
	AddPlayerClass(131,-207.5484,1119.1932,20.4297,272.3628,0,0,0,0,0,0);
	AddPlayerClass(202,-207.5484,1119.1932,20.4297,272.3628,0,0,0,0,0,0);
	AddPlayerClass(201,-207.5484,1119.1932,20.4297,272.3628,0,0,0,0,0,0);
	AddPlayerClass(159,-207.5484,1119.1932,20.4297,272.3628,0,0,0,0,0,0);
	AddPlayerClass(157,-207.5484,1119.1932,20.4297,272.3628,0,0,0,0,0,0);
	return 1;
}

public OnGameModeExit()
{
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
	SetPlayerInterior(playerid,0);
	SetPlayerFacingAngle(playerid,92.3628);
	SetPlayerPos(playerid,1544.2264,-1631.9332,13.3828);
	SetPlayerCameraPos(playerid,1539.9740,-1632.0128,13.3828);
	SetPlayerCameraLookAt(playerid,1544.2264,-1631.9332,13.3828);
	return 1;
}

public OnPlayerConnect(playerid)
{
  SetPlayerMapIcon(playerid,1,-217.7988,979.1361,19.5038,30,0); // Department
  SetPlayerMapIcon(playerid,2,-179.6478,1133.1523,19.7422,52,0); // Bank
  SetPlayerMapIcon(playerid,3,-318.7509,1048.5924,20.3403,22,0); // Hospital
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
  dini_IntSet(udb_encode(pname),"bankmoney",bankmoney[playerid]);
	return 1;
}

public OnPlayerSpawn(playerid)
{
  SetPlayerSkillLevel(playerid,WEAPONSKILL_PISTOL,0);
	SetPlayerSkillLevel(playerid,WEAPONSKILL_MICRO_UZI,0);
	GivePlayerMoney(playerid,350);
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	return 1;
}

public OnVehicleSpawn(vehicleid)
{
	return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
	return 1;
}

public OnPlayerText(playerid, text[])
{
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
  new cmd[256],idx,tmp[265],tmp2[256];
  cmd = strtok(cmdtext,idx);
  GetPlayerName(playerid,pname,sizeof(pname));
  new string[128];
	if (strcmp("/createaccount",cmdtext,true,10) == 0)
    {
        new pincode;
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp))
        {
        	SendClientMessage(playerid,0xFF0000FF,"USAGE: /createaccount (pincode)");
        	return 1;
        }
        pincode = strval(tmp);
    		if (!dini_Exists(udb_encode(pname)))
    		{
        	dini_Create(udb_encode(pname));
        	dini_IntSet(udb_encode(pname),"pincode",udb_hash(tmp));
        	dini_IntSet(udb_encode(pname),"bankmoney",0);
        	SendClientMessage(playerid,0xF5DEB3FF,"You have created a new bank account! You can now log in.");
        	return 1;
        }
        else
        {
        	SendClientMessage(playerid,0xF5DEB3FF,"You already have a bank account!");
        	return 1;
        }
		}
	if (strcmp("/loginaccount",cmdtext,true,10) == 0)
    {
        new pincode;
        tmp = strtok(cmdtext,idx);
        if(banklogged[playerid] == 1)
        {
        	SendClientMessage(playerid,0xF5DEB3FF,"You are already logged in!");
					return 1;
        }
        if(!strlen(tmp))
        {
        	SendClientMessage(playerid,0xFF0000FF,"USAGE: /loginaccount (pincode)");
        	return 1;
        }
        pincode = strval(tmp);
        tmp2 = dini_Get(udb_encode(pname),"pincode");
        if (udb_hash(tmp) != strval(tmp2))
        {
        	SendClientMessage(playerid,0xF5DEB3FF,"You have entered a wrong pincode!");
        	return 1;
        }
        SendClientMessage(playerid,0xF5DEB3FF,"You have logged in into your bank account!");
        banklogged[playerid] = 1;
        return 1;
    }
	if(strcmp(cmdtext,"/deposit",true) == 0)
    {
        new ammount;
        tmp = strtok(cmdtext,idx);
        if(banklogged[playerid] == 0)
        	{
					SendClientMessage(playerid,0xF5DEB3FF,"You are not logged in on your bank account!");
					return 1;
   			}
        if(!strlen(tmp))
        	{
        		SendClientMessage(playerid,0xFF0000FF,"USAGE: /deposit (ammount)");
					return 1;
   			}
        ammount = strval(tmp);
        new currentm = GetPlayerMoney(playerid);
        if(currentm <= ammount)
        	{
        	SendClientMessage(playerid,0xF5DEB3FF,"You cannot deposit more money than you have!");
					return 1;
  				}
        if(PlayerToPoint(3,playerid,2308.7920,-13.5103,26.7422))
        	{
        	bankmoney[playerid] += ammount;
         	format(string, sizeof(string),"You have deposited $%d.00 to your bank account.",ammount);
         	SendClientMessage(playerid,0xF5DEB3FF,string);
          	GivePlayerMoney(playerid,-ammount);
          return 1;
        	}
        else
        	{
        	SendClientMessage(playerid,0xF5DEB3FF,"You are not at the Bank!");
					return 1;
   			}
    }
	if(strcmp(cmdtext,"/balance",true) == 0)
    {
        if(banklogged[playerid] == 0)
        {
        	SendClientMessage(playerid,0xF5DEB3FF,"You are not logged in into your bank account!");
					return 1;
        }
        if(PlayerToPoint(3,playerid,2308.7920,-13.5103,26.7422))
        {
       		format(string,sizeof(string),"You currently have $%d.00 in your bank account.",bankmoney[playerid]);
        	SendClientMessage(playerid,0xF5DEB3FF,string);
         	return 1;
        }
        else
        {
        	SendClientMessage(playerid,0xF5DEB3FF,"You are not in the bank!");
					return 1;
				}
    }
	if(strcmp(cmdtext,"/withdraw",true) == 0)
    {
        new wammount;
        tmp = strtok(cmdtext,idx);
        if(banklogged[playerid] == 0)
        {
        	SendClientMessage(playerid,0xF5DEB3FF,"You are not logged in into your bank account!");
					return 1;
        }
        if(!strlen(tmp))
        {
        	SendClientMessage(playerid,0xFF0000FF,"USAGE: /withdraw (ammount)");
					return 1;
        }
        wammount = strval(tmp);
        new bank = bankmoney[playerid];
        if(bank <= wammount-1)
        {
        	SendClientMessage(playerid,0xF5DEB3FF,"You cannot withdraw more money than you have!");
					return 1;
        }
        if(PlayerToPoint(3,playerid,2308.7920,-13.5103,26.7422))
        {
        	bankmoney[playerid] -= wammount;
         	format(string,sizeof(string),"You have withdrawed $%d.00 from your bank account.",wammount);
         	SendClientMessage(playerid,0xF5DEB3FF,string);
          	GivePlayerMoney(playerid,wammount);
          return 1;
        }
        else
        {
          SendClientMessage(playerid,0xF5DEB3FF,"You are not in the bank!");
					return 1;
				}
		}
	if(strcmp(cmdtext,"/enter",true) == 0)
		{
			if(PlayerToPoint(3,playerid,-217.7988,979.1361,19.5038)) // Department
			{
      SetPlayerPos(playerid,246.7975,62.8494,1003.6406);
			SetPlayerInterior(playerid,6);
			}
			if(PlayerToPoint(3,playerid,-179.6478,1133.1523,19.7422)) // Bank
			{
      SetPlayerPos(playerid,2305.2908,-16.1280,26.7422);
			SetPlayerInterior(playerid,0);
			}
			if(PlayerToPoint(3,playerid,-181.1324,1034.7759,19.7422)) // Supermarket
 			{
      SetPlayerPos(playerid,-26.7067,-57.9067,1003.5469);
			SetPlayerInterior(playerid,6);
			}
			return 1;
		}
  if(strcmp(cmdtext,"/exit",true) == 0)
		{
			if(PlayerToPoint(3,playerid,246.7975,62.8494,1003.6406)) // Department
 			{
      SetPlayerPos(playerid,-217.7988,979.1361,19.5038);
			SetPlayerInterior(playerid,0);
			}
			if(PlayerToPoint(3,playerid,2305.2908,-16.1280,26.7422)) // Bank
 			{
      SetPlayerPos(playerid,-179.6478,1133.1523,19.7422);
			SetPlayerInterior(playerid,0);
			}
			if(PlayerToPoint(3,playerid,-26.7067,-57.9067,1003.5469)) // Supermarket
 			{
      SetPlayerPos(playerid,-181.1324,1034.7759,19.7422);
			SetPlayerInterior(playerid,0);
			}
			return 1;
		}
  if(!strcmp(cmdtext,"/me",true,3))
  	{
    	if(!cmdtext[3])return SendClientMessage(playerid,0xFF0000FF,"USAGE: /me (action)");
    	new str[128];
    	GetPlayerName(playerid,str,sizeof(str));
    	format(str,sizeof(str),"* %s %s",str,cmdtext[4]);
    	SendClientMessageToAll(0xF5DEB3FF,str);
			return 1;
  	}
 	if(!strcmp(cmdtext,"/do",true,3))
  	{
  	  if(!cmdtext[3])return SendClientMessage(playerid,0xFF0000FF,"USAGE: /do (action)");
  	  new str[128];
  	  GetPlayerName(playerid,str,sizeof(str));
  	  format(str,sizeof(str),"* %s (%s)",cmdtext[4],str);
  	  SendClientMessageToAll(0xF5DEB3FF,str);
  	  return 1;
		}
	if(strcmp(cmdtext,"/onduty",true) == 0)
  	{
    	new str[128];
  	  GetPlayerName(playerid,str,sizeof(str));
  	  format(str,sizeof(str),"* Deputy sheriff %s is now on duty.",str);
  	  SendClientMessageToAll(0xF5DEB3FF,str);
 			return 1;
  	}
  if(strcmp(cmdtext,"/offduty",true) == 0)
  	{
    	new str[128];
  	  GetPlayerName(playerid,str,sizeof(str));
  	  format(str,sizeof(str),"* Deputy sheriff %s is no longer on duty.",str);
  	  SendClientMessageToAll(0xF5DEB3FF,str);
 			return 1;
  	}
  if(strcmp(cmdtext,"/uniform",true) == 0)
  	{
   		if(PlayerToPoint(3,playerid,254.0610,73.9032,1003.6406))
    		{
			SetPlayerSkin(playerid,288);
			GivePlayerWeapon(playerid,22,17);
		 	return 1;
			}
			else
  			{
		  SendClientMessage(playerid,0xF5DEB3FF,"You are not in the locker room!");
	   	return 1;
   		}
	  }
  	return 0;
}

stock PlayerToPoint(Float:radi,playerid,Float:x,Float:y,Float:z)
{
  new Float:oldposx,Float:oldposy,Float:oldposz;
  new Float:tempposx,Float:tempposy,Float:tempposz;
  GetPlayerPos(playerid,oldposx,oldposy,oldposz);
  tempposx = (oldposx -x);
  tempposy = (oldposy -y);
  tempposz = (oldposz -z);
  if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  {
    return 1;
  }
  return 0;
}

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 OnPlayerRequestSpawn(playerid)
{
	return 1;
}

public OnObjectMoved(objectid)
{
	return 1;
}

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

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

public OnVehicleMod(playerid, vehicleid, componentid)
{
	return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
	return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
	return 1;
}

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

public OnPlayerExitedMenu(playerid)
{
	return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
	return 1;
}

public OnPlayerUpdate(playerid)
{
	return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
	return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
	return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
	return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
	return 1;
}



Re: (Question) Unknown Command - Gamer_Z - 18.05.2010

in each cm you have
return 1;
}
}

but it should be at least
return 1;
}
return 1;
}

and no matter what always an return 1 at end of command.. or anithing else thet returns 1+

}
return 1;
}

or
}
return SendClientMessage(playerid,COLOR,Message);
}




Re: (Question) Unknown Command - Almighty Socrates - 18.05.2010

Sorry sir but I don't get it, I'm newbie. Do you mean that I have to make it like this?

Код:
if(strcmp(cmdtext,"/withdraw",true) == 0)
    {
        new wammount;
        tmp = strtok(cmdtext,idx);
        if(banklogged[playerid] == 0)
        {
        	SendClientMessage(playerid,0xF5DEB3FF,"You are not logged in into your bank account!");
					return 1;
        }
        if(!strlen(tmp))
        {
        	SendClientMessage(playerid,0xFF0000FF,"USAGE: /withdraw (ammount)");
					return 1;
        }
        wammount = strval(tmp);
        new bank = bankmoney[playerid];
        if(bank <= wammount-1)
        {
        	SendClientMessage(playerid,0xF5DEB3FF,"You cannot withdraw more money than you have!");
					return 1;
        }
        if(PlayerToPoint(3,playerid,2308.7920,-13.5103,26.7422))
        {
        	bankmoney[playerid] -= wammount;
         	format(string,sizeof(string),"You have withdrawed $%d.00 from your bank account.",wammount);
         	SendClientMessage(playerid,0xF5DEB3FF,string);
          	GivePlayerMoney(playerid,wammount);
          return 1;
        }
        else
        {
          SendClientMessage(playerid,0xF5DEB3FF,"You are not in the bank!");
				}
				return 1;
		}
It's not the whole script I only cut some, the end of the script return 0; is used. What's the different between those exactly?


Re: (Question) Unknown Command - Almighty Socrates - 18.05.2010

Hallo?


Re: (Question) Unknown Command - Almighty Socrates - 18.05.2010

Anyone can help please?