Have problem with using SetPlayerWantedLevel(targetid,amount);
#1

When i try use command with playerID and AMOUNT OF STARS "/wanted 1 6", it says "Server: Unknown command".. but without amount of stars or player ID it says that error "You forget amount of starts or playerID.......".

There is something wich i forgot?

Код:
public OnPlayerCommandText(playerid,cmdtext[]) {

  new cmd[256];
  new idx;
  cmd = strtok(cmdtext,idx);
  new tmp[256];

  // WANTED
  if (strcmp(cmdtext, "/wanted", true) == 0)
  {
   tmp = strtok(cmdtext,idx);

   new targetid = strval(tmp); // Target ID
   new amount = strval(tmp); // How many stars

   if(!strlen(tmp)) {
     SendClientMessage(playerid,COLOR_LIGHTBLUE,"You forget amount of stars or playerID -> /wanted [ID] [amount 1-6]");
  	return 1;
  }
  if(PlayerInfo[playerid][logged] == 0) {
	 SendClientMessage(playerid,COLOR_BRIGHTRED,"You must be logged in!");
	return 1;
	}

  if (PlayerInfo[playerid][admin] < 2) {
     SendClientMessage(playerid,COLOR_BRIGHTRED,"You have no rights to use this command... Or your security clearance are too low.");
   	return 1;
 	}

  if(PlayerInfo[targetid][logged] == 0) {
	  SendClientMessage(playerid,COLOR_BRIGHTRED,"Player not found!");
	return 1;
    }
      SetPlayerWantedLevel(targetid,amount); // The main function
    return 1;
	}
 return 0;
}
Reply
#2

Код:
public OnPlayerCommandText(playerid,cmdtext[]) {

	new cmd[256];
	new idx;
	cmd = strtok(cmdtext,idx);
	new tmp[256];
	// WANTED
	if (strcmp(cmd, "/wanted", true) == 0)
	{
	tmp = strtok(cmdtext,idx);
	if(!strlen(tmp)) {
	SendClientMessage(playerid,COLOR_LIGHTBLUE,"You forget amount of stars or playerID -> /wanted [ID] [amount 1-6]");
	return 1;
	}
	new targetid = strval(tmp); // Target ID
	tmp = strtok(cmdtext,idx);
	new amount = strval(tmp); // How many stars
	if(PlayerInfo[playerid][logged] == 0) {
	SendClientMessage(playerid,COLOR_BRIGHTRED,"You must be logged in!");
	return 1;
	}
	if (PlayerInfo[playerid][admin] < 2) {
	SendClientMessage(playerid,COLOR_BRIGHTRED,"You have no rights to use this command... Or your security clearance are too low.");
	return 1;
	}
	if(PlayerInfo[targetid][logged] == 0) {
	SendClientMessage(playerid,COLOR_BRIGHTRED,"Player not found!");
	return 1;
	}
	SetPlayerWantedLevel(targetid,amount); // The main function
	return 1;
	}
	return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)