How to make a ERROR Message?
#1

How can I make it say "You must be on foot to use this command"


on this CMD:


pawn Код:
CMD:mission(playerid,params[])
{
if(IsPlayerSpawned(playerid))
{
  TextDrawShowForPlayer(playerid,mission);
  TextDrawShowForPlayer(playerid,mission1);
  TextDrawShowForPlayer(playerid,mission2);
  return 1;
}
//SendClientMessage(playerid,0xFF1A00C8,"You must be on foot to use this command"); This here
Reply
#2

pawn Код:
if(IsPlayerSpawned(playerid))
{
  TextDrawShowForPlayer(playerid,mission);
  TextDrawShowForPlayer(playerid,mission1);
  TextDrawShowForPlayer(playerid,mission2);
  return 1;
}
else
{
//code
Reply
#3

pawn Код:
new playerState = GetPlayerState(playerid);
 
if (playerState != PLAYER_STATE_ONFOOT) return SendClientMessage(playerid, COLOR_RED, "Error: You must be on foot to use this command.");
Reply
#4

EDIT: do the playerstate part as PrivatioBoni showed
pawn Код:
CMD:mission(playerid,params[])
{
new playerState = GetPlayerState(playerid);
 
if (playerState != PLAYER_STATE_ONFOOT) return SendClientMessage(playerid, COLOR_RED, "Error: You must be on foot to use this command.");
  else
  {
  if(IsPlayerSpawned(playerid))
  {
    TextDrawShowForPlayer(playerid,mission);
    TextDrawShowForPlayer(playerid,mission1);
    TextDrawShowForPlayer(playerid,mission2);
 
  }
return 1;
}
Reply
#5

Код:
CMD:mission(playerid,params[])
{
if(IsPlayerSpawned(playerid)&&GetPlayerState(playerid)==PLAYER_STATE_ONFOOT)
{ 
  TextDrawShowForPlayer(playerid,mission);
  TextDrawShowForPlayer(playerid,mission1);
  TextDrawShowForPlayer(playerid,mission2);

}
else
{
SendClientMessage(playerid,0xFF1A00C8,"You must be on foot to use this command");
return 1;
}
 return 1;
}
Reply
#6

Dunno why everyone's code is so messy. This is the cleanest I can do:

pawn Код:
CMD:mission(playerid,params[])
{
   new playerState = GetPlayerState(playerid);  
   if (playerState != PLAYER_STATE_ONFOOT)
   {
      SendClientMessage(playerid, COLOR_RED, "Error: You must be on foot to use this command.");
      return 1;
   }




   TextDrawShowForPlayer(playerid,mission);
   TextDrawShowForPlayer(playerid,mission1);
   TextDrawShowForPlayer(playerid,mission2);
 
   return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)