SA-MP Forums Archive
Key player - 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: Key player (/showthread.php?tid=587186)



Key player - zeth98 - 28.08.2015

How can I make the player to press the key "2" (KEY_LOOK_BEHIND) I know to detect in onplayerkeystatechange.
But i want to make something like this
OnPlayerEnterCheckPoint(playerid)
{
if(CP[playerid] == 10)
{
PressKeyForPlayer(playerid,KEY_LOOK_BEHIND);
SendClientMessage(playerid,-1,"Key '2' was pressed for you");
}
return 1;
}
Is this possible?


Re: Key player - xVIP3Rx - 28.08.2015

Don't think it's possible, you could change his camera position to the back if that's what are you trying to do, or just call the OnPlayerKeyStateChange if you wanna trigger it.


Re: Key player - Logofero - 28.08.2015

Quote:
Originally Posted by zeth98
Посмотреть сообщение
How can I make the player to press the key "2" (KEY_LOOK_BEHIND) I know to detect in onplayerkeystatechange.
But i want to make something like this
OnPlayerEnterCheckPoint(playerid)
{
if(CP[playerid] == 10)
{
PressKeyForPlayer(playerid,KEY_LOOK_BEHIND);
SendClientMessage(playerid,-1,"Key '2' was pressed for you");
}
return 1;
}
Is this possible?
PHP код:
/*
 * native IsPlayerKeyPress(playerid, keycode);
 */
stock IsPlayerKeyPress(playeridkeycode) {
    new 
keyupdownleftright;
    
GetPlayerKeys(playeridkeyupdownleftright);
    
//printf("PRESS player %d key %d updown %d leftright %d",playerid, key, updown, leftright);
    
if(key keycode) return true;
    else if(
keycode == KEY_UP && updown == -128 && leftright == 0) return true;
    else if(
keycode == KEY_DOWN && updown == 128 && leftright == 0) return true;
    else if(
keycode == KEY_LEFT && updown == && leftright == -128) return true;
    else if(
keycode == KEY_RIGHT && updown == && leftright == 128) return true;
    return 
false;
}
public 
OnPlayerEnterCheckPoint(playerid)
{
    if(
CP[playerid] == 10 && IsPlayerKeyPress(playeridKEY_LOOK_BEHIND))
    {
        
SendClientMessage(playerid,-1,"Key '2' was pressed for you");
        return 
1;
    }
    return 
1;




Re: Key player - zeth98 - 28.08.2015

That Function check if I press a key, not press for me.


Re: Key player - Logofero - 28.08.2015

Quote:
Originally Posted by zeth98
Посмотреть сообщение
That Function check if I press a key, not press for me.
It looks like you did not know what you want.
The function keys used to verify who press it and not for another.


Re: Key player - zeth98 - 29.08.2015

I want to press that key for me. If I am in stunt plane and i put that funtion he need ti activate the red smoke. Something like this. I want to click for me.


Re: Key player - CodeStyle175 - 29.08.2015

I dont get the point, for system to click 2. You can just send message of that.


Re: Key player - JaKe Elite - 29.08.2015

There is no possible way to script it nor there is a function which makes the buttons automatically pressed for the player.

Just like the above user's statement, Just send a message over the player. (E.G: "Press 2 to activate the red smoke from the Stunt Plane."