Admin say problem
#1

Hello everyone , i made an /asay command that allows the admin to send a message to the players. i compiled the .pwn file and there is no errors/warnings , but in game , the command is not working...
Maybe you can tell me what should i do..
Here's the cmd

PHP код:
if(!strcmp(cmd"/asay2"))
    {
  {
  if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,"You are not an admin !");
  new 
text[128], string[128];
  if(
sscanf(params"s[128]",text)) return SendClientMessage(playerid0xFFFFFFFF"Usage: /asay [text]");
  else
  {
  new 
pName[128];
  
GetPlayerName(playerid,pName,128);
  
format(string,sizeof string,"~b~%s:~r~%s",pName,text);
  
GameTextForAll(string,3000,4);
  }
  }
  return 
1;

Reply
#2

How do you want to use SSCANF with strcmp?
Use DCMD, ZCMD. A command plugin which supports params.
Reply
#3

Quote:
Originally Posted by Biesmen
Посмотреть сообщение
How do you want to use SSCANF with strcmp?
Use DCMD, ZCMD. A command plugin which supports params.
Well , i used SSCANF With strcmp to create many commands /kick , /ban , /freeze , /mute and many other commands
and i don't know what is this cmd problem , Help me please?
Reply
#4

But how do you use the params if it's not defined? Or is it defined somewhere else in the callbakc OnPlayerCommand?

Well, anyway, let's try this code then:
pawn Код:
if(!strcmp(cmd, "/asay2"))
{
    new text[128], string[128];
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,"You are not an admin !");
    if(sscanf(params, "s[128]",text)) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /asay2 [text]");
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(string, sizeof(string), "~b~%s:~r~%s",pName, text);
    GameTextForAll(string, 3000, 4);
    return 1;
}
You used too many unnecessarily brackets, and you used else for no reason, and pName should be MAX_PLAYER_NAME, which will make the small chance of lag even more small.
Reply
#5

Mhmm... I tested this but , still not working !! nothing changed , when i type like /asay2 Hello , it shows /asay2 [text]..
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)