ConnectSpawn function - send messages to a player when he first connects - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: ConnectSpawn function - send messages to a player when he first connects (
/showthread.php?tid=631947)
ConnectSpawn function - send messages to a player when he first connects -
noPANDA - 07.04.2017
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)
Re: ConnectSpawn function - send messages to a player when he first connects -
jlalt - 07.04.2017
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
}
}
Re: ConnectSpawn function - send messages to a player when he first connects -
Toroi - 07.04.2017
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.
Re: ConnectSpawn function - send messages to a player when he first connects -
noPANDA - 07.04.2017
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