OnPlayerConnect bug -
DRP - 17.01.2016
Alright I'm kinda a noob on scripting, a big one, but tell me what's wrong with this script line.
public OnPlayerConnect(playerid)
{
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"Welcome Back %s",pName);
SendClientMessage(0xFFFFFFAA,string);
return 1;
}
Re: OnPlayerConnect bug -
GeneralAref - 17.01.2016
PHP код:
new string[128];
PHP код:
GetPlayerName(playerid, pname, sizeof(pname));
Re: OnPlayerConnect bug -
DRP - 17.01.2016
Quote:
Originally Posted by GeneralAref
PHP код:
new string[128];
PHP код:
GetPlayerName(playerid, pname, sizeof(pname));
|
If posible remake the whole script lines I wrote please.
Re: OnPlayerConnect bug -
PrO.GameR - 17.01.2016
SendClientMessage(0xFFFFFFAA,string);
Here is your problem
https://sampwiki.blast.hk/wiki/SendClientMessage
Syntax is SendClientMessage(playerid, color, const message[]);
And you don't have any playerid to send the client msg to, other than that your code works just fine.
Re: OnPlayerConnect bug -
DRP - 17.01.2016
Quote:
Originally Posted by PrO.GameR
SendClientMessage(0xFFFFFFAA,string);
Here is your problem
https://sampwiki.blast.hk/wiki/SendClientMessage
Syntax is SendClientMessage(playerid, color, const message[]);
And you don't have any playerid to send the client msg to, other than that your code works just fine.
|
Thanks for the help,
But recently I've tried to remake the message system for only admins, whoever joins, leaves or times out, a message is sent to admins, and I failed on this one too, seems like I'm in need of your help.
So this doesn't work.
public OnPlayerDisconnect(playerid, reason)
{
new pname[MAX_PLAYER_NAME], string[39 + MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
switch(reason)
{
if (IsPlayerConnected(i))
{
if (IsPlayerAdmin(i))
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);
}
SendClientMessage(playerid, -1, params);
return 1;
}
EDIT: I'm researching on ****** and everything I find useful like a 1000 times to make it work, but when I am stuck on something, I'm just posting here for help.
Re: OnPlayerConnect bug -
d1git - 17.01.2016
This should work.
PHP код:
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);
}
for(new i,j=GetPlayerPoolSize();i<=j;i++) {
if(!IsPlayerConnected(i) || IsPlayerAdmin(i)) continue;
SendClientMessage(i, -1, string);
}
return 1;
}
EDIT: Fixed a typo, my bad.
Re: OnPlayerConnect bug -
DRP - 17.01.2016
Quote:
Originally Posted by d1git
This should work.
PHP код:
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);
}
for(new i,j=GetPlayerPoolSize();i<=j;i++) {
if(!IsPlayerConnected(i) || IsPlayerAdmin(i)) continue;
SendClientMessage(i, -1, string);
}
return 1;
}
EDIT: Fixed a typo, my bad.
|
That works, I may thank you by increasing your reputation skills
P.S - after 24 hrs as I'm out of them.