SA-MP Forums Archive
How to - 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: How to (/showthread.php?tid=513594)



How to - weedxd - 17.05.2014

I wanted to ask how can i bind a command to a button? like at this situation when I want to start robbery in a shop i have to press alt.


Edit For the moment i have only this

PHP код:
    public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
  if (
PRESSED(KEY_CROUCH))
    {
     if(
IsPlayerInRangeOfPoint(playerid7.0754.16119, -40.84430999.99481))
        { 



Re: How to - Hwang - 17.05.2014

Example:
pawn Код:
if (PRESSED(KEY_CROUCH))
{
if(IsPlayerInRangeOfPoint(playerid, 7.0, 754.16119, -40.84430, 999.99481))
{
OnPlayerCommandText(playerid, "/command");
}
}
ZCMD:

pawn Код:
if (PRESSED(KEY_CROUCH))
{
if(IsPlayerInRangeOfPoint(playerid, 7.0, 754.16119, -40.84430, 999.99481))
{
cmd_command(playerid);
}
}
cmd_command, change u name.


Re: How to - weedxd - 17.05.2014

Quote:
Originally Posted by Hwang
Посмотреть сообщение
Example:
pawn Код:
if (PRESSED(KEY_CROUCH))
{
if(IsPlayerInRangeOfPoint(playerid, 7.0, 754.16119, -40.84430, 999.99481))
{
OnPlayerCommandText(playerid, "/command");
}
}
ZCMD:

pawn Код:
if (PRESSED(KEY_CROUCH))
{
if(IsPlayerInRangeOfPoint(playerid, 7.0, 754.16119, -40.84430, 999.99481))
{
cmd_command(playerid);
}
}
cmd_command, change u name.
And for Dcmd ? I have to change cmd_robstore to dcmd_robstore ?


Re: How to - Hwang - 17.05.2014

Quote:
Originally Posted by weedxd
Посмотреть сообщение
And for Dcmd ? I have to change cmd_robstore to dcmd_robstore ?
dcmd uses OnPlayerCommandText infrastructure, for her:
pawn Код:
OnPlayerCommandText(playerid, "/rob");



Re: How to - Ciandlah - 17.05.2014

It is safer to just copy and past your /rob command under that line instead of making a forwarded function.

Its better in the long run because it will not be calling a process to go to another process you have made.


Re: How to - weedxd - 17.05.2014

Quote:
Originally Posted by Hwang
Посмотреть сообщение
dcmd uses OnPlayerCommandText infrastructure, for her:
pawn Код:
OnPlayerCommandText(playerid, "/rob");
Oh okey thanks