Getting the keys?
#1

hi, i was trying to detect waht keys players use when they are gonna use the gamble machines in casino's but:

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	new string[30];
	format(string,sizeof(string),"%d,%d",newkeys,oldkeys);
	print(string);
	return 1;
}
dosen't work? Cut anyone tell me what's wrong or if you know waht keys they use? (:

- Naxix
Reply
#2

the vendor machines, roulette, blackjack, etc. are working by pressing the "enter car" key when standing infront of them. if you didnt modify your config, then its supposed to be F.
Reply
#3

So how would the key part of that look like? Like something with if(GetPlayerKeys, i guess
Reply
#4

The code you wrote works. Don't forget that OnPlayerKeyStateChange doesn't get called if you're pressing the movement keys (W, S, A, D or arrow keys)
Reply
#5

Ye, i got the key id (16) but i'm not sure how to make the code, i was thinking of something like:

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(IsPlayerInRangeOfPoint(playerid,12,1955.3472,1019.2318,992.4688))
	{
	  if(GetPlayerKeys(playerid,16);
	  {
	    SetPlayerPos(playerid,Out side casino);
		}
	}
	return 1;
}
Tho it wont work. i'm not sure on the GetPlayerKeys, never used it.
Reply
#6

You don't need to get the keys, since you already have them saved inside 'newkeys' and 'oldkeys'.
You need to compare the id (16) with 'newkeys', since they are the keys, which were pressed.

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(IsPlayerInRangeOfPoint(playerid,12,1955.3472,1019.2318,992.4688))
    {
        if(newkeys & 16)
        {
            SetPlayerPos(playerid,Out side casino);
        }
    }
    return 1;
}
Click the wiki link to see further, how to check for a key
https://sampwiki.blast.hk/wiki/OnPlayerK...heck_for_a_key
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)