Send message when key is pressed
#1

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)