OnPlayerConnect help
#1

Hello, I am currently trying to make my server announce a special sentence if a certain user connects.

E.x. If player Hiukuss connects, the server will announce "Server developer Hiukuss has joined the game!"

Is there a way I can do that?
Thank you for your time

~Hiukuss
Reply
#2

pawn Код:
public OnPlayerConnect(playerid)
{
    new name[MAX_PLAYER_NAME], string[156];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "%s has connected to the server!", name);
    SendClientMessage(playerid, -1, string);
    return 1;
}
Reply
#3

Could you go into depth? E.X. tell me what to do with that?

EDIT: Basically, I don't know what to edit in that.
Reply
#4

What Sinc has posted is for every single player who connect's the server.

You might be having a Level for the Server Developer in the Player define's area. Lets say "pAdmin = 7"
Код:
public OnPlayerConnect(playerid)
{
    if(PlayerInfo[playerid][pAdmin] == 7)
    {
        new name[MAX_PLAYER_NAME], string[156];
        GetPlayerName(playerid, name, sizeof(name));
        format(string, sizeof(string), "Server Developer %s has connected to the server!", name);
        SendClientMessageToAll(COLOR_RED, string); // Choose your color
        return 1;
    }
}
You need to paste this in your OnPlayerConnect Function of your game mode! [Rep+ if i help'ed you]
Reply
#5

Thank you

but if the user is not admin, how do I make it say User %s has joined
I tried this but it failed:

pawn Код:
public OnPlayerConnect(playerid)
{
    if(IsPlayerAdmin(playerid))
    {
        new name[MAX_PLAYER_NAME], string[156];
        GetPlayerName(playerid, name, sizeof(name));
        format(string, sizeof(string), "Server Developer %s has logged in!", name);
        SendClientMessageToAll(COLOR_RED, string); // Choose your color
        return 1;
}
}
else
{
public OnPlayerConnect(playerid)
        new name[MAX_PLAYER_NAME], string[156];
        GetPlayerName(playerid, name, sizeof(name));
        format(string, sizeof(string), "User %s has logged in!", name);
        SendClientMessageToAll(COLOR_RED, string); // Choose your color
        return 1;
}
I added another OnPlayerConnect which removed some errors, but overall it gives me this:

pawn Код:
C:\Users\William\Desktop\Dublin GTA Freeroam\gamemodes\freeroam.pwn(59) : warning 209: function "OnPlayerConnect" should return a value
C:\Users\William\Desktop\Dublin GTA Freeroam\gamemodes\freeroam.pwn(60) : error 010: invalid function or declaration
C:\Users\William\Desktop\Dublin GTA Freeroam\gamemodes\freeroam.pwn(63) : error 021: symbol already defined: "OnPlayerConnect"
C:\Users\William\Desktop\Dublin GTA Freeroam\gamemodes\freeroam.pwn(63) : error 003: declaration of a local variable must appear in a compound block
C:\Users\William\Desktop\Dublin GTA Freeroam\gamemodes\freeroam.pwn(67) : error 010: invalid function or declaration
C:\Users\William\Desktop\Dublin GTA Freeroam\gamemodes\freeroam.pwn(462) : warning 203: symbol is never used: "gArmySpawns"
C:\Users\William\Desktop\Dublin GTA Freeroam\gamemodes\freeroam.pwn(462) : warning 203: symbol is never used: "gMedicalSpawns"
C:\Users\William\Desktop\Dublin GTA Freeroam\gamemodes\freeroam.pwn(462) : warning 203: symbol is never used: "gPoliceSpawns"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
halp
Reply
#6

The Code your using will not work absolutely cause there can be only one OnPlayerConnect function.

You need to use two separate if() for this ,One for the user and other for the developer. What kind of define you have for the Server Developer , is it with the Admin?? Cause if(IsPlayerAdmin(playerid)) is for Rcon Admins only.
Reply
#7

No, I want it to say the message when an admin logs into RCon.
This is very annoying, if I can't do the user one I will just not add it.
Reply
#8

You dont want the Message when an Admin Logs into RCON?

Or
You want the to create a Message when a User logs into RCON? Or a Server Developer?
Reply
#9

I want the server to send a message to everyone when an admin /rcon login 's
Reply
#10

Inside the game But any admin can only login in the rcon while being inside.

He connect's the game and then logs into rcon , so its simply out of sense?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)