Returning a command in OnPlayerKeyStateChange
#1

Basically, I'm using Zcmd and sscanf to code commands, but in OnPlayerKeyStateChange "params" isn't defined so the following code doesn't work as expected.

How can I return the use of a command in OnPlayerKeyStateChange?

Here's my code:

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_YES))
    {
        return cmd_vinteract(playerid, params);
    }
    if(GetPlayerState(playerid) == 2 || GetPlayerState(playerid) == 3)
    {
        if(GetPlayerVehicleSeat(playerid) == 0 || GetPlayerVehicleSeat(playerid) == 1)
        {
            if(PRESSED(KEY_SPRINT))
            {
                new vehid;
                vehid = GetPlayerVehicleID(playerid);
                if(vengineon[playerid] == 0)
                {
                    return cmd_eon(playerid, params);
                }
            }
            if(PRESSED(KEY_SUBMISSION))
            {
                //
            }
        }
    }
    if(PRESSED(128))
    {
        //
    }
    return 1;
}
Reply
#2

why do you want to return cmd

just esay way copy and paste your cmd text

EDIT:
May you can get these to work
Код:
OnPlayerCommandReceived(playerid, cmdtext[])
OnPlayerCommandPerformed(playerid, cmdtext[], success)
Reply
#3

pawn Код:
Public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_YES))
    {
        return cmd_vinteract(playerid, "");
    }
    if(GetPlayerState(playerid) == 2 || GetPlayerState(playerid) == 3)
    {
        if(GetPlayerVehicleSeat(playerid) == 0 || GetPlayerVehicleSeat(playerid) == 1)
        {
            if(PRESSED(KEY_SPRINT))
            {
                new vehid;
                vehid = GetPlayerVehicleID(playerid);
                if(vengineon[playerid] == 0)
                {
                    return cmd_eon(playerid, "");
                }
            }
            if(PRESSED(KEY_SUBMISSION))
            {
                //
            }
        }
    }
    if(PRESSED(128))
    {
        //
    }
    return 1;
}
Not tested - but should work
Reply
#4

Without params :

Ex:
pawn Код:
//Your command
CMD:vinteract(playerid)
{
    //
    return true;
}


//OnPlayerKeyStateChange
cmd_vinteract(playerid);
Reply
#5

Quote:
Originally Posted by Lido
Посмотреть сообщение
pawn Код:
Public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_YES))
    {
        return cmd_vinteract(playerid, "");
    }
    if(GetPlayerState(playerid) == 2 || GetPlayerState(playerid) == 3)
    {
        if(GetPlayerVehicleSeat(playerid) == 0 || GetPlayerVehicleSeat(playerid) == 1)
        {
            if(PRESSED(KEY_SPRINT))
            {
                new vehid;
                vehid = GetPlayerVehicleID(playerid);
                if(vengineon[playerid] == 0)
                {
                    return cmd_eon(playerid, "");
                }
            }
            if(PRESSED(KEY_SUBMISSION))
            {
                //
            }
        }
    }
    if(PRESSED(128))
    {
        //
    }
    return 1;
}
Not tested - but should work
Like a charm, repped you both. Thanks for the help.

Edit: What do you mean ******? All parameters are checked in the actual command, all the button is doing is performing the command's function.
Reply
#6

Quote:
Originally Posted by vIBIENNYx
Посмотреть сообщение
Like a charm, repped you both. Thanks for the help.

Edit: What do you mean ******? All parameters are checked in the actual command, all the button is doing is performing the command's function.
Your welcome.
Reply
#7

Never thought of it like that, that's a very good point actually, thanks. It's kind of like, turning the command into a function, calling the function inside the command and the keypress, rather than just calling the command in the Keypress.

Repped you aswell, might use it for a couple more dialogues and keypresses I'm using.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)