PM help-
#1

PHP Code:
CMD:pm(playeridparams[])
{
    new 
targetidstring[258], tekst[128];
    if(
sscanf(params"us[128]"targetidtekst)) return SendClientMessage(playeridCOLOR_WHITE"{3BB9FF}use: {FFFFFF}/pm  < ID > < tekst >");
    if(
targetid == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_RED"Wrong ID");
    
format(stringsizeof(string), "[PM][IN] %s: %s"PlayerName(playerid), tekst);
    
SendClientMessage(targetidCOLOR_YELLOWstring);
    
format(stringsizeof(string), "[PM][out] %s: %s"PlayerName(targetid), tekst);
    
SendClientMessage(playeridCOLOR_REDstring);
    return 
1;

Hello.
I have problem with this command?
If i try to ingame /pm 0 Test

Its says "Wrong ID" Why? )
Reply
#2

if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Wrong ID");
Reply
#3

you might check whether you inputted correct player id and also check ifthe player is connected or not
Reply
#4

You're using sscanf version by Emmet_ or ******?
Use by Emmet_: https://sampforum.blast.hk/showthread.php?tid=570927
Test it...
Reply
#5

Quote:

if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Wrong ID");

this dosnt work /: says Wornh ID i want try by my self..
Like why i cant send myself PM?
Reply
#6

In your code you save targetid as "u", it can be a name so no "targetid = INVALID_PLAYER_ID" nor IsPlayerConnected(targetid) can slove it maybe in your sscanf version, "u" works fine with me but try to change "u" to "d"

PHP Code:
CMD:pm(playeridparams[])
{
    new 
targetidstring[258], tekst[128];
    if(
sscanf(params"ds[128]"targetidtekst)) return SendClientMessage(playeridCOLOR_WHITE"{3BB9FF}use: {FFFFFF}/pm  < ID > < tekst >");
    if(
targetid == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_RED"Wrong ID");
    
format(stringsizeof(string), "[PM][IN] %s: %s"PlayerName(playerid), tekst);
    
SendClientMessage(targetidCOLOR_YELLOWstring);
    
format(stringsizeof(string), "[PM][out] %s: %s"PlayerName(targetid), tekst);
    
SendClientMessage(playeridCOLOR_REDstring);
    return 
1;

Reply
#7

Quote:
Originally Posted by Shinja
View Post
In your code you save targetid as "u", it can be a name so no "targetid = INVALID_PLAYER_ID" nor IsPlayerConnected(targetid) can slove it, change "u" to "d"
"u" allows sscanf to search for both names and ids.
And if the id or name doesn't exist, it sets the variable as INVALID_PLAYER_ID.
So it has nothing to with "d" and "u"

https://sampforum.blast.hk/showthread.php?tid=602923
Read the specifiers section.
Reply
#8

Quote:
Originally Posted by Stinged
View Post
"u" allows sscanf to search for both names and ids.
And if the id or name doesn't exist, it sets the variable as INVALID_PLAYER_ID.
So it has nothing to with "d" and "u"

https://sampforum.blast.hk/showthread.php?tid=602923
Read the specifiers section.
I already edited my post.
But, where the hell mistake can be lol? my command have almost same syntax and working perfectly
PHP Code:
new idmess[40];
     if(
sscanf(params"us[40]"idmess)) return SendClientMessage(playerid, -1"{0008F7}USAGE: {FFFFFF}/PM ID MESSAGE");
     if(!
IsPlayerConnected(id)) return SendClientMessage(playerid0xCD0000FF"Player is not connected");
     if(
DND[id] == 1) return SendClientMessage(playerid0xCD0000FF"Player is on DND mode");
     new 
PName[24];
    
GetPlayerName(idPNamesizeof(PName));
    new 
string[100], name[24];
    
GetPlayerName(playeridnamesizeof(name));
    
format(string,sizeof(string),"{FCDF00}[PRIVATE MESSAGE] {8A887B}From %s(%d): {8C8656}%s"nameplayeridmess);
    
SendClientMessage(id, -1string);
    
format(string,sizeof(string),"{FCDF00}[PRIVATE MESSAGE] {8A887B}To %s(%d): {8C8656}%s"PNameidmess);
    
SendClientMessage(playerid, -1string); 
Reply
#9

Still need help?
Reply
#10

you try to change "u" in "i"..
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)