PDA

View Full Version : OnPlayerSpawn check


nickbouwhuis
10/11/2012, 12:18 PM
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!

Skillet`
10/11/2012, 12:23 PM
You have double closing ' ) ' at the end.
if(!Variables[playerid][LoggedIn] = true)) {

Plovix
10/11/2012, 12:26 PM
Replace:

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

With:

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

nickbouwhuis
10/11/2012, 12:39 PM
Replace:

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

With:

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

Welp, that didn't fixed it
My code now:
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

Konstantinos
10/11/2012, 12:42 PM
Do you use boolean or just 0/1.
In the first case, ! and true = false
So,

if(Variables[playerid][LoggedIn] == false)

In the second case,

if(Variables[playerid][LoggedIn] == 0)

Plovix
10/11/2012, 12:45 PM
This has to work:

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

nickbouwhuis
10/11/2012, 12:46 PM
This has to work:

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!

Plovix
10/11/2012, 12:48 PM
Np,thank you for +rep,if you want,rep to Dwane,because he/she try to help too :)