problem
#1

Guys i have problem with my /rp command here is the command

Код:
CMD:rp(playerid, params[])
{
  new playername[MAX_PLAYER_NAME];
	GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
	
	new plvl;
	GetPlayerWantedLevel(plvl);
	
	new string[256];
	
	new
	  giveplayerid,
	  reason[64];
	  
  if (sscanf(params, "uz", giveplayerid,reason))return SendClientMessage(playerid, 0xFF9900AA, "Usage: \"/rp [playerid/name] [reason]\"");
  else if (gTeam[playerid] != TEAM_COP)return SendClientMessage(playerid,0xFF9900AA,"Only Cops Can Use This Command!");
  else if (giveplayerid == INVALID_PLAYER_ID)return SendClientMessage(playerid, 0xFF9900AA, "Player Not Found");
  //else if (giveplayerid == playerid)return SendClientMessage(playerid,0xFF9900AA,"You Can't Report Yourself!");
  else if (GetDistanceBetweenPlayers(playerid,giveplayerid) > 4)return SendClientMessage(playerid,0xFF9900AA,"This Player Is Out Of Rage!");
	else if (giveplayerid == TEAM_COP)return SendClientMessage(playerid,0xFF9900AA,"You Can't Report Law Enforcement Officer");
  else if (IsJailed[giveplayerid] == true)return SendClientMessage(playerid,0xFF9900AA,"You Can't Report Prisoners!");
  else
  {
  format(reason, sizeof (reason), "You Have Been Reported By Officer %s(%d)", reason[0] ? ("For Criminal:"):(""),playername,playerid,reason);
	SendClientMessage(giveplayerid, 0x800080AA, reason);
	
	SetPlayerWantedLevel(giveplayerid,plvl +1);
	return 1;
	}
}
but it wont work so good ... i want when i type /rp id reason it will say ''You Have Been Reported By Officer (name)(id) For Criminalreason , what player type in) how i can do this ?
Reply
#2

ammm anyone ?
Reply
#3

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256];
new idx;
new string[256];
if(strcmp(cmd, "/rp", true) == 0)
	{
	new tmp[256];
		tmp = strtok(cmdtext, idx);
		new otherplayer = strval(tmp);
	new pName[MAX_PLAYER_NAME];
  		if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /rp [playerid] [reason]");
		new length = strlen(cmdtext);
		while ((idx < length) && (cmdtext[idx] <= ' '))
		{
			idx++;
		}
		new offset = idx;
		new result[64];
		while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
		{
			result[idx - offset] = cmdtext[idx];
			idx++;
		}
		result[idx - offset] = EOS;
		if(!strlen(result)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /rp [playerid] [reason]");
		if(!IsPlayerConnected(otherplayer)) return SendClientMessage(playerid, COLOR_WHITE, "Invalid Player ID.");
		GetPlayerName(playerid, pName, sizeof(pName));
   			SendClientMessage(playerid, COLOR_BRIGHTRED, "Report Message has sent to the Admins.");
				 format(string,sizeof(string),"Report from %s: [ID:%d Reason: %s.]", pName, otherplayer, result);
		for(new i=0;i<MAX_PLAYERS;i++)
		{
			if(IsPlayerConnected(i) && IsPlayerAdmin(playerid))
			{
				SendClientMessage(i,COLOR_CYAN,string);
			}
		}
  	return 1;
	}
	return 0;
}
Код:
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}

new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
this may help you ,remember to put strtok at last of the FS or GM !
Reply
#4

ty i wil ltry to figure out ^^
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)