Disabling cmds
#1

I'm using I-ZCMD and wanted to disable all commands if a player is not logged or spawn, problem is, they can use commands even if they're not logged/spawned:

pawn Код:
public OnPlayerCommandRecieved(playerid, cmdtext[])
{
    if(Player[playerid][IsLoggedIn] == false) return GameTextForPlayer(playerid, "~w~You need to be ~r~logged in ~w~to use commands!", 3000, 4), 0;
    if(Player[playerid][PlayerSpawned] == false) return GameTextForPlayer(playerid, "~w~You must be ~r~alive ~w~to use commands!", 3000, 4), 0;
    return 1;
}
Bools are set to false on OnPlayerConnect.
Reply
#2

Код:
public OnPlayerCommandRecieved(playerid, cmdtext[])
{
    if(!Player[playerid][IsLoggedIn])
    {
	GameTextForPlayer(playerid, "~w~You need to be ~r~logged in ~w~to use commands!", 3000, 4);
	return 0;
    }
    if(!Player[playerid][PlayerSpawned])
    {
	GameTextForPlayer(playerid, "~w~You must be ~r~alive ~w~to use commands!", 3000, 4);
	return 0;
    }
    return 1;
}
Reply
#3

Still nothing.
Reply
#4

Quote:

public OnPlayerCommandRecieved(playerid, cmdtext[])
{
if(Player[playerid][IsLoggedIn] == false) return GameTextForPlayer(playerid, "~w~You need to be ~r~logged in ~w~to use commands!", 3000, 4), 0;
if(Player[playerid][PlayerSpawned] == false) return GameTextForPlayer(playerid, "~w~You must be ~r~alive ~w~to use commands!", 3000, 4), 0;
return 1;
}
}

edit to
Quote:

public OnPlayerCommandRecieved(playerid, cmdtext[])
{
if(Player[playerid][IsLoggedIn] = 0) return GameTextForPlayer(playerid, "~w~You need to be ~r~logged in ~w~to use commands!", 3000, 4), 0;
if(Player[playerid][PlayerSpawned] = 0) return GameTextForPlayer(playerid, "~w~You must be ~r~alive ~w~to use commands!", 3000, 4), 0;
return 1;
}
public OnPlayerSpawn(playerid)
{
Player[playerid][IsLoggedIn] = 1;
Player[playerid][PlayerSpawned] = 1;
return 1;
}

public OnPlayerDeath(playerid)
{
Player[playerid][PlayerSpawned] = 0;
return 1;
}

Reply
#5

Using filterscripts with commands? Callbacks are called first in filterscripts so this wouldn't do anything.
Reply
#6

Quote:
Originally Posted by ******
Посмотреть сообщение
The return value of GameTextForPlayer is undefined. Return a proper value.
I did in the first post. I returned 0 after GameTextForPlayer but still nothing.

@GeorgeLimit: IsLoggedIn and PlayerSpawned are bools.
Reply
#7

Bump.
Reply
#8

Код:
public OnPlayerCommandReceived(playerid, cmd[], params[], flags)
{
       if(!Player[playerid][IsLoggedIn])
           return false;
	    
       return true;
}
Reply
#9

Nothing...
Reply
#10

You are still stuck on this? This shouldn't take more than 5 minutes to figure out it is so simple. Put print()'s indicating what is being called and when then trace the order of function calls find the break point. This shit happens constantly when scripting learn how to fix it quick.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)