#1

Код:
CMD:slap(playerid, params[])
{
  if(PlayerInfo[playerid][pAdmin] < 1)
  {
     new id,Float:x,Float:y,Float:z,name[MAX_PLAYER_NAME],msg[128];
     if(sscanf(params,"u",id)) return SendClientMessage(playerid,-1,"Usage: /slap [id]");
     else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid,-1,"Player is not connected anymore!");
     else
     {
         SendClientMessage(playerid,-1,"You have been successful slapped that player!"); 
         GetPlayerPos(id,x,y,z);
         SetPlayerPos(id,x,y,z+10); 
         GetPlayerName(playerid,name,sizeof(name)); 
         format(msg,sizeof(msg),"AdmCmd: You have been slapped by Admin %s",name); 
         SendClientMessage(id,-1,msg); /
     }
     }
     else
     {
         SendClientMessage(playerid,0x800000FF,"You are not authorized to use this command!");
  }

  return 1;
}
This is my slap cmd..how i can edit line
Код:
SendClientMessage(playerid,-1,"You have been successful slapped that player!");
to show what player i slap, to show player reason why
Код:
format(msg,sizeof(msg),"AdmCmd: You have been slapped by Admin %s",name);
and how to send admin message with this stock
Код:
stock SendMessageToAdmins(color, message[], level)
{
for(new i = 0; i < MAX_PLAYERS; i ++)
{
   if(IsPlayerConnected(i))
   {
      if(PlayerInfo[i][pAdmin] >= level)
      {
         SendClientMessage(i, color, message);
      }
   }
}
return 1;
}
Reply
#2

Код:
CMD:slap(playerid, params[])
{
  if(PlayerInfo[playerid][pAdmin] < 1)
  {
     new id,Float:x,Float:y,Float:z,name[MAX_PLAYER_NAME],msg[128], reason[64], string[128], idname[MAX_PLAYER_NAME];
     if(sscanf(params,"us[32]",id, reason)) return SendClientMessage(playerid,-1,"Usage: /slap [id] [reason]");
     else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid,-1,"Player is not connected anymore!");
     else
     {
         GetPlayerName(id, name, MAX_PLAYER_NAME);
         format(string, sizeof(string), "AdmCmd: You have successfully slapped %s, reason: %s",  name, reason);
         SendClientMessage(playerid,-1,string); 
         GetPlayerPos(id,x,y,z);
         SetPlayerPos(id,x,y,z+10); 
         GetPlayerName(playerid,name,sizeof(name)); 
         format(msg,sizeof(msg),"AdmCmd: You have been slapped by Admin %s, reason: %s",name, reason); 
         SendClientMessage(id,-1,msg); /
         GetPlayerName(id, idname, MAX_PLAYER_NAME);
         format(string, sizeof(string), "AdmCmd: Admin %s has slapped %s, reason: %s", name, idname, reason);
         SendMessageToAdmins(0xFF6347FF, string, 1);
     }
     }
     else
     {
         SendClientMessage(playerid,0x800000FF,"You are not authorized to use this command!");
  }

  return 1;
}
Reply
#3

To explain it: format changes the string you are formatting to its content and replaces specifiers given with variables. So what you would just have to do, like the person above me did, is send the string you formatted along with the SendMessageToAdmins function.
Reply
#4

Код:
CMD:slap(playerid, params[])
{
  if(PlayerInfo[playerid][pAdmin] < 1)
  {
     new id,Float:x,Float:y,Float:z,name[MAX_PLAYER_NAME],msg[128],reason[128],targetid[128];
     if(sscanf(params,"u",id,reason)) return SendClientMessage(playerid,-1,"Usage: /slap [id] [reason]");
     else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid,-1,"Player is not connected anymore!");
     else
     {
         SendClientMessage(playerid,-1,"You have been successful slapped that player!"); 
         GetPlayerPos(id,x,y,z);
         SetPlayerPos(id,x,y,z+10); 
         GetPlayerName(playerid,name,sizeof(name)); 
         format(msg,sizeof(msg),"AdmCmd: You have been slapped by Admin %s for %s",name,reason); 
         SendClientMessage(id,-1,msg); 
	format(string, sizeof(string), "*"COL_RED" Admin %s has slapped %s for %s",name,name(targetid),reason);
       SendMessageToAdmins(-1,string);
     }
     }
     else
     {
         SendClientMessage(playerid,0x800000FF,"You are not authorized to use this command!");
  }

  return 1;
}
Try this please
Reply
#5

thanks
Reply
#6

