send client message to all
#1

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);
         }
   }
}
Reply
#2

https://sampwiki.blast.hk/wiki/SendClientMessageToAll
Reply
#3

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

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); 
Reply
#5

https://sampwiki.blast.hk/wiki/Format
Reply
#6

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);
         }
   }

Reply
#7

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:
    {
    }

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)