28.08.2016, 08:10
(
Last edited by Siddhant240201; 15/09/2016 at 01:35 PM.
)
sSiddhant Tutorial 1# Custom Player Messages
Ok! Today I am gonna explain you about messages which are related to players like Welcome Messages, Join Messages, Death Messages extra.For example I am taking Welcome Message
First we have to make an array where the name of the player will be stored
Quote:
new sname[MAX_PLAYER_NAME]; |
Quote:
GetPlayerName(playerid, sname, sizeof(sname)); |
Now we are gonna make a new string
Quote:
new str[24+MAX_PLAYERS_NAME]; |
Ok! Now lets format the string
Quote:
format(str, sizeof(str), "%s , Welcome to the Server", sname); |
Remember you can use as many arguments as you want. Now, I am not gonna explain you what are string as it would be off-topic.
Ok! Now lets send the message
Quote:
SendClientMessageToAll(-1, str); |
Ok! I am gonna more examples of Custom Player Messages.
Join Message
Quote:
new pname[MAX_PLAYER_NAME], string[22 + MAX_PLAYER_NAME]; GetPlayerName(playerid, pname, sizeof(pname)); format(string, sizeof(string), "%s has joined the server", pname); SendClientMessageToAll(0xAAAAAAAA, string); |
Quote:
public OnPlayerDisconnect(playerid, reason) { new pname[MAX_PLAYER_NAME], string[39 + MAX_PLAYER_NAME]; GetPlayerName(playerid, pname, sizeof(pname)); switch(reason) { case 0: format(string, sizeof(string), "%s has left the server. (Lost Connection)", pname); case 1: format(string, sizeof(string), "%s has left the server. (Leaving)", pname); case 2: format(string, sizeof(string), "%s has left the server. (Kicked)", pname); } SendClientMessageToAll(0xAAAAAAAA, string); return 1; } |