ClientMessage only once - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: ClientMessage only once (
/showthread.php?tid=200214)
ClientMessage only once -
BlackWolf120 - 17.12.2010
hi,
how to display a ClientMessage only once to a player? e.g. after he spawned?
regards.
Re: ClientMessage only once -
Biesmen - 17.12.2010
pawn Код:
public OnPlayerSpawn(playerid)
{
SendClientMessage(playerid, 0xFFFFFFFF, "You have spawned!");
return 1;
}
Re: ClientMessage only once -
BlackWolf120 - 17.12.2010
haha,

i knew that before, but if this player dies he'll get this message again.
My question is how to show this message only once, on his first spawn only.
Re: ClientMessage only once -
Biesmen - 17.12.2010
pawn Код:
public OnPlayerRequestSpawn(playerid) // This is only when the player wants to spawn by clicking "SHIFT" at the skin selection screen.
{
SendClientMessage(playerid, 0xFFFFFFFF, "You have spawned!");
return 1;
}
Re: ClientMessage only once -
BlackWolf120 - 17.12.2010
yeah,
but i have a cmd /class
This cmd allows u to change ur skin ingame, if u wish to change ur team for example
And then this message would appear again right?
Re: ClientMessage only once -
WillyP - 17.12.2010
Quote:
Originally Posted by Biesmen
pawn Код:
public OnPlayerRequestSpawn(playerid) // This is only when the player wants to spawn by clicking "SHIFT" at the skin selection screen. { SendClientMessage(playerid, 0xFFFFFFFF, "You have spawned!"); return 1; }
|
That would send him a message even before he spawned. :P
Use PVars or variables
Re: ClientMessage only once -
BlackWolf120 - 17.12.2010
yeah, i know that i have to do sth. with variables, but the problem is, i dont know how to do this

maybe u could give me a little example or a link to a thread or sth?
thx for ur answer btw
Re: ClientMessage only once -
Biesmen - 17.12.2010
Victious, if the spawn will succeed it will send this message at the same time he is spawning.
For BlackWolf, I tried to evade that variable idea.. But here you go.
At the top of your script:
pawn Код:
new IsSpawned[MAX_PLAYERS];
Then, at OnPlayerSpawn:
pawn Код:
public OnPlayerSpawn(playerid)
{
if(IsSpawned[playerid] == 0)
{
SendClientMessage(playerid, COLOR_WHITE, "You have logged in!");
IsSpawned[playerid] = 1;
return 1;
} else if(IsSpawned[playerid] == 1)
{
return 1;
}
return 1;
}
at OnPlayerConnect:
pawn Код:
public OnPlayerConnect(playerid)
{
IsLogged[playerid] = 0;
return 1;
}
AW: ClientMessage only once -
BigETI - 19.12.2010
Do it like this:
pawn Код:
#define GREEN 0x0000FFFF
OnPlayerSpawn(playerid)
{
switch(GetPVarInt(playerid, "IsSpawned"))
case 0:
{
SendClientMessage(playerid, GREEN, You have been succesfully spawned.);
SetPVarInt(playerid, "IsSpawned", 1);
}
return 1;
}