SA-MP Forums Archive
Send message when key is pressed - 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: Send message when key is pressed (/showthread.php?tid=403480)



Send message when key is pressed - NicholasA - 30.12.2012

I was wondering how do we make it so that when a player presses a button it sends a message to all rcon logged in people?


Re: Send message when key is pressed - [KHK]Khalid - 30.12.2012

You can do that using OnPlayerKeyStateChange.

pawn Код:
// After includes
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED (KEY_SPRINT)) // for more keys - https://sampwiki.blast.hk/wiki/GetPlayerKeys
    {
        for(new i = 0; i < MAX_PLAYERS; i ++) // loop through all players
        {
            if(IsPlayerAdmin(i)) // check if they are logged in rcon
            {
                SendClientMessage(i, -1, "Message"); // send a message
            }
        }
    }
    return 1;
}