SA-MP Forums Archive
Help with OnPlayerKeyStateChange - 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: Help with OnPlayerKeyStateChange (/showthread.php?tid=624238)



Help with OnPlayerKeyStateChange - Merciful - 13.12.2016

Hey guys,

Basically I am trying to detect if someone is activating some particular hacks. I know some troll hacks and their activation keys and I want to take advantage of OnPlayerKeyStateChange function to tell me if someone is holding those 2 keys together.

Here is my script:
Quote:

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new Keys,ud,lr;
new name[24];
new string[100];
if(Keys == KEY_ACTION && KEY_SUBMISSION)
{
GetPlayerKeys(playerid,Keys,ud,lr);
GetPlayerName(playerid,name,sizeof(name));
format(string,sizeof(string),"Warning :- %s is suspected to be using car troll hacks.",string);
MessageToAdmins(red,string);
}
return 1;
}

This was supposed to detect if someone is HOLDING CTRL + 2 but it is not detecting it.

I kindly request to the scripters here to take out some time to help me fix this script.

Thank you very much in advance


Re: Help with OnPlayerKeyStateChange - X337 - 13.12.2016

Your if() statement is invalid, and you don't need that GetPlayerKeys() since there is a newkeys parameter in that callback.
There's a tutorial on SA-MP wiki about checking multiple keys: https://sampwiki.blast.hk/wiki/OnPlayerK..._multiple_keys
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	new name[24], string[100];
	if((newkeys & KEY_ACTION) && (newkeys & KEY_SUBMISSION))
	{
		GetPlayerName(playerid, name, sizeof(name));
		format(string, sizeof(string), "Warning :- %s is suspected to be using car troll hacks.", name);
		MessageToAdmins(red,string);
	}
	return 1;
}



Re: Help with OnPlayerKeyStateChange - Merciful - 13.12.2016

Quote:
Originally Posted by X337
Посмотреть сообщение
Your if() statement is invalid, and you don't need that GetPlayerKeys() since there is a newkeys parameter in that callback.
There's a tutorial on SA-MP wiki about checking multiple keys: https://sampwiki.blast.hk/wiki/OnPlayerK..._multiple_keys
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	new name[24], string[100];
	if((newkeys & KEY_ACTION) && (newkeys & KEY_SUBMISSION))
	{
		GetPlayerName(playerid, name, sizeof(name));
		format(string, sizeof(string), "Warning :- %s is suspected to be using car troll hacks.", name);
		MessageToAdmins(red,string);
	}
	return 1;
}
Thanks, appreciated.

It is working.