OnPlayerConnect bug
#1

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;
}
Reply
#2

PHP код:
new string[128]; 
PHP код:
GetPlayerName(playeridpnamesizeof(pname)); 
Reply
#3

Quote:
Originally Posted by GeneralAref
Посмотреть сообщение
PHP код:
new string[128]; 
PHP код:
GetPlayerName(playeridpnamesizeof(pname)); 
If posible remake the whole script lines I wrote please.
Reply
#4

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.
Reply
#5

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.
Reply
#6

This should work.

PHP код:
public OnPlayerDisconnect(playeridreason) {
    new 
pname[MAX_PLAYER_NAME], string[39 MAX_PLAYER_NAME];
    
GetPlayerName(playeridpnamesizeof(pname));
    switch(
reason) {
        case 
0format(stringsizeof(string), "%s has left the server. (Lost Connection)"pname);
        case 
1format(stringsizeof(string), "%s has left the server. (Leaving)"pname);
        case 
2format(stringsizeof(string), "%s has left the server. (Kicked)"pname);
    }
    for(new 
i,j=GetPlayerPoolSize();i<=j;i++) { 
        if(!
IsPlayerConnected(i) || IsPlayerAdmin(i)) continue; 
        
SendClientMessage(i, -1string);
    }
    return 
1;

EDIT: Fixed a typo, my bad.
Reply
#7

Quote:
Originally Posted by d1git
Посмотреть сообщение
This should work.

PHP код:
public OnPlayerDisconnect(playeridreason) {
    new 
pname[MAX_PLAYER_NAME], string[39 MAX_PLAYER_NAME];
    
GetPlayerName(playeridpnamesizeof(pname));
    switch(
reason) {
        case 
0format(stringsizeof(string), "%s has left the server. (Lost Connection)"pname);
        case 
1format(stringsizeof(string), "%s has left the server. (Leaving)"pname);
        case 
2format(stringsizeof(string), "%s has left the server. (Kicked)"pname);
    }
    for(new 
i,j=GetPlayerPoolSize();i<=j;i++) { 
        if(!
IsPlayerConnected(i) || IsPlayerAdmin(i)) continue; 
        
SendClientMessage(i, -1string);
    }
    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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)