SA-MP Forums Archive
Message Duplicating for PlayerID's other than 0. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Message Duplicating for PlayerID's other than 0. (/showthread.php?tid=530354)



Message Duplicating for PlayerID's other than 0. - gtasarules14 - 06.08.2014

Hi, I am have a bit of trouble with my report command. When someone reports a player, the message duplicates to other players who are admin, if you do have ID 0, it does not duplicate for you. If you have an ID over 0 and you are admin, it duplicates the message.

Picture.


Code for the report command.
pawn Код:
CMD:report(playerid, params[])
    {
     new pName[MAX_PLAYER_NAME], aName[MAX_PLAYER_NAME], str[128], reason, iD;
     if(PlayerInfo[playerid][pReport] > 0) return SendClientMessage(playerid, -1, "You have already reported someone!");
     if(sscanf(params, "us[128]", iD, reason)) return SendClientMessage(playerid, -1, "Usage: /report [id] [reason]");
     if(iD == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "That player is not connected!");
     PlayerInfo[playerid][pReport] +=1;
     GetPlayerName(playerid, pName, sizeof(pName));
     GetPlayerName(iD, aName, sizeof(aName));
     for(new i= 0; i < MAX_PLAYERS; i++)
     {
        if(IsPlayerConnected(i))
        {
           new zName[MAX_PLAYER_NAME];
           GetPlayerName(i, zName, sizeof(zName));
           if(PlayerInfo[i][pAdmin] > 0)
           {
            new str35[128];
            format(str, sizeof(str), "(( [REPORT] %s(%d) has reported %s(%d). [Reason]:%s ))", pName,playerid, aName,iD, reason);
            format(str35, sizeof(str35),"Type /acceptreport %d to accept the Report",playerid);
            SendClientMessage(i,ORANGE, str);
            SendClientMessage(i,ORANGE, str35);
           }
        }
    }
    return 1;
   }
All suggestions are appreciated, thanks


Re: Message Duplicating for PlayerID's other than 0. - Blademaster680 - 06.08.2014

Try use this function.
Код:
stock SendClientMessageToAdmins(color,string[],level)
{
	foreach(Player, i)
	{
	    if(!IsPlayerConnected(i)) return 1;
		if(pInfo[i][pAdminLevel] >= level)
		{
			SendClientMessage(i, color, string);
		}
	}
	return 1;
}
Then you dont need to run the loop everytime. just use: SendClientMessage(ORANGE, str, 1);


Re: Message Duplicating for PlayerID's other than 0. - ViniBorn - 06.08.2014

Try this
pawn Код:
CMD:report(playerid, params[])
{
    if(PlayerInfo[playerid][pReport] > 0) return SendClientMessage(playerid, -1, "You have already reported someone!");

    new reason[64], iD;
    if(sscanf(params, "us[64]", iD, reason)) return SendClientMessage(playerid, -1, "Usage: /report [id] [reason]");
    if(iD == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "That player is not connected!");

    PlayerInfo[playerid][pReport] ++;
    new pName[MAX_PLAYER_NAME], aName[MAX_PLAYER_NAME], str[128], str35[50];
    GetPlayerName(playerid, pName, sizeof(pName));
    GetPlayerName(iD, aName, sizeof(aName));
    format(str, sizeof(str), "(( [REPORT] %s(%d) has reported %s(%d). [Reason]:%s ))", pName,playerid, aName,iD, reason);
    format(str35, sizeof(str35),"Type /acceptreport %d to accept the Report",playerid);
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(PlayerInfo[i][pAdmin] > 0)
            {
                SendClientMessage(i,ORANGE, str);
                SendClientMessage(i,ORANGE, str35);
            }
        }
    }
    return 1;
}



Re: Message Duplicating for PlayerID's other than 0. - gtasarules14 - 06.08.2014

Thanks guys for the responses , I have fixed it now, thanks


Re: Message Duplicating for PlayerID's other than 0. - Blademaster680 - 06.08.2014

No problem