Block ESC
#1

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!
Reply
#2

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

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

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

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

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;
}
?
Reply
#7

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
Reply
#8

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
Reply
#9

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)