Help with OnPlayerKeyStateChange
#1

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

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

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)