Login before spawn
#1

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;
}
Reply
#2

Код:
	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?
Reply
#3

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

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;
Reply
#5

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
?
Reply
#6

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.
Reply
#7

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

NPC= irrelevent, i dont uses NPC's
Reply
#9

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;
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)