How can i do this? (random word in the connect message)
#1

Heres what i got..

Код:
	new stringsys [128];
	new pName[MAX_PLAYER_NAME];
   	GetPlayerName(playerid, pName, sizeof(pName));
	format(stringsys, sizeof(stringsys), "[SYSTEM] Your Majesty %s has connected ", pName);
	SendClientMessageToAll(COLOR_YELLOW, stringsys);
Now what i want to do is change "Your Majesty" into a random phrase defined at the top of the script. But im not sure of how to go about this, i tried creating a random float with different phrases in it, but im unsure of how to actually get the phrases into the above line. Could someone possibly help me out with this?
Reply
#2

pawn Код:
new RandomMSG[][] =
{
    "You majesty %s has connected!",
    "Welcome king or queen, %s!",
    "The master has connected. Say hi to %s."
};

public OnPlayerConnect(playerid)
{
    new randMSG = random(sizeof(RandomMSG)); //calculates the size of RandomMSG (which is 3)
    GetPlayerName(playerid, pName, sizeof(pName));
    format(string,sizeof(string),"%s",pName,playerid);
    SendClientMessageToAll(0x33CCFFAA, RandomMSG[randMSG]);    // Replace the color with your defined color.
    return 1;
}
Try this I guess...
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)