Help please, lacks forward declaration..
#1

Код:
C:\Documents and Settings\Owner\Desktop\samp03csvr_win32\gamemodes\Hillside.htm(28025) : warning 235: public function lacks forward declaration (symbol "OnPlayerPrivmsg")
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.
Код:
public OnPlayerPrivmsg(playerid, recieverid, text[])
{
	return 0;
}
Reply
#2

Remove the entire function, it was implemented in older versions of SA-MP and removed as of 0.3a.
Reply
#3

Will i still be able to pm though?
Reply
#4

Quote:
Originally Posted by getty154
Посмотреть сообщение
Will i still be able to pm though?
You wouldn't be able to anyway, the callback is empty and the function for /pm to fire that callback was removed in 0.3a.
Reply
#5

Ahh, thankyou, whilst we're talking here, could you help me create a /pm function? Thankyou.
Reply
#6

Using sscanf and zcmd:

pawn Код:
CMD:pm(playerid, params[]) {
    new
        szPlayerName[MAX_PLAYER_NAME], // Create a string to store a player name
        szFormatString[120], // Create a string to format the message, 64 for the message and 24 for MAX_PLAYER_NAME
        iPlayerID, // Create a variable for the returned player ID to be assigned to
        szMessage[64]; // And for the message once split by sscanf

    // Split the input that the user provided, split it in to the two variables created above.
    if(sscanf(params, "us[64]", iPlayerID, szMessage)) return SendClientMessage(playerid, 0xFFFF00FF, "Incorrect usage! The usage is: /pm [playerid/name] [message]");
   
    // Check whether the player is connected or not, sscanf returns INVALID_PLAYER_ID if it doesn't find a name/id connected with the criteria provided
    if(iPlayerID == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFFFF00FF, "That player is not connected");
   
    // Get the name of the player who is sending the message, format it in a string with the message and send it to the player who is to be sent the PM
    GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
    format(szFormatString, sizeof(szFormatString), "Message from %s: %s", szPlayerName, szMessage);
    SendClientMessage(iPlayerID, 0xFFFF00FF, szFormatString);
   
    // Send a message back to the person who sent it, to confirm that the message was sent
    // Get the player's name who it was sent to, format that message and send it
    GetPlayerName(iPlayerID, szPlayerName, MAX_PLAYER_NAME);
    format(szFormatString, sizeof(szFormatString), "You sent this message to %s: %s", szPlayerName, szMessage);
    SendClientMessage(playerid, 0xFFFF00FF, szFormatString);
   
    // We're done here now. Let's return 1.
    return 1;
}
Untested, but it should work.
Reply
#7

It worked, Thanks
Reply
#8

TESTED AND WORKS!!!


Alright.
I will use ZCMD. You'll need the ZCMD include. The sscanf2 include as well.
You can easily find them on the forum.

Lets start with making the command.

pawn Код:
COMMAND:pm(playerid,params[])
{

return 1;
}
That's how we start making the command.

Now we need this in our command:
pawn Код:
new id,string[100],text[100],playername1[MAX_PLAYER_NAME],playername2[MAX_PLAYER_NAME];
The id is the person we'll send it to.
the string is the message you and the player will get.
The text is the text you'll send.

Now we're going to use the sscanf fuction.

pawn Код:
if(sscanf(params,"us[100]",id,text)) return SendClientMessage(playerid,COLOR,"USAGE:/pm playerid text");
If you forget the [100] after the S you'll get a warning in your server.exe, so don't forget it.

Now we want to check if the player is connected.

pawn Код:
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR,"Player not connected");
We don't use playerid at the !IsPlayerConnected(id)) because we don't want to know if the player that uses the command is online.

Now what will happen when the player is connected and you used the cmd on a good way?

pawn Код:
else
{
GetPlayerName(playerid,playername1,sizeof(playername1));
GetPlayerName(id,playername2,sizeof(playername2));
format(string,sizeof(string),"PM from %s: %s",playername1,text);
SendClientMessage(id,COLOR,string);
format(string,sizeof(string),"PM to %s: %s",playername2,text);
SendClientMessage(playerid,COLOR,string);
}
Now that's done.

The whole code:

pawn Код:
COMMAND:pm(playerid,params[])
{
new id,string[100],text[100],playername1[MAX_PLAYER_NAME],playername2[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername1,sizeof(playername1));
GetPlayerName(id,playername2,sizeof(playername2));
if(sscanf(params,"us[100]",id,text)) return SendClientMessage(playerid,COLOR,"USAGE:/pm playerid text");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR,"Player not connected");
else
{
GetPlayerName(playerid,playername1,sizeof(playername1));
GetPlayerName(id,playername2,sizeof(playername2));
format(string,sizeof(string),"PM from %s: %s",playername1,text);
SendClientMessage(id,COLOR,string);
format(string,sizeof(string),"PM to %s: %s",playername2,text);
SendClientMessage(playerid,COLOR,string);
}
return 1;
}
I hope I've explained this well enough.

Good luck

EDIT:
Damn you calgon!! xD
You were faster. LOl
Reply
#9

Too late, and your example isn't really efficient, you've wasted 24 cells (96 bytes) creating another variable for the other players name, and you're using IsPlayerConnected instead of a constant (which would be less efficient), furthermore you haven't used sufficient indentation.

But kudos on explaining your example a little bit better than mine.
Reply
#10

Hmm yes, that's something I still don't understand. About how many cells I should use . xD

Thanks.

But.
Could you maybe explain me that part? About the cells?.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)