SA-MP Forums Archive
PM command - 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: PM command (/showthread.php?tid=578944)



PM command - KamalBa - 23.06.2015

Код:
D:\My server\gamemodes\LvG_Script.pwn(1984) : warning 202: number of arguments does not match definition
D:\My server\gamemodes\LvG_Script.pwn(1984) : warning 202: number of arguments does not match definition
D:\My server\gamemodes\LvG_Script.pwn(1986) : warning 202: number of arguments does not match definition
D:\My server\gamemodes\LvG_Script.pwn(1986) : warning 202: number of arguments does not match definition
D:\My server\gamemodes\LvG_Script.pwn(1988) : error 001: expected token: "-string end-", but found "-identifier-"
D:\My server\gamemodes\LvG_Script.pwn(1988) : error 001: expected token: "-string end-", but found "-identifier-"
D:\My server\gamemodes\LvG_Script.pwn(1988) : warning 215: expression has no effect
D:\My server\gamemodes\LvG_Script.pwn(1988) : error 001: expected token: ";", but found "-integer value-"
D:\My server\gamemodes\LvG_Script.pwn(1988) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Код:
CMD:pm(playerid, params[])
{
   new str[128], str2[128], id, adminstr[128];
   if(sscanf(params,"ds[128]", id, str2)) return SendClientMessage(playerid, COLOR_YELLOW,"USAGE: /pm [id] [message]");
   if(IsPlayerConnected(id))
   {
	   if(id != playerid)
	   {
		   if(DND[id] == 0)
		   {
		   		format(str, sizeof(str),"PM to [%d]%s: %s", id, GetPlayerName(id), str2);
		   		SendClientMessage(playerid, COLOR_YELLOW, str);
		   		format(str, sizeof(str),"PM from [%d]%s: %s", playerid, GetPlayerName(playerid), str2);
		   		SendClientMessage(id, COLOR_YELLOW, str);
		   		SendClientMessage(id, -1,"Use "COLOR_YELLOW"/rpm [message] "COLOR_WHITE"to reply to this PM");
		   		format(adminstr, sizeof(adminstr),"PM from %s[%d] to %s[%d]: %s", PlayerName2(playerid), playerid, PlayerName2(id), id, str2);
		   		MessageTo4(grey, adminstr);
		   		LastPm[id] = playerid;
		   }
		   else return SendClientMessage(playerid, red,"That player is in do not disturb mode!");
	   }
	   else return SendClientMessage(playerid, red,"You cannot PM yourself");
   }
   else return SendClientMessage(playerid, red,"Player is not connected");
   return 1;
}



Re: PM command - Hessu - 23.06.2015

Tell us line 1984, 1986 and 1988 please.
Makes it much easier for people to help you when you do not have to go through whose piece of script you pasted.


Re: PM command - KamalBa - 23.06.2015

Line 1984
Код:
format(str, sizeof(str),"PM to [%d]%s: %s", id, GetPlayerName(id), str2);
Line 1984
Код:
format(str, sizeof(str),"PM from [%d]%s: %s", playerid, GetPlayerName(playerid), str2);
Line 1988
Код:
SendClientMessage(id, -1,"Use "COLOR_YELLOW"/rpm [message] "COLOR_WHITE"to reply to this PM");



Re: PM command - KamalBa - 23.06.2015

BUMP!


Re: PM command - AndySedeyn - 23.06.2015

COLOR_YELLOW and COLOR_WHITE are not embedded colours (i.e. "{FFFFFF}" is white. Don't forget the double quotation around it when defining, that's important.).


Re: PM command - KamalBa - 23.06.2015

Код:
D:\My server\gamemodes\LvG_Script.pwn(1992) : warning 202: number of arguments does not match definition
D:\My server\gamemodes\LvG_Script.pwn(1992) : warning 202: number of arguments does not match definition
D:\My server\gamemodes\LvG_Script.pwn(1994) : warning 202: number of arguments does not match definition
D:\My server\gamemodes\LvG_Script.pwn(1994) : warning 202: number of arguments does not match definition
D:\My server\gamemodes\LvG_Script.pwn(1997) : warning 202: number of arguments does not match definition
D:\My server\gamemodes\LvG_Script.pwn(1997) : warning 202: number of arguments does not match definition
D:\My server\gamemodes\LvG_Script.pwn(1997) : warning 202: number of arguments does not match definition
D:\My server\gamemodes\LvG_Script.pwn(1997) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


8 Warnings.



Re: PM command - KamalBa - 23.06.2015

Line 1992
Код:
format(str, sizeof(str),"PM to [%d]%s: %s", id, GetPlayerName(id), str2);
Line 1994
Код:
format(str, sizeof(str),"PM from [%d]%s: %s", playerid, GetPlayerName(playerid), str2);
Line 1997
Код:
	format(adminstr, sizeof(adminstr),"PM from %s[%d] to %s[%d]: %s", GetPlayerName(playerid), playerid, GetPlayerName(id), id, str2);
