Code Help
#1

Hi guys ,
Can someone tell me why or what is wrong because when i type /setdonatorlvl is says unknown command this is my code:
Код:
public OnPlayerConnect(playerid)
{
	new string[128], string2[128];
	CreateNameVariable(playerid, pName);

	format(string, sizeof(string), "%s/%s.%s", USER_DIR, pName, USER_EXT);

	DonatorLevel[playerid] = 0;
	if(fexist(string))
	{
	  if((dini_Int(string, "Donator level") < 0) || (dini_Int(string, "Donator level") > DONATOR_LEVELS))
	  {
	    // Undefined Donator Level
      return printf("ERROR: Undefined donator level at %s/%s.%s (%i).", USER_DIR, pName, USER_EXT);
	  }
	  if(!strcmp(DonatorText[dini_Int(string, "Donator level")], "\0"))
	  {
	    // There is no text in DonatorText[player's donator level]
	    return printf("ERROR: Please enter a text for donator level %i.", dini_Int(string, "Donator level"));
		}

		if(dini_Int(string, "Donator level") != 0)
		{
			format(string2, sizeof(string2), "Your donator level is %s. Enjoy all benefits of it!", DonatorText[dini_Int(string, "Donator level")]);
			SendClientMessage(playerid, COLOR_DARKYELLOW, string);
		}

		DonatorLevel[playerid] = dini_Int(string, "Donator level");
	}

	return 1;
}

public IsPlayerDonator(playerid)
{
	if(DonatorLevel[playerid] != 0 && DonatorLevel[playerid] < 0 && DonatorLevel[playerid] > DONATOR_LEVELS) return 1;
	return 0;
}

public IsPlayerDonatorLevel(playerid, level)
{
	if(DonatorLevel[playerid] == level) return 1;
	return 0;
}

public GetPlayerDonator(playerid)
{
	return DonatorLevel[playerid];
}

public SetPlayerDonator(playerid, level)
{
	if(level != DonatorLevel[playerid])
	{
	  new string[128];
	  CreateNameVariable(playerid, pName);

		format(string, sizeof(string), "%s/%s.%s", USER_DIR, pName, USER_EXT);
		if(!fexist(string)) dini_Create(string);

		dini_IntSet(string, "Donator level", level);
	}

	DonatorLevel[playerid] = level;
	return 1;
}

command(setdonatorlvl, playerid, params[])
{
	new target, level, string[128];
	if(sscanf(params, "ui", target, level)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setdonatorlvl [player] [level]");
	else
	{
		CreateNameVariable(playerid, pName);
		CreateNameVariable(target, tName);

		if(target == INVALID_PLAYER_ID)
		{
			format(string, sizeof(string), "Player %s is not active.", tName);
		  return SendClientMessage(playerid, COLOR_WHITE, string);
		}

		if(level < 0 || level > DONATOR_LEVELS)
		{
		  format(string, sizeof(string), "Please enter a valid level (0 - %i).", DONATOR_LEVELS);
		  return SendClientMessage(playerid, COLOR_WHITE, string);
		}

		if(GetPlayerDonator(playerid) < level)
		{
		  format(string, sizeof(string), "%s has promoted you to donator level %i (%s).", pName, level, DonatorText[level]);
		  SendClientMessage(target, COLOR_LIGHTGREEN, string);
		  format(string, sizeof(string), "You have promoted %s to donator level %i (%s).", tName, level, DonatorText[level]);
		  SendClientMessage(playerid, COLOR_LIGHTGREEN, string);
		}
		else
		{
			format(string, sizeof(string), "%s has demoted you to donator level %i (%s).", pName, level, DonatorText[level]);
		  SendClientMessage(target, COLOR_LIGHTRED, string);
		  format(string, sizeof(string), "You have demoted %s to donator level %i (%s).", tName, level, DonatorText[level]);
		  SendClientMessage(playerid, COLOR_LIGHTRED, string);
		}

		SetPlayerDonator(target, level);
	}
	return 1;
}
Reply
#2

pawn Код:
public OnPlayerCommandText(playerid,cmdtext)
{
dcmd(setdonatorlvl,13,cmdtext); // that line
return 1;
}
Got that line?
Reply
#3

There could be numerous causes. Debug it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)