SA-MP Forums Archive
Disabling cmds - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Disabling cmds (/showthread.php?tid=663241)



Disabling cmds - SymonClash - 25.01.2019

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.


Re: Disabling cmds - Wanheda - 25.01.2019

Код:
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;
}



Re: Disabling cmds - SymonClash - 25.01.2019

Still nothing.


Re: Disabling cmds - GeorgeLimit - 25.01.2019

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;
}




Re: Disabling cmds - Pottus - 26.01.2019

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


Re: Disabling cmds - SymonClash - 26.01.2019

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.


Re: Disabling cmds - SymonClash - 27.01.2019

Bump.


Re: Disabling cmds - Bolex_ - 27.01.2019

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



Re: Disabling cmds - SymonClash - 29.01.2019

Nothing...


Re: Disabling cmds - Pottus - 29.01.2019

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.