what happend here?
#1

What happend? when i type /achat [MY Message] given me nothing lol. Please Edit it if there a wrong.

PHP код:
CMD:achat(playeridparams[])
{
  new 
string[128],msg[128],id,name[MAX_PLAYER_NAME];
  if(
pInfo[playerid][Adminlevel] >=|| IsPlayerAdmin(playerid))
  {
      if(
sscanf(params"s[128]",msg)) return SCM(playerid,-1,""grey"[SYSTEM]:"red"/achat [Message]");
      
GetPlayerName(id,name,sizeof(name));
      
format(string,sizeof(string),"[Admins]: %s: %s",pInfo[id][Adminlevel],name,msg);
      foreach(
Playeri)
      {
          if(
pInfo[playerid][Adminlevel] >= 1)
          {
             
SCM(playerid, -1,string);
          }
      }
  }
  else
  {
       
SCM(playerid, -1""red"{FF0000}[SYSTEM]: This command available for administrator only.");
  }
  return 
1;

Reply
#2

Код:
CMD:achat(playerid, params[]) 

{ 
  new string[128],msg[128],name[MAX_PLAYER_NAME]; 
  if(pInfo[playerid][Adminlevel] >=1 || IsPlayerAdmin(playerid)) 
  { 
      if(sscanf(params, "s[128]",msg)) return SCM(playerid,-1,""grey"[SYSTEM]:"red"/achat [Message]"); 
      GetPlayerName(playerid,name,sizeof(name)); 
      format(string,sizeof(string),"[Admins]: %s: %s",pInfo[playerid][Adminlevel],name,msg); 
      foreach(Player, i) // < Old loop, recommended update to the new foreach version
      { 
          if(pInfo[i][Adminlevel] >= 1) 
          { 
             SCM(i, -1,string); 
          } 
      } 
  } 
  else 
  { 
       SCM(playerid, -1, ""red"{FF0000}[SYSTEM]: This command available for administrator only."); 
  } 
  return 1; 
}
Reply
#3

Still not work? please help me.
Reply
#4

Sorry, there were more mistakes than I thought

Try this:

Код:
CMD:achat(playerid, params[]) 

{ 
  new string[128],msg[128],name[MAX_PLAYER_NAME]; 
  if(pInfo[playerid][Adminlevel] >=1) 
  { 
      if(sscanf(params, "s[128]",msg)) return SCM(playerid,-1,""grey"[SYSTEM]:"red"/achat [Message]"); 
      GetPlayerName(playerid,name,sizeof(name)); 
      format(string,sizeof(string),"[Admins]: %s: %s",name,msg); 
      foreach(Player, i) // < Old loop, recommended update to the new foreach version
      { 
          if(pInfo[i][Adminlevel] >= 1) 
          { 
             SCM(i, -1,string); 
          } 
      } 
  } 
  else 
  { 
       SCM(playerid, -1, ""red"{FF0000}[SYSTEM]: This command available for administrator only."); 
  } 
  return 1; 
}
Reply
#5

Tested its work.
Код:
CMD:achat(playerid, params[])

{
  new string[128],msg[128],name[MAX_PLAYER_NAME];
  if(pInfo[playerid][AdminLevel] >=1)
  {
      if(sscanf(params, "s[128]",msg)) return SCM(playerid,-1,""grey"[SYSTEM]:"red"/achat [Message]");
      GetPlayerName(playerid,name,sizeof(name));
      format(string,sizeof(string),"[Admins]: %s: %s",pInfo[playerid][AdminLevel],name,msg);
      foreach(new i : Player) 
      {
          if(pInfo[i][AdminLevel] >= 1)
          {
             SCM(i, -1,string);
          }
      }
  }
  else
  {
       SCM(playerid, -1, ""red"{FF0000}[SYSTEM]: This command available for administrator only.");
  }
  return 1;
}
Reply
#6

Thanks worked Rep both worked
Reply
#7

Before you go, let me explain you in comments what was bad, so you learn something instead of just copy-pasting:

PHP код:
CMD:achat(playeridparams[]) 


  new 
string[128],msg[128],id,name[MAX_PLAYER_NAME];  // Variable id here is useless, why did you make it? You already have playerid.
  
if(pInfo[playerid][Adminlevel] >=|| IsPlayerAdmin(playerid)) // 'IsPlayerAdmin' You were checking here if the player was RCON admin, I highly doubt you provide the server's RCON password to every admin your server have.
  

      if(
sscanf(params"s[128]",msg)) return SCM(playerid,-1,""grey"[SYSTEM]:"red"/achat [Message]"); 
      
GetPlayerName(id,name,sizeof(name)); // again, id did not mean anything here, so we changed it for playerid.
      
format(string,sizeof(string),"[Admins]: %s: %s",pInfo[id][Adminlevel],name,msg); // yor format had two strings but you were trying to add a third one, we removed pInfo[id][Adminlevel] from here as it was not doing anything.
      
foreach(Playeri
      { 
          if(
pInfo[playerid][Adminlevel] >= 1)  // this is inside a loop, the reason you want to loop is to check on every player, hence we changed here player id for 'i'
          

             
SCM(playerid, -1,string);  // same 'i' here
          

      } 
  } 
  else 
  { 
       
SCM(playerid, -1""red"{FF0000}[SYSTEM]: This command available for administrator only."); 
  } 
  return 
1

Everything else was 'ok'. Please keep learning and reading, do not copy-paste!
Reply
#8

Quote:
Originally Posted by Troydere
Посмотреть сообщение
Before you go, let me explain you in comments what was bad, so you learn something instead of just copy-pasting:

PHP код:
CMD:achat(playeridparams[]) 

  new 
string[128],msg[128],id,name[MAX_PLAYER_NAME];  // Variable id here is useless, why did you make it? You already have playerid.
  
if(pInfo[playerid][Adminlevel] >=|| IsPlayerAdmin(playerid)) // 'IsPlayerAdmin' You were checking here if the player was RCON admin, I highly doubt you provide the server's RCON password to every admin your server have.
  

      if(
sscanf(params"s[128]",msg)) return SCM(playerid,-1,""grey"[SYSTEM]:"red"/achat [Message]"); 
      
GetPlayerName(id,name,sizeof(name)); // again, id did not mean anything here, so we changed it for playerid.
      
format(string,sizeof(string),"[Admins]: %s: %s",pInfo[id][Adminlevel],name,msg); // yor format had two strings but you were trying to add a third one, we removed pInfo[id][Adminlevel] from here as it was not doing anything.
      
foreach(Playeri
      { 
          if(
pInfo[playerid][Adminlevel] >= 1)  // this is inside a loop, the reason you want to loop is to check on every player, hence we changed here player id for 'i'
          

             
SCM(playerid, -1,string);  // same 'i' here
          

      } 
  } 
  else 
  { 
       
SCM(playerid, -1""red"{FF0000}[SYSTEM]: This command available for administrator only."); 
  } 
  return 
1

Everything else was 'ok'. Please keep learning and reading, do not copy-paste!
It's more of a problem when people just give the person the code without explaining anything rather than the ones asking for help, looking for an easy way out and just copy-pasting the code. You gave him the code and you expected him to learn something from that?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)