SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 02/08/2016, 02:32 PM   #1
b0b
Big Clucker
 
Join Date: Dec 2012
Posts: 136
Reputation: 7
Default PM help-

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? )
b0b is offline   Reply With Quote
Old 02/08/2016, 02:32 PM   #2
J0sh...
Banned
 
Join Date: Aug 2014
Location: Hamburger
Posts: 1,276
Reputation: 461
Default Re: PM help-

if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Wrong ID");
J0sh... is offline   Reply With Quote
Old 02/08/2016, 02:33 PM   #3
SyS
High-roller
 
SyS's Avatar
 
Join Date: Oct 2015
Posts: 1,939
Reputation: 504
Default Re: PM help-

you might check whether you inputted correct player id and also check ifthe player is connected or not
SyS is offline   Reply With Quote
Old 02/08/2016, 02:34 PM   #4
F1N4L
High-roller
 
F1N4L's Avatar
 
Join Date: Jun 2013
Posts: 2,723
Reputation: 260
Default Re: PM help-

You're using sscanf version by Emmet_ or ******?
Use by Emmet_: http://forum.sa-mp.com/showthread.php?t=570927
Test it...
F1N4L is offline   Reply With Quote
Old 02/08/2016, 02:39 PM   #5
b0b
Big Clucker
 
Join Date: Dec 2012
Posts: 136
Reputation: 7
Default Re: PM help-

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?
b0b is offline   Reply With Quote
Old 02/08/2016, 06:34 PM   #6
Shinja
Gangsta
 
Shinja's Avatar
 
Join Date: Jan 2016
Posts: 972
Reputation: 107
Default Re: PM help-

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;

Shinja is offline   Reply With Quote
Old 02/08/2016, 06:35 PM   #7
Stinged
High-roller
 
Join Date: Feb 2013
Posts: 1,571
Reputation: 187
Default Re: PM help-

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"

http://forum.sa-mp.com/showthread.php?t=602923
Read the specifiers section.
Stinged is offline   Reply With Quote
Old 02/08/2016, 06:37 PM   #8
Shinja
Gangsta
 
Shinja's Avatar
 
Join Date: Jan 2016
Posts: 972
Reputation: 107
Default Re: PM help-

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"

http://forum.sa-mp.com/showthread.php?t=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); 
Shinja is offline   Reply With Quote
Old 02/08/2016, 08:11 PM   #9
Fantje
Huge Clucker
 
Join Date: Dec 2014
Posts: 393
Reputation: 9
Default Re: PM help-

Still need help?
__________________
Fantje is offline   Reply With Quote
Old 03/08/2016, 01:18 AM   #10
AlexPalermitano97
Big Clucker
 
Join Date: Jan 2016
Posts: 151
Reputation: 0
Default Re: PM help-

you try to change "u" in "i"..
AlexPalermitano97 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 01:20 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.