SA-MP Forums Archive
Login before spawn - 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: Login before spawn (/showthread.php?tid=136680)



Login before spawn - cozza123456 - 26.03.2010

Why isnt this working? you can just spawn willy nilly.

Код:
public OnPlayerRequestSpawn(playerid)
{
  if(!IsPlayerNPC(playerid)) return 1;
	#if defined LOGIN_BEFORE_SPAWN
	new string[128];
	new sendername[MAX_PLAYER_NAME];
	GetPlayerName(playerid,sendername,24);
	format(string,128,"/sAccounts/%s.seifadmin",sendername);
	if (AccountInfo[playerid][Logged] == 0)
	{
 	SendClientMessage(playerid,RED,"Your account is registered. You must first login in order to spawn.");
 	printf("%s is trying to spawn but hasn't logged in!", sendername);
 	SendClientMessageToAll(YELLOW, "%s is trying to spawn but hasn't logged in!");
	return 0;
	}
 	#endif
	return 1;
}



Re: Login before spawn - Rac3r - 26.03.2010

Код:
	format(string,128,"/sAccounts/%s.seifadmin",sendername);
Check if this file exists first, then check if player is logged in.
Код:
	format(string,128,"/sAccounts/%s.seifadmin",sendername);
	if( fexist (string) )
	{
		if (AccountInfo[playerid][Logged] == 0)
		{
			return 0;
		}
	}
	return 1;
}
Also, explain better why it doesn't work. Does the player spawn at all?



Re: Login before spawn - cozza123456 - 26.03.2010

Quote:
Originally Posted by XxCozzaxX
you can just spawn willy nilly.
^^ explained. You can spawn without logging in.


Re: Login before spawn - Oxside - 26.03.2010

Try making a new variable named logged:

Код:
new logged[MAX_PLAYERS];
Then on spawn:

Код:
if(logged[playerid] == 0)
{
   SendClientMessage(playerid, COLOR_RED, "[!] You may not spawn before logging in!");
}
Then in the /login command add:

Код:
logged[playerid] = 1;
And when the player disconnect (OnPlayerDisconnect)

Код:
logged[playerid] = 0;



Re: Login before spawn - Rac3r - 26.03.2010

Ahh yeh spawned willy nilly lol

Still doesn't explain why you format a string, but don't use the string for anything. But oh well.

Are you sure at the top of the script there is:
Код:
#define LOGIN_BEFORE_SPAWN
?



Re: Login before spawn - cozza123456 - 26.03.2010

It's not my script... its Seif's... but it used to work... i havent changed anything about login before spawn

and yes, its at the top.


Re: Login before spawn - dice7 - 26.03.2010

pawn Код:
public OnPlayerRequestSpawn(playerid)
{
  if(!IsPlayerNPC(playerid)) return 1;
If the player is an npc, then he must login, else he spawns ?


Re: Login before spawn - cozza123456 - 26.03.2010

NPC= irrelevent, i dont uses NPC's


Re: Login before spawn - [03]Garsino - 26.03.2010

Quote:
Originally Posted by dice7
pawn Код:
public OnPlayerRequestSpawn(playerid)
{
  if(!IsPlayerNPC(playerid)) return 1;
If the player is an npc, then he must login, else he spawns ?
If the player is NOT an NPC the player will be allowed to spawn. Simply change to
pawn Код:
if(IsPlayerNPC(playerid)) return 1;



Re: Login before spawn - playbox12 - 26.03.2010

Hey according to all your weird errors you post here on the forum, you sure that no Filterscripts are messing up your script, try To load without filterscripts.