Full CODE

Код:
CMD:pm(playerid, params[])
{
   new str[128], str2[128], id, adminstr[128];
   if(sscanf(params,"ds[128]", id, str2)) return SendClientMessage(playerid, COLOR_YELLOW,"USAGE: /pm [id] [message]");
   if(IsPlayerConnected(id))
   {
	   if(id != playerid)
	   {
		   if(DND[id] == 0)
		   {
		   		format(str, sizeof(str),"PM to [%d]%s: %s", id, GetPlayerName(id), str2);
		   		SendClientMessage(playerid, COLOR_YELLOW, str);
		   		format(str, sizeof(str),"PM from [%d]%s: %s", playerid, GetPlayerName(playerid), str2);
		   		SendClientMessage(id, COLOR_YELLOW, str);
		   		SendClientMessage(id, -1,"Use "cyellow"/rpm [message] "cwhite"to reply to this PM");
		   		format(adminstr, sizeof(adminstr),"PM from %s[%d] to %s[%d]: %s", GetPlayerName(playerid), playerid, GetPlayerName(id), id, str2);
		   		SendClientMessageToAll(COLOR_WHITE, adminstr);
		   		LastPm[id] = playerid;
		   }
		   else return SendClientMessage(playerid, COLOR_RED,"That player is in do not disturb mode!");
	   }
	   else return SendClientMessage(playerid, COLOR_RED,"You cannot PM yourself");
   }
   else return SendClientMessage(playerid, COLOR_RED,"Player is not connected");
   return 1;
}



Re: PM command - KamalBa - 23.06.2015

Also, when i type /pm server will closed!


Re: PM command - Hessu - 23.06.2015

Try this

pawn Код:
CMD:pm(playerid, params[])
{
   new id, str[128], str2[128], adminstr[128], YourName[24], OtherPlayerName[24];
   if(sscanf(params,"ds[128]", id, str2)) return SendClientMessage(playerid, COLOR_YELLOW,"USAGE: /pm [id] [message]");
   if(IsPlayerConnected(id))
   {
       if(id != playerid)
       {
           if(DND[id] == 0)
           {
                GetPlayerName(playerid, YourName, sizeof(YourName));
                GetPlayerName(id, OtherPlayerName, sizeof(OtherPlayerName));

                format(str, sizeof(str),"PM to [%d]%s: %s", id, OtherPlayerName, str2);
                SendClientMessage(playerid, COLOR_YELLOW, str);
                format(str, sizeof(str),"PM from [%d]%s: %s", playerid, YourName, str2);
                SendClientMessage(id, COLOR_YELLOW, str);
                SendClientMessage(id, -1,"Use {FFFF33}/rpm [message] {FFFFFF}to reply to this PM");
                format(adminstr, sizeof(adminstr),"PM from %s[%d] to %s[%d]: %s", YourName, playerid, OtherPlayerName, id, str2);
                SendClientMessageToAll(COLOR_WHITE, adminstr);
                LastPm[id] = playerid;
           }
           else return SendClientMessage(playerid, COLOR_RED,"That player is in do not disturb mode!");
       }
       else return SendClientMessage(playerid, COLOR_RED,"You cannot PM yourself");
   }
   else return SendClientMessage(playerid, COLOR_RED,"Player is not connected");
   return 1;
}



Re: PM command - Threshold - 23.06.2015

pawn Код:
CMD:pm(playerid, params[])
{
    new id, str[100];
    if(sscanf(params, "ds[100]", id, str)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /pm [id] [message]");
    if(!IsPlayerConnected(id) || id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "Player is not connected");
    if(id == playerid) return SendClientMessage(playerid, COLOR_RED, "You cannot PM yourself");
    if(!DND[id]) return SendClientMessage(playerid, COLOR_RED, "That player is in 'Do Not Disturb' mode!");
    new str2[144];
    format(str2, sizeof(str2), "PM to [%d]%s: %s", id, GetPlayerName(id), str);
    SendClientMessage(playerid, COLOR_YELLOW, str);
    format(str, sizeof(str), "PM from [%d]%s: %s", playerid, GetPlayerName(playerid), str);
    SendClientMessage(id, COLOR_YELLOW, str);
    SendClientMessage(id, -1, "Use "cyellow"/rpm [message] "cwhite"to reply to this PM");
    format(str2, sizeof(str2), "PM from %s[%d] to %s[%d]: %s", GetPlayerName(playerid), playerid, GetPlayerName(id), id, str);
    SendClientMessageToAll(COLOR_WHITE, str2); // SendClientMessageToAll? I don't think that's right...
    LastPm[id] = playerid;
    return 1;
}
If this still crashes your server, the problem is either:
DND[id]

or:
LastPm[id] = playerid;

Where 'id' is causing an out of bounds error.