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



SendMessageToPlayer - misho1 - 06.12.2011

What Is Wrong With This?
pawn Код:
SendPlayerMessageToPlayer(Body_Guard,senderid,"I Need Body Guard!");
Код:
E:\Freeroam World\filterscripts\Jobs.pwn(98) : error 035: argument type mismatch (argument 1)



Re: SendMessageToPlayer - JamesC - 06.12.2011

There's something wrong with the first parameter, can you show us where you change the value the variable Body_Guard?


Re: SendMessageToPlayer - misho1 - 06.12.2011

pawn Код:
new Body_Guard[MAX_PLAYERS];



Re: SendMessageToPlayer - JamesC - 06.12.2011

Quote:
Originally Posted by misho1
Посмотреть сообщение
pawn Код:
new Body_Guard[MAX_PLAYERS];
Yeah, exactly. Body_Guard is an array whereas the first parameter in SendPlayerMessageToPlayer should be an integer, usually playerid. What exactly are you trying to achieve with this?


Re: SendMessageToPlayer - jamesbond007 - 06.12.2011

pawn Код:
SendPlayerMessageToPlayer(Body_Guard[playerid],senderid,"I Need Body Guard!");
try this


Re: SendMessageToPlayer - misho1 - 07.12.2011

Quote:
Originally Posted by JamesC
Посмотреть сообщение
Yeah, exactly. Body_Guard is an array whereas the first parameter in SendPlayerMessageToPlayer should be an integer, usually playerid. What exactly are you trying to achieve with this?
I Am Making Jobs FS And I Want Make /NeedBG Command For Any 1 Want Body Guard,Send Message To All Body Guard That Some One Want BG
pawn Код:
new Body_Guard[MAX_PLAYERS];
    if (strcmp("/NeedBG", cmdtext, true, 10) == 0)
    {
    if(GetPlayerMoney(playerid) < 500) return SendClientMessage(playerid,red,"You Need 500$ To Send This Message");
    SendPlayerMessageToPlayer(Body_Guard,senderid,"I Need Body Guard!");
    GivePlayerMoney(playerid,-500);
    return 1;
    }



Re: SendMessageToPlayer - [ABK]Antonio - 08.12.2011

pawn Код:
new Body_Guard[MAX_PLAYERS];
when a player chooses to be a body guard...set their Body_Guard[playerid] to 1 then;
pawn Код:
for(new b; b < MAX_PLAYERS; b++)
{
    SendPlayerMessageToPlayer(Body_Guard[b], senderid,"I need a bodyguard!");
}



Re: SendMessageToPlayer - Rob_Maate - 08.12.2011

The above won't work.
Loop through every ID and at each loop check if the player is actually a bodyguard before sending the message.

pawn Код:
for(new b=0; b<MAX_PLAYERS; b++)
{
  if(Body_Guard[b] != 0) SendMessageToPlayer(Body_Guard[b]. senderid, "I need a bodyguard!");
}



Re: SendMessageToPlayer - misho1 - 08.12.2011

Quote:
Originally Posted by [ABK]Antonio
Посмотреть сообщение
pawn Код:
new Body_Guard[MAX_PLAYERS];
when a player chooses to be a body guard...set their Body_Guard[playerid] to 1 then;
pawn Код:
for(new b; b < MAX_PLAYERS; b++)
{
    SendPlayerMessageToPlayer(Body_Guard[b], senderid,"I need a bodyguard!");
}
Код:
E:\Freeroam World\filterscripts\Jobs.pwn(99) : error 017: undefined symbol "senderid"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Quote:
Originally Posted by Rob_Maate
Посмотреть сообщение
The above won't work.
Loop through every ID and at each loop check if the player is actually a bodyguard before sending the message.

pawn Код:
for(new b=0; b<MAX_PLAYERS; b++)
{
  if(Body_Guard[b] != 0) SendMessageToPlayer(Body_Guard[b]. senderid, "I need a bodyguard!");
}
Код:
                 
E:\Freeroam World\filterscripts\Jobs.pwn(99) : error 017: undefined symbol "SendMessageToPlayer"
E:\Freeroam World\filterscripts\Jobs.pwn(99) : error 029: invalid expression, assumed zero
E:\Freeroam World\filterscripts\Jobs.pwn(99) : error 017: undefined symbol "senderid"
E:\Freeroam World\filterscripts\Jobs.pwn(99) : fatal error 107: too many error messages on one line

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


4 Errors.



Re: SendMessageToPlayer - [ABK]Antonio - 08.12.2011

pawn Код:
new str[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
for(new b; b<MAX_PLAYERS; b++)
{
    format(str, sizeof(str), "{00CCCC}%s {FFFFFF}needs a bodyguard!", name);
    SendClientMessage(Body_Guard[b],0xFFFFFFAA, str);
}