SA-MP Forums Archive
NPC welcomes new players? - 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: NPC welcomes new players? (/showthread.php?tid=168488)



NPC welcomes new players? - xZacharias - 16.08.2010

hello..

I've seen on an webpage that there's possible to make bot welcome new players. I mean: player connects, bot says: "Hello, %s!" but I can't find that webpage again
does anyone know how can I do that? sry for my bad english..


Re: NPC welcomes new players? - [FA]StUnT4LiFeZ - 16.08.2010

Could possibly be something to do with OnPlayerConnect or OnPlayerSpawn, no idea how you would go about coding it, but yeh.


Re: NPC welcomes new players? - Jeffry - 16.08.2010

Under OnPlayerConnect:

pawn Код:
new str[128];
GetPlayerName(playerid,pName, MAX_PLAYER_NAME);
format(str, 128, "Hello %s!!!", pName);
SendPlayerMessageToAll(0, str); //Change the 0 to the ID of your NPC
Say if there are bugs. ^^


Re: NPC welcomes new players? - xZacharias - 16.08.2010

it will be something like this?



Re: NPC welcomes new players? - Kaye - 16.08.2010

How would I go about making it random messages from the NPC? My way didn't work out to well. :/


Re: NPC welcomes new players? - Jeffry - 16.08.2010

Just try the code. -_-


Re: NPC welcomes new players? - xZacharias - 16.08.2010

thank you it works


Re: NPC welcomes new players? - Jeffry - 16.08.2010

No problem. Have fun.


Re: NPC welcomes new players? - Kaye - 16.08.2010

Jeffry, would you know how to set it up so it's a different message each time? I've tried to mess around with the random function but with no luck. Any ideas? Thanks.


Re: NPC welcomes new players? - xZacharias - 16.08.2010

Код:
new str[128];
		GetPlayerName(playerid,pname, MAX_PLAYER_NAME);
		new RandR = random (8);
		if(RandR == 1)
		{
			format(str, 128, "Hello, %s!", pname);
			SendPlayerMessageToAll(0, str);
		}
		else if(RandR == 2)
		{
		    format(str, 128, "%s, what's up?", pname);
			SendPlayerMessageToAll(0, str);
		}
...
this should work