
public OnPlayerConnect(playerid)
{
new pName[24];
new str[128];
GetPlayerName(playerid, pName, 24);
format(str, 128, "%s has joined the server", pName);
SendClientMessageToAll(COLOR_LIGHTGREEN, str);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new pName[24];
new str[128];
GetPlayerName(playerid, pName, 24);
switch(reason)
{
case 0: format(str, 128, "%s has left the server. (Timeout)", pName);
case 1: format(str, 128, "%s has left the server. (Leaving)", pName);
case 2: format(str, 128, "%s has left the server. (Kicked)", pName);
case 3: format(str, 128, "%s has left the server. (Banned)", pName);
}
SendClientMessageToAll(COLOR_GREY, str);
return 1;
}
C:\Users\PUZI\Desktop\RP\gamemodes\rp-main.pwn(138) : error 017: undefined symbol "reason" Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 1 Error.

|
Originally Posted by Puzi
Hello, I am adding OnPlayerConnect and OnPlayerDisconnect messages, but I have a slight question about the nick formatting. A player will join with an RP nick for example John_Epic and when he connects, it has to say ''John Epic has joined the server'' without the underline. Is it possible? If yes, how?
|
stock PlayerNameEx(playerid) // credits to the creator (i'm not sure who's the original creator).
{
new
playername[MAX_PLAYER_NAME];
strmid(playername, PlayerName(playerid), 0, strlen(PlayerName(playerid)), MAX_PLAYER_NAME);
for(new i = 0; i < MAX_PLAYER_NAME; i++)
{
if(playername[i] == '_') playername[i] = ' ';
}
return playername;
}
stock PlayerName(playerid)
{
new
playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
return playername;
}
public OnPlayerConnect(playerid)
{
IsLogged[playerid] = 0;
SendClientMessage(playerid, 0xFFFFFFFF, "Welcome to BETA RP");
SendClientMessage(playerid, 0xFFFFFFFF, "Type /cmd for a list of commands");
new pName[24];
new str[128];
GetPlayerName(playerid, pName, 24);
format(str, 128, "|| San Andreas Customs Office || %s has joined the server.", pName);
SendClientMessageToAll(COLOR_LIGHTGREEN, str);
return 1;
}
public OnPlayerDisconnect(playerid)
{
IsLogged[playerid] = 0;
new pName[24];
new str[128];
GetPlayerName(playerid, pName, 24);
switch(reason)
{
case 0: format(str, 128, "|| San Andreas Customs Office || %s has left the server. (Timeout)", pName);
case 1: format(str, 128, "|| San Andreas Customs Office || %s has left the server. (Leaving)", pName);
case 2: format(str, 128, "|| San Andreas Customs Office || %s has left the server. (Kicked/Banned)", pName);
}
SendClientMessageToAll(COLOR_GREY, str);
return 1;
}
|
Originally Posted by Don Correlli
This code compiles just great for me, i don't see a reason why the reason could be undefined + kick and ban reasons are using the same ID, that's 2.
|
forward OnPlayerDisconnect(playerid);
public OnPlayerDisconnect(playerid, reason)
{
SendDeathMessage(INVALID_PLAYER_ID, playerid, 201);
new string[128];
switch (reason)
{
case 0:
{
GetPlayerName(playerid, playername, sizeof(playername));
format(string,sizeof(string), "*** %s has left the server (Timeout).", playername);
SendClientMessageToAll(COLOR_GREY, string);
}
case 1:
{
GetPlayerName(playerid, playername, sizeof(playername));
format(string,sizeof(string), "*** %s has left the server (Leaving).", playername);
SendClientMessageToAll(COLOR_GREY, string);
}
case 2:
{
GetPlayerName(playerid, playername, sizeof(playername));
format(string,sizeof(string), "*** %s has left the server (Kicked).", playername);
SendClientMessageToAll(COLOR_GREY, string);
}
}
return 1;
}
C:\Users\PUZI\Desktop\RP\gamemodes\rp-main.pwn(136) : error 017: undefined symbol "reason" C:\Users\PUZI\Desktop\RP\gamemodes\rp-main.pwn(140) : error 017: undefined symbol "playername" C:\Users\PUZI\Desktop\RP\gamemodes\rp-main.pwn(140) : error 017: undefined symbol "playername" C:\Users\PUZI\Desktop\RP\gamemodes\rp-main.pwn(140) : error 029: invalid expression, assumed zero C:\Users\PUZI\Desktop\RP\gamemodes\rp-main.pwn(140) : fatal error 107: too many error messages on one line Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 5 Errors.
|
Originally Posted by Puzi
I have made it correct in the above code... But still get the error.
|
public OnPlayerDisconnect(playerid)
public OnPlayerDisconnect(playerid, reason)
|
Originally Posted by Don Correlli
Quote:
pawn Код:
|
|
Originally Posted by Puzi
Actually, I have tested that, and I still get the underdash (_) when a player connects.
![]() |
new
myArray[48];
format(myArray, sizeof(myArray), "%s connected.", PlayerNameEx(playerid));
SendClientMessage(playerid, 0xFFFFFFAA, myArray);
public OnPlayerConnect(playerid)
{
// str defined here
IsLogged[playerid] = 0;
SendClientMessage(playerid, 0xFFFFFFFF, "Blablabla...");
new
myArray[48];
format(myArray, sizeof(myArray), "%s connected.", PlayerNameEx(playerid));
SendClientMessageToAll(playerid, COLOR_LIGHTGREEN, myArray);
return 1;
}

