Lots of problems in my commands! Please help (Urgent)
#1

Hey guys, I've recently added a few commands, and they do not work properly.

Command 1 (/report)

Код:
CMD:report(playerid, params[])
{
	new id, reason[128];
    if(sscanf(params, "us", id, reason))return SendClientMessage(playerid, RED, "Usage: /report [id/name][reason]");
    if(id==playerid)SendClientMessage(playerid,RED,"Error: You can not report yourself!");
	if(!IsPlayerConnected(id))return SendClientMessage(playerid,RED,"Player is not connected!");
    if(id==INVALID_PLAYER_ID)SendClientMessage(playerid,RED,"Error: Player is not connected!");
	SendClientMessage(playerid,COLOR_BLUE,"Your report has been sent to online admins!");
    new Name[MAX_PLAYER_NAME], KickMessage[128];
    new Name2[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, sizeof(Name));
    GetPlayerName(id, Name2, sizeof(Name2));
    format(KickMessage, sizeof(KickMessage), "%s(%d) has reported player %s(%d) | Reason: %s", Name, playerid, Name2, id, reason);
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
	if(IsPlayerConnected(i) == 1)  if(pInfo[i][Adminlevel] >=1) SendClientMessage(i, RED, KickMessage);
	}
	return 1;
}
The problem is, when I go in-game, and I do /report, it sends it to all players when I set it to send it to Admins only. And the part where it says "You can not report yourself", comes up when I do the command, and it still works?


Command Number 2 (ask):

Код:
CMD:ask(playerid, params[])
{
    if (sscanf(params, "s[256]", Question[playerid])) return SendClientMessage(playerid, 0x009DFFFF,"USAGE:{FFFFFF} /pm [ID] [Message]");
	if(QuestionAsked[playerid] == true) return SendClientMessage(playerid, COLOR_RED, "ERROR: Wait for the response of your previous question!");
	new string[128], string2[256], name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	format(string2, sizeof(string2), "QUESTION: %s", Question[playerid]);
	SendMessageToAdmins(COLOR_GREEN, string2);
	format(string, sizeof(string), "INFO: %s has asked a question, use /answer %d to answer it!", name, playerid);
	SendMessageToAdmins(COLOR_GREEN, string);
	QuestionAsked[playerid] = true;
	return 1;
}
The problem is, when I do /ask (question), the usage comes up saying "Usage: /ask (question) when I done it correctly. Here is my SendMessageToAdmins stock:

Код:
stock SendMessageToAdmins(color,const msg[])
{
   for (new i=0; i<MAX_PLAYERS; i++)
   {
      if(IsPlayerConnected(i) == 1) if(pInfo[i][Adminlevel] > 1) SendClientMessage(i,color,msg);
   }
}
Command Number 3 (answer)

CMD:answer(playerid, params[])
{

Код:
	new ID, string[256], string2[256];
	if(pInfo[playerid][Adminlevel] < 1)return SendClientMessage(playerid, 0xFF0000FF, "You are not authorised to use this command");
	if (sscanf(params, "is[256]", ID, string)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /answer [ID] [Answer]");
	if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_RED, "ERROR: This player is not connected!");
	if(QuestionAsked[ID] != true) return SendClientMessage(playerid, COLOR_RED, "ERROR: This player has not asked a question!");
	QuestionAsked[ID] = false;
	format(string2, sizeof(string2), "ANSWER: %s", string);
	SendClientMessage(ID, COLOR_GREEN, string2);
	return 1;
}
Just like the problem above! When I do /answer when someone does /ask, I do "/answer [ID] [Answer]" and I do it correctly! Please help! Thanks
Reply
#2

Quote:
Originally Posted by Goldino
Посмотреть сообщение
Код:
stock SendMessageToAdmins(color,const msg[])
{
   for (new i=0; i<MAX_PLAYERS; i++)
   {
      if(IsPlayerConnected(i) == 1) if(pInfo[i][Adminlevel] > 1) SendClientMessage(i,color,msg);
   }
}
pawn Код:
if(IsPlayerConnected(i) == 1)
wtf ?
i think i should be like that
pawn Код:
stock SendMessageToAdmins(color,const msg[])
{
   for (new i=0; i<MAX_PLAYERS; i++)
   {
      if(IsPlayerConnected(i)) if(pInfo[i][Adminlevel] > 1) SendClientMessage(i,color,msg);
   }
}
Reply
#3

Yay it works! Thanks, but one more problem. When I do /report, it says, "You can not report yourself" but the command works! Please help
Reply
#4

Anyone help with other commands?
Reply
#5

Try this

i did not test this command, so try it
pawn Код:
CMD:report(playerid, params[])
{
    new id, reason[128];
    if(sscanf(params, "us", id, reason))
    {
        SendClientMessage(playerid, RED, "Usage: /report [id/name][reason]");
    }
    if(id == playerid)
    {
        SendClientMessage(playerid,RED,"Error: You can not report yourself!");
    }
    if(!IsPlayerConnected(id))
    {
        SendClientMessage(playerid,RED,"Player is not connected!");
    }
    if(id == INVALID_PLAYER_ID)
    {
        SendClientMessage(playerid,RED,"Error: Player is not connected!");
    }
    //
    SendClientMessage(playerid,COLOR_BLUE,"Your report has been sent to online admins!");
    new Name[MAX_PLAYER_NAME], KickMessage[128];
    new Name2[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, sizeof(Name));
    GetPlayerName(id, Name2, sizeof(Name2));
    format(KickMessage, sizeof(KickMessage), "%s(%d) has reported player %s(%d) | Reason: %s", Name, playerid, Name2, id, reason);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    if(IsPlayerConnected(i) == 1)  if(pInfo[i][Adminlevel] >=1) SendClientMessage(i, RED, KickMessage);
    }
    return 1;
}
Reply
#6

Don't work! Anyone? plz
Reply
#7

Help!
Reply
#8

plz help
Reply
#9

pawn Код:
if(id == playerid) SendClientMessage(...
Can you see anywhere in this code, where the code is being stopped? What's different about this one line from the rest of them?























That's right... there's no 'return' in it, which is used to end a code and stop it from continuing.
So:
pawn Код:
if(id == playerid) return SendClientMessage(...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)