SA-MP Forums Archive
Block ESC - 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: Block ESC (/showthread.php?tid=306476)



Block ESC - soueu - 26.12.2011

Since I can't find this anywhere I decided to ask... (If it was already posted please link it...)
Is there any way to block users from going godmod when pressing ESC? Or any alternative method?

Thanks in advance!


Re: Block ESC - PrawkC - 26.12.2011

Look into GetPlayerKeys and OnPlayerKeyStateChange, you can't detect ESC though, but you can check the available keys in the wiki.


Re: Block ESC - coole210 - 26.12.2011

Ok, check if they are in ESC mode, then check if another player shot or melee'd them and set their health appropriately


Re: Block ESC - soueu - 26.12.2011

Yeah, I've looked into GetPlayerKeys already but no ESC keys related in there...


Re: Block ESC - coole210 - 26.12.2011

You don't need to check for ESC key, check out my AFK filterscript, it shows how to detect Escape mode


Re: Block ESC - soueu - 27.12.2011

Hmm thanks for the tip.
Still not sure what would be the best way to detect the damage done from the attacker and then to apply it on the victim...

Would something like this work:
Код:
#include <a_samp>

new Float:AFKPos[MAX_PLAYERS][3];

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
	new Float:Pos[3];
	new Float:health;

	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		GetPlayerPos(i,Pos[0],Pos[1],Pos[2]);
		if(Pos[0] + Pos[1] + Pos[2] == AFKPos[i][0] + AFKPos[i][1] + AFKPos[i][2])
		{
			if(amount > 0)
			{
				GetPlayerHealth(playerid, health);
				SetPlayerHealth(playerid, health - amount);
			}
		}
		GetPlayerPos(i, AFKPos[i][0], AFKPos[i][1], AFKPos[i][2]);
	}
 	return 1;
}
?


Re: Block ESC - coole210 - 27.12.2011

If you want to try a whole different approach, go for OnPlayerShootPlayer and maybe something to check melee.

P.S. search for "Escape" in my code, thats how u check for escape mode


Re: Block ESC - Scenario - 27.12.2011

You need to determine if the player is "away from keyboard" or they have alt-tabbed (or they are in the game menu). I think ******'s YUP system should do. It may need to be re-compiled for 0.3d though (if it's even compatible)!

https://sampforum.blast.hk/showthread.php?tid=55397


Re: Block ESC - soueu - 27.12.2011

Ok, got it...
Код:
public OnPlayerPause(playerid)
{

}
But how am I supposed to retrieve the amount of health taken from the victim inside of that ?


Re: Block ESC - Scenario - 27.12.2011

That's a good question. I'm not sure if "OnPlayerTakeDamage" will work when the player is paused, have you given that a shot?