IsPlayerLoggedIn Help.
#1

FIXED

Hey everyone,

Im pretty much stumped on IsPlayerLogged for my commands.

I put in this stock to make it actually work which I found somewhere else!

EX:
Код:
stock IsPlayerLoggedIn(playerid)
{
if(YourVariable[Logged] == 1) return 1;
else if(YourVariable[Logged] == 0) return 0;
}
What am I supposed to put in for "YourVariable" ?

Trying to make this command with this stock.

Ex:

Код:
CMD:backpack(playerid, params[])
{
	if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GRAD1,"You have to be logged in to use that command!");
    SetPlayerAttachedObject(playerid, 1, 363, 1, 0.300000, -0.14,0.2, 0.000000, 90, 359.5022,1,1,1);
    return 1;
}
ERRORS:
Код:
error 017: undefined symbol "YourVariable"
error 017: undefined symbol "Logged"
error 029: invalid expression, assumed zero
Thanks!
Reply
#2

EDITED

I posted this one first, however, this got some logic as you're detecting logins globally.

The array isn't kept for players, you must make it for players too to detect if they're logged in or not well.
pawn Код:
//Enum method:
enum urvar
{
 Logged
}

new YourVariable[MAX_PLAYERS][urvar];

stock IsPlayerLoggedIn(playerid)
{
 if(YourVariable[playerid][Logged] == 1) return true;
 else if(YourVariable[playerid][Logged] == 0) return false;
}
Another way:
pawn Код:
new Logged[MAX_PLAYERS];

stock IsPlayerLoggedIn(playerid)
{
 if(Logged[playerid] == 1) return true;
 else if(Logged[playerid] == 0) return false;
}

Your FIX:

You haven't declared that array, you must declare it first.
pawn Код:
enum somevar
{
 Logged
}

new YourVariable[somevar];

//Add this above the function.
Reply
#3

Try this
pawn Код:
new bool:PlayerLogged[MAX_PLAYERS];

public OnPlayerConnect(playerid) {
    PlayerLogged[playerid] = false; // resetting the variable
    return 1;
}
// uhhm if you success logining the player put this
    PlayerLogged[playerid] = true;
// then do this
CMD:backpack(playerid, params[])
{
    if(PlayerLogged[playerid] != true) return SendClientMessage(playerid, COLOR_GRAD1,"You have to be logged in to use that command!");
    SetPlayerAttachedObject(playerid, 1, 363, 1, 0.300000, -0.14,0.2, 0.000000, 90, 359.5022,1,1,1);
    return 1;
}
Reply
#4

Fixed!

Appreciate it!
Reply
#5

I just put in this like Lordz said:

Quote:

new Logged[MAX_PLAYERS];

stock IsPlayerLoggedIn(playerid)
{
if(Logged[playerid] == 1) return true;
else if(Logged[playerid] == 0) return false;
}

And no errors!

But will it actually work?
Reply
#6

Quote:
Originally Posted by aaleks123
Посмотреть сообщение
I just put in this like Lordz said:



And no errors!

But will it actually work?
trust him, he's pro
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)