Quote:

error 017: undefined symbol "string"
error 017: undefined symbol "string"
warning 215: expression has no effect
error 001: expected token: ";", but found ")"
fatal error 107: too many error messages on one line

on line
Quote:

format(string, sizeof(string), "*"COL_RED" Admin %s has slapped %s for %s",name,name(targetid),reason);

Reply
#7

Код:
CMD:slap(playerid, params[])
{
  if(PlayerInfo[playerid][pAdmin] < 1)
  {
     new id,Float:x,Float:y,Float:z,name[MAX_PLAYER_NAME],msg[128],reason[128],targetid[128],string[128];
     if(sscanf(params,"u",id,reason)) return SendClientMessage(playerid,-1,"Usage: /slap [id] [reason]");
     else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid,-1,"Player is not connected anymore!");
     else
     {
         SendClientMessage(playerid,-1,"You have been successful slapped that player!"); 
         GetPlayerPos(id,x,y,z);
         SetPlayerPos(id,x,y,z+10); 
         GetPlayerName(playerid,name,sizeof(name)); 
         format(msg,sizeof(msg),"AdmCmd: You have been slapped by Admin %s for %s",name,reason); 
         SendClientMessage(id,-1,msg); 
	format(string, sizeof(string), "*"COL_RED" Admin %s has slapped %s for %s",name,name(targetid),reason);
       SendMessageToAdmins(-1,string);
     }
     }
     else
     {
         SendClientMessage(playerid,0x800000FF,"You are not authorized to use this command!");
  }

  return 1;
}
Reply
#8

on same line error:
Quote:

error 012: invalid function call, not a valid address
warning 215: expression has no effect
error 001: expected token: ";", but found ")"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line

Reply
#9

Код:
Код:
CMD:slap(playerid, params[])
{
  if(PlayerInfo[playerid][pAdmin] < 1)
  {
     new id,Float:x,Float:y,Float:z,name[MAX_PLAYER_NAME],name2[MAX_PLAYER_NAME],msg[128],reason[128],targetid[128],string[128];
     if(sscanf(params,"u",id,reason)) return SendClientMessage(playerid,-1,"Usage: /slap [id] [reason]");
     else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid,-1,"Player is not connected anymore!");
     else
     {
         SendClientMessage(playerid,-1,"You have been successful slapped that player!"); 
         GetPlayerPos(id,x,y,z);
         SetPlayerPos(id,x,y,z+10); 
         GetPlayerName(playerid,name,sizeof(name)); 
         format(msg,sizeof(msg),"AdmCmd: You have been slapped by Admin %s for %s",name,reason); 
         SendClientMessage(id,-1,msg); 
	format(string, sizeof(string), "*"COL_RED" Admin %s has slapped %s for %s",name,name2,reason);
         SendMessageToAdmins(-1,string);
     }
     }
     else
     {
         SendClientMessage(playerid,0x800000FF,"You are not authorized to use this command!");
  }

  return 1;
}
Reply
#10

Quote:
Originally Posted by Wizzard2H
Посмотреть сообщение
Код:
Код:
CMD:slap(playerid, params[])
{
  if(PlayerInfo[playerid][pAdmin] < 1)
  {
     new id,Float:x,Float:y,Float:z,name[MAX_PLAYER_NAME],name2[MAX_PLAYER_NAME],msg[128],reason[128],targetid[128],string[128];
     if(sscanf(params,"u",id,reason)) return SendClientMessage(playerid,-1,"Usage: /slap [id] [reason]");
     else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid,-1,"Player is not connected anymore!");
     else
     {
         SendClientMessage(playerid,-1,"You have been successful slapped that player!"); 
         GetPlayerPos(id,x,y,z);
         SetPlayerPos(id,x,y,z+10); 
         GetPlayerName(playerid,name,sizeof(name)); 
         format(msg,sizeof(msg),"AdmCmd: You have been slapped by Admin %s for %s",name,reason); 
         SendClientMessage(id,-1,msg); 
	format(string, sizeof(string), "*"COL_RED" Admin %s has slapped %s for %s",name,name2,reason);
         SendMessageToAdmins(-1,string);
     }
     }
     else
     {
         SendClientMessage(playerid,0x800000FF,"You are not authorized to use this command!");
  }

  return 1;
}
Don't you think that name2 won't show any name?
Use:
Код:
GetPlayerName(targetid,name2,sizeof(name2));
format(string, sizeof(string), "*"COL_RED" Admin %s has slapped %s for %s",name, name2, reason);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)