ConnectSpawn function - send messages to a player when he first connects
#1

hello !

i dont know how to make a function which when a player spawns in after connecting it will send him a message like (example: SERVER: Welcome!), but not when he dies and respawns if that is making any sense
can anybody help? (sorry for bad english)
Reply
#2

You will have to do a simple variable at top ->
PHP код:
new newplayer[MAX_PLAYERS char]; 
And later on player connect set it to 1
PHP код:
public OnPlayerConnect(playerid)
{
    
newplayer{playerid} = 1;

On player spawn check if 1, set to 0 and send message
PHP код:
public OnPlayerSpawn(playerid)
{
    if(
newplayer{playerid})
    {
        
newplayer{playerid} = 0;
        
//... message here
    
}

Reply
#3

Create a player variable under OnPlayerConnect to mark the player as just connected. You can call the variable however you want and set the value you want other than zero.

Then, under OnPlayerSpawn , check if that variable is set to the value you choose before, if so, send the message and delete the variable.

That's how i'd do it.
Reply
#4

Quote:
Originally Posted by jlalt
Посмотреть сообщение
jsalt method
thank you this worked
Quote:
Originally Posted by Troydere
Посмотреть сообщение
troydere's method
i understand the logic behind yours but for some reason when i tried to compile it my pawno crashed every time so idk but this method did teach me something thank you +rep'd both of u
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)