SA-MP Forums Archive
send client message to all - 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: send client message to all (/showthread.php?tid=625734)



send client message to all - Lukasz56 - 05.01.2017

So im kinda newbie at scripting , i made a simple tp cmd which works good but only thing that i want is that when player chooses a city it would send a message to all where he teleported how do i do it?

he is my OnDialogResponse
Код:
    if(dialogid == 741)
   {
      if(response)
      {
       if(listitem == 0)
         {
            SetPlayerPos(playerid,-1984.4254,137.7499,27.6875);
            GameTextForPlayer(playerid, "~y~San Fierro (SF)", 4000, 5);
            
         }
         else if(listitem == 1)
         {
            SetPlayerPos(playerid,1479.2385,-1672.3132,14.0469);
            GameTextForPlayer(playerid, "~y~Los Santos (LS)", 4000, 5);
            
         }
         else if(listitem == 2)
         {
            SetPlayerPos(playerid,2026.7106,1342.5176,10.8203);
            GameTextForPlayer(playerid, "~y~Las Venturas (LV)", 4000, 5);
         }
   }
}



Re: send client message to all - Bolex_ - 05.01.2017

https://sampwiki.blast.hk/wiki/SendClientMessageToAll


Re: send client message to all - Lukasz56 - 05.01.2017

Quote:
Originally Posted by Scripter18
Посмотреть сообщение
i see, but how do i show player's name who teleported?


Re: send client message to all - saffierr - 05.01.2017

You will have to loop through all the players with:
PHP код:
for (new 0GetPlayerPoolSize (); <= ji++) 
and then send the gametextforplayer message

To get a pplayer's name:
PHP код:
new pName [MAX_PLAYER_NAME];
GetPlayerName (playeridpNameMAX_PLAYER_NAME); 



Re: send client message to all - Bolex_ - 05.01.2017

https://sampwiki.blast.hk/wiki/Format


Respuesta: send client message to all - Whillyrez - 05.01.2017

PHP код:
if(dialogid == 741)
   {
      if(
response)
      {
       new 
name[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME];
       
GetPlayerName(playeridnamesizeof(name));
       if(
listitem == 0)
         {
            
SetPlayerPos(playerid,-1984.4254,137.7499,27.6875);
            
GameTextForPlayer(playerid"~y~San Fierro (SF)"40005);
            
format(stringsizeof(string), "%s have gone to San Fierro"name);
            
SendClientMessageToAll(-1string);
            
         }
         else if(
listitem == 1)
         {
            
SetPlayerPos(playerid,1479.2385,-1672.3132,14.0469);
            
GameTextForPlayer(playerid"~y~Los Santos (LS)"40005);
            
format(stringsizeof(string), "%s have gone to Los Santos"name);
            
SendClientMessageToAll(-1string);
            
         }
         else if(
listitem == 2)
         {
            
SetPlayerPos(playerid,2026.7106,1342.5176,10.8203);
            
GameTextForPlayer(playerid"~y~Las Venturas (LV)"40005);
            
format(stringsizeof(string), "%s have gone to Las Venturas"name);
            
SendClientMessageToAll(-1string);
         }
   }




Re: send client message to all - Logic_ - 05.01.2017

Quote:
Originally Posted by saffierr
Посмотреть сообщение
You will have to loop through all the players with:
PHP код:
for (new 0GetPlayerPoolSize (); <= ji++) 
and then send the gametextforplayer message

To get a pplayer's name:
PHP код:
new pName [MAX_PLAYER_NAME];
GetPlayerName (playeridpNameMAX_PLAYER_NAME); 
Use GameTextForAll.

--

Above reply;

Use switch, it's faster and optimized, as well as easier to read. Add +1 in the Name variable new Name[MAX_PLAYER_NAME + 1];

PHP код:
switch(listitem)
{
    case 
0:
    {
    }
    case 
1:
    {
    }
    case 
2:
    {
    }