OnPlayerSpawn check
#1

Hey guys!

I am busy with a login system but it won't work for me and I can't figure out what I'm doing wrong.

Here is my code:
Код:
public OnPlayerSpawn(playerid) {
	if(!Variables[playerid][LoggedIn] = true)) {
	GameTextForPlayer(playerid,"JE VERGAT IN TE1 LOGGEN!",5000,5);
	Kick(playerid);
	}
	return 1;
}
It gives these errors on the "if" line:

Код:
login.pwn(144) : warning 211: possibly unintended assignment
login.pwn(144) : error 022: must be lvalue (non-constant)
login.pwn(144) : warning 215: expression has no effect
login.pwn(144) : error 001: expected token: ";", but found ")"
login.pwn(144) : error 029: invalid expression, assumed zero
login.pwn(144) : fatal error 107: too many error messages on one line
Thanks in advance!
Reply
#2

You have double closing ' ) ' at the end.
Quote:

if(!Variables[playerid][LoggedIn] = true)) {

Reply
#3

Replace:

PHP код:
if(!Variables[playerid][LoggedIn] = true)) 
With:

PHP код:
if(!Variables[playerid][LoggedIn] == true
Reply
#4

Quote:
Originally Posted by Plovix
Посмотреть сообщение
Replace:

PHP код:
if(!Variables[playerid][LoggedIn] = true)) 
With:

PHP код:
if(!Variables[playerid][LoggedIn] == true
Welp, that didn't fixed it
My code now:
PHP код:
public OnPlayerSpawn(playerid) {
    if(!
Variables[playerid][LoggedIn] = true) {
    
GameTextForPlayer(playerid,"JE VERGAT IN TE LOGGEN!",5000,5);
    
Kick(playerid);
    }
    return 
1;

Errors:
Код:
login.pwn(144) : warning 211: possibly unintended assignment
login.pwn(144) : error 022: must be lvalue (non-constant)
login.pwn(144) : warning 215: expression has no effect
login.pwn(144) : error 001: expected token: ";", but found ")"
login.pwn(144) : error 029: invalid expression, assumed zero
login.pwn(144) : fatal error 107: too many error messages on one line
Reply
#5

Do you use boolean or just 0/1.
In the first case, ! and true = false
So,
pawn Код:
if(Variables[playerid][LoggedIn] == false)
In the second case,
pawn Код:
if(Variables[playerid][LoggedIn] == 0)
Reply
#6

This has to work:

PHP код:
public OnPlayerSpawn(playerid
{
    if(
Variables[playerid][LoggedIn] != true
    {
    
GameTextForPlayer(playerid,"JE VERGAT IN TE LOGGEN!",5000,5);
    
Kick(playerid);
    }
    return 
1;

Reply
#7

Quote:
Originally Posted by Plovix
Посмотреть сообщение
This has to work:

PHP код:
public OnPlayerSpawn(playerid
{
    if(
Variables[playerid][LoggedIn] != true
    {
    
GameTextForPlayer(playerid,"JE VERGAT IN TE LOGGEN!",5000,5);
    
Kick(playerid);
    }
    return 
1;

Worked perfectly! Thanks a million! Repped!
Reply
#8

Np,thank you for +rep,if you want,rep to Dwane,because he/she try to help too
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)