SA-MP Forums Archive
Returning a command in OnPlayerKeyStateChange - 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: Returning a command in OnPlayerKeyStateChange (/showthread.php?tid=381976)



Returning a command in OnPlayerKeyStateChange - vIBIENNYx - 01.10.2012

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



Re: Returning a command in OnPlayerKeyStateChange - Danyal - 01.10.2012

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)



Re: Returning a command in OnPlayerKeyStateChange - Smally - 01.10.2012

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


Re: Returning a command in OnPlayerKeyStateChange - ViniBorn - 01.10.2012

Without params :

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


//OnPlayerKeyStateChange
cmd_vinteract(playerid);



Re: Returning a command in OnPlayerKeyStateChange - vIBIENNYx - 01.10.2012

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.


Re: Returning a command in OnPlayerKeyStateChange - Smally - 01.10.2012

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.


Re: Returning a command in OnPlayerKeyStateChange - vIBIENNYx - 01.10.2012

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.