Hello There, Guest! Login or Register


OnInvionAskForHelp;...
#1
I need help with my OnPlayerConnect! Atm, when someone connects connects, it doesnt say anything! You only know that someone has connected when you look in tab!

Here is my code
Code:
public OnPlayerConnect(playerid)
{
    GameTextForPlayer(playerid,"~r~Movie~l~-~y~Maker~l~-~g~Mod",7000,5);
    SendClientMessage(playerid, COLOR_GREEN, "Please type /help to get started :)");
    return 1;
}

How can I make it so that it says: (Player Name) has connected to the server


Thanks

-InVion_
Reply
#2
add this to onplayerconnect

Code:
new string[47];
new name[24];
GetPlayerName(playerid,name,24);
format(string,sizeof(string),"%s had joined the server",name);
SendClientMessageToAll(COLOR_GREEN,string);

hope i helped  ;)
Reply
#3
Code:
public OnPlayerConnect(playerid)
{
    new pName[MAX_PLAYER_NAME];
    new string[48];
   
    GetPlayerName(playerid, pName, sizeof(pName));
   
    format(string, sizeof(string), "%s has joined the server.", pName);
    SendClientMessageToAll(0xAAAAAAAA, string);
    return 1;
}


this should work
Reply
#4
Quote:new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(string, sizeof(string), "%s has joined the server.", pName);

ya it may work, but its more easy this isnt it?:
Code:
public OnPlayerConnect(playerid){
    ...
    new pName[30];
    new string[48];
   
    GetPlayerName(playerid, pName, sizeof(pName));
   
    format(string, sizeof(string), "%s(ID:%d) has joined the server.", pName,playerid);
    SendClientMessageToAll(0xAAAAAAAA, string);
    ...
    return 1;
}
Its more easy to understand
you can replace this:
Code:
SendClientMessageToAll(0xAAAAAAAA, string);
for this:
Code:
SendClientMessageToAll(COLOR_RED, string);
If you add this to the begin of your code after the #include thingy:
Code:
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_PURPLE 0xC2A2DAAA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_GOLD 0xFFCC00FF
#define COLOR_DBLUE 0x2641FEAA
#define COLOR_BLUE 0x33AAFFFF
#define COLOR_GREEN 0x33AA33AA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xFF0000FF
#define COLOR_LIGHTRED 0xFF6347AA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_LIGHTGREEN 0x9ACD32AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_YELLOW2 0xF5DEB3AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_PURPLE 0xC2A2DAAA
#define COLOR_DBLUE 0x2641FEAA
#define COLOR_CYAN 0x00FFFFAA
#define COLOR_SYSTEM 0xEFEFF7AA
Reply
#5
Quote:    format(string, sizeof(string), "%s(ID:%d) has joined the server.", pName,playerid);

okay, but if you add that then you have to change the string size from 47 to 52 so here:

public OnPlayerConnect(playerid){
    new pName[24];
    new string[52];
 
    GetPlayerName(playerid, pName, 24
 
    format(string, sizeof(string), "%s(ID:%d) has joined the server.", pName,playerid);
    SendClientMessageToAll(0xAAAAAAAA, string);
    return 1;
}

and the pName variable is max_size is 24 not 30 and when using the max number you have to change sizeof(pName) to 24

also i added COLOR_GREEN in there because i already new that he defined it because in the first post he uses it in the message

"type /help for help"
Reply