SA-MP Forums Archive
How to add command 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to add command to ... (/showthread.php?tid=188130)



How to add command to ... - antsolen - 06.11.2010

How i can add this command to OnplayerCommandText
Код:
if(strcmp(cmdtext,"/home",true)==0)
{
new vehicleid = GetPlayerVehicleID(playerid);
new State = GetPlayerState(playerid);
if(IsPlayerInAnyVehicle(playerid) && State == PLAYER_STATE_DRIVER)
{
GameTextForPlayer(playerid,"Welcome to home !",4000,6);
return SetVehiclePos(vehicleid,387.7016,2590.6699,16.4900,194.4789);
}
SetPlayerPos(playerid,387.7016,2590.6699,16.4900,194.4789);
GameTextForPlayer(playerid,"Welcome to home !",4000,6);
return 1;
}
my onplayyercommand text is :
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  if (strcmp("/cmds", cmdtext, true, 10) == 0)
  {
        SendClientMessage(playerid, 0xFFFFFFFF, "[TELES] /home ,");
  }
  if(strcmp("/help", cmdtext, true, 10) == 0)
  {
        SendClientMessage(playerid, 0xFFFFFFFF, "[HELP] USE /cmds FOR COMMANDS !");
  }
  return 0;
}



Re: How to add command to ... - Kwarde - 06.11.2010

Just add it below the last bracket of the "help" command:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  if (strcmp("/cmds", cmdtext, true, 10) == 0)
  {
        SendClientMessage(playerid, 0xFFFFFFFF, "[TELES] /home ,");
  }
  if(strcmp("/help", cmdtext, true, 10) == 0)
  {
        SendClientMessage(playerid, 0xFFFFFFFF, "[HELP] USE /cmds FOR COMMANDS !");
  }
  if(strcmp(cmdtext,"/home",true)==0)
  {
        new vehicleid = GetPlayerVehicleID(playerid);
        new State = GetPlayerState(playerid);
        if(IsPlayerInAnyVehicle(playerid) && State == PLAYER_STATE_DRIVER)
        {
                GameTextForPlayer(playerid,"Welcome to home !",4000,6);
                return SetVehiclePos(vehicleid,387.7016,2590.6699,16.4900,194.4789);
        }
        SetPlayerPos(playerid,387.7016,2590.6699,16.4900,194.4789);
    GameTextForPlayer(playerid,"Welcome to home !",4000,6);
    return 1;
  }
  return 0;
}



Re: How to add command to ... - Alex_Valde - 06.11.2010

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/cmds", cmdtext, true, 10) == 0)
    {
        SendClientMessage(playerid, 0xFFFFFFFF, "[TELES] /home ,");
    }
    if(strcmp("/help", cmdtext, true, 10) == 0)
    {
        SendClientMessage(playerid, 0xFFFFFFFF, "[HELP] USE /cmds FOR COMMANDS !");
    }

    if(strcmp(cmdtext,"/home",true)==0)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        new State = GetPlayerState(playerid);
        if(IsPlayerInAnyVehicle(playerid) && State == PLAYER_STATE_DRIVER)
        {
            GameTextForPlayer(playerid,"Welcome to home !",4000,6);
            return SetVehiclePos(vehicleid,387.7016,2590.6699,16.4900,194.4789);
        }
        SetPlayerPos(playerid,387.7016,2590.6699,16.4900,194.4789);
        GameTextForPlayer(playerid,"Welcome to home !",4000,6);
    return 1;
    }
  return 0;
}
You just add it to your OnPlayerCommandText callback

Edit: Kwarde was faster


Re: How to add command to ... - antsolen - 06.11.2010

Thanks for that ! I love you all !