Seperate Msgs For Virtual Worlds
#1

How would I go about making separate server messages for different virtual worlds? I would be using like the standard announcement messages. Which works fine, but don't know where to start for doing seperate ones for different worlds. :/
Reply
#2

pawn Код:
for(new i; i <= MAX_PLAYERS; i++)
{
    if(IsPlayerConnected(i)) {
        if(GetPlayerVirtualWorld(i) == 0) {
            SendClientMessage(i, COLOR_GREEN, "This message will be sent to everyone in virtual world 0!");
        }
    }
}
Reply
#3

pawn Код:
stock SendClientMessageToWorld(color, msg[], worldid)
{
  for(new i; i < MAX_PLAYERS; i++)
  {
    if(!IsPlayerConnected(i) || GetPlayerVirtualWorld(i) != worldid) continue;
    SendClientMessage(i, color, msg);
  }
}
Damn Conroy pwnt me
Reply
#4

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
Damn Conroy pwnt me
As usual.
Reply
#5

Thanks for the response guys. Sry, but using this for example how would it work using the above code?

http://pastebin.com/aV8PMN5L
Reply
#6

pawn Код:
enum AnnountmentStructure
{
    AnnountmentMessage[128],
    Color,
    VirtualWorld
}
pawn Код:
new Announcements[][AnnountmentStructure] =
{
    {"MESSAGE 1", COLOR_RED, 1},
    {"MESSAGE 2", COLOR_RED, 1},
    {"MESSAGE 3", COLOR_RED, 1},
    {"MESSAGE 4", COLOR_RED, 2},
    {"MESSAGE 5", COLOR_RED, 2},
    {"MESSAGE 6", COLOR_RED, 2}
};
pawn Код:
public GlobalAnnouncement()
{
    new RandMsg = random(sizeof(Announcements));
    for(new i; i <= MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i)) {
            if(GetPlayerVirtualWorld(i) == Announcements[RandMsg][VirtualWorld]) {
                SendClientMessage(i, Announcements[RandMsg][Color], Announcements[RandMsg][AnnouncementMessage]);
            }
        }
    }
    return 1;
}
Reply
#7

Thanks alot Conroy, I appreciate it.
Reply
#8

No problem, here to help.
Reply
#9

Just a simple public to send messages to the selected world you wish.


pawn Код:
forward SendClientMessageToAllInVirtualWorld(string[],color,worldid);

public SendClientMessageToAllInVirtualWorld(string[],color,worldid)
{
    for(new j=0; j<MAX_SERVER_SLOTS; j++)
    {
        if(IsPlayerConnected(j) && GetPlayerVirtualWorld(j) == worldid)
        {
                SendClientMessage(j,color,string);
        }
    }
}
E.G: SendClientMessageToVirtualWorld("This will send to virtual world 2",2,COLOR_RED)
Reply
#10

"A simple stock"

You're creating a new public callback XD

BTW, why first the MSG, then the world id, then the color?

SendClientMessage(playerid, color, msg[])
compared to
SendClientMessageToWorld(msg[], worldid, color)
Doesn't makes sense.
Reply
#11

I was doing a stock, then relised it should be a public. But forgot to change the word stock to public.

Ive fixed it anyways now.
Reply
#12

Hiddos way is better if you are planning to use it for cmds or other things, but seems like conroy's is better for what you looking for
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)