Bug with PM
#1

When someone sent me a PM, I sent him 3 times, not as they should, 1. This happened after I put JunkBuster 11 and 0.3d

Edit: and I remove AllowAdminTeleport(1);

Код:
	if(strcmp(cmd, "/pm", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "Type: /pmtoplayer [ID] [text]");
				return 1;
			}
			giveplayerid = strval(tmp);
			if (IsPlayerConnected(giveplayerid))
			{
			    if(giveplayerid!= INVALID_PLAYER_ID)
			    {
					GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
					new length = strlen(cmdtext);
					while ((idx < length) && (cmdtext[idx] <= ' '))
					{
						idx++;
					}
					new offset = idx;
					new result[256];
					while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
					{
						result[idx - offset] = cmdtext[idx];
						idx++;
					}
					result[idx - offset] = EOS;
					if(!strlen(result))
					{
						SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /pm [playerid/PartOfName] [text]");
						return 1;
					}
					for(new i = 0; i < MAX_PLAYERS; i++)
					{
					    if(IsPlayerConnected(i))
					    {
							if(PlayerInfo[i][aigm] == 1)
							{
								format(string, sizeof(string), "* Pm from %s(ID: %d): %s", PlayerName(playerid), playerid, (result));
								SendClientMessage(giveplayerid, COLOR_YELLOW, string);
							}
						}
					}
					format(string, sizeof(string), "* Pm for %s(ID: %d): %s", giveplayer, giveplayerid, (result));
					SendClientMessage(playerid,  COLOR_YELLOW, string);
					return 1;
				}
			}
		}
		return 1;
	}
Reply
#2

Quote:
Originally Posted by Join7
Посмотреть сообщение
When someone sent me a PM, I sent him 3 times, not as they should, 1. This happened after I put JunkBuster 11 and 0.3d

Edit: and I remove AllowAdminTeleport(1);

Код:
	if(strcmp(cmd, "/pm", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "Type: /pmtoplayer [ID] [text]");
				return 1;
			}
			giveplayerid = strval(tmp);
			if (IsPlayerConnected(giveplayerid))
			{
			    if(giveplayerid!= INVALID_PLAYER_ID)
			    {
					GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
					new length = strlen(cmdtext);
					while ((idx < length) && (cmdtext[idx] <= ' '))
					{
						idx++;
					}
					new offset = idx;
					new result[256];
					while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
					{
						result[idx - offset] = cmdtext[idx];
						idx++;
					}
					result[idx - offset] = EOS;
					if(!strlen(result))
					{
						SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /pm [playerid/PartOfName] [text]");
						return 1;
					}
					for(new i = 0; i < MAX_PLAYERS; i++)
					{
					    if(IsPlayerConnected(i))
					    {
							if(PlayerInfo[i][aigm] == 1)
							{
								format(string, sizeof(string), "* Pm from %s(ID: %d): %s", PlayerName(playerid), playerid, (result));
								SendClientMessage(giveplayerid, COLOR_YELLOW, string);
							}
						}
					}
					format(string, sizeof(string), "* Pm for %s(ID: %d): %s", giveplayer, giveplayerid, (result));
					SendClientMessage(playerid,  COLOR_YELLOW, string);
					return 1;
				}
			}
		}
		return 1;
	}
The problem come from the for loop. You don't need a for loop, because you must send the PM only for the giveplayerid player .

PHP код:
    if(strcmp(cmd"/pm"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp))
            {
                
SendClientMessage(playeridCOLOR_GRAD2"Type: /pmtoplayer [ID] [text]");
                return 
1;
            }
            
giveplayerid strval(tmp);
            if (
IsPlayerConnected(giveplayerid))
            {
                
GetPlayerName(giveplayeridgiveplayersizeof(giveplayer));
                new 
length strlen(cmdtext);
                while ((
idx length) && (cmdtext[idx] <= ' '))
                {
                    
idx++;
                }
                new 
offset idx;
                new 
result[256];
                while ((
idx length) && ((idx offset) < (sizeof(result) - 1)))
                {
                    
result[idx offset] = cmdtext[idx];
                    
idx++;
                }
                
result[idx offset] = EOS;
                if(!
strlen(result))
                {
                    
SendClientMessage(playeridCOLOR_GRAD2"USAGE: /pm [playerid] [text]");
                    return 
1;
                }
                if(
PlayerInfo[giveplayerid][aigm] == 1)
                {
                    
format(stringsizeof(string), "* Pm from %s(ID: %d): %s"PlayerName(playerid), playerid, (result));
                    
SendClientMessage(giveplayeridCOLOR_YELLOWstring);
                }
                
format(stringsizeof(string), "* Pm for %s(ID: %d): %s"giveplayergiveplayerid, (result));
                
SendClientMessage(playerid,  COLOR_YELLOWstring);
                return 
1;
            }
        }
        return 
1;
    } 
*NOTE: Take attention at sintax 2nd parameter ( you use strval, not ReturnUser ; so you must give the parameter as an integer ).
Reply
#3

same
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)