SA-MP Forums Archive
Command without " / " - 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: Command without " / " (/showthread.php?tid=198883)



Command without " / " - blackwave - 13.12.2010

Everytime I make a command like:

dcmd_lol

it is automatically like: /lol

How can I put it for be a single character? Like Im trying to do a chat group, and wanted the single character:


pawn Код:
&
dcmd or strcmp


Re: Command without " / " - DRIFT_HUNTER - 13.12.2010

Try with:
if(strcmp(cmd, "test", true) ==0 )
{
return 1;
}

or use OnPlayerText....

if(text[0] == '&')
{

}


Re: Command without " / " - JaTochNietDan - 13.12.2010

You can't do it in OnPlayerCommandText, as it is only called when there is a / as the first character.

You need to do it in OnPlayerText, like DRIFT_HUNTER has shown an example of comparing the first character of the text string to the AND character.

Also you should remember that strcmp is not a command processor, it is merely for comparing strings, it would seem you suggested it was a command processor in your post . On the other hand, dcmd is specifically for commands, however you would not be able to use dcmd either for this function, as it uses OnPlayerCommandText, which is only called when you add a / as the first character


Re: Command without " / " - blackwave - 13.12.2010

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
You can't do it in OnPlayerCommandText, as it is only called when there is a / as the first character.

You need to do it in OnPlayerText, like DRIFT_HUNTER has shown an example of comparing the first character of the text string to the AND character.

Also you should remember that strcmp is not a command processor, it is merely for comparing strings, it would seem you suggested it was a command processor in your post . On the other hand, dcmd is specifically for commands, however you would not be able to use dcmd either for this function, as it uses OnPlayerCommandText, which is only called when you add a / as the first character
But can you help me fixing it? It's like: If player team is 0, returns a message. Else, if player team is more or equal to 1, send the message for all online members of same team. Here my code:

pawn Код:
if(text[0] = '&')
    {
    new string[128];
    new string2[128];
    new name[30];
    GetPlayerName(playerid, name, 30);
    format(string, sizeof(string),"GROUP: %s [ID:%d]: %s", name, playerid, text[1]);
    //if (sscanf(text[1], "s[128]",string2)) SendClientMessage(playerid, cinza, "/c <texto>");
    if(GetPlayerTeam(playerid) == 0) return SendClientMessage(playerid, cinza, "Vocк nгo tem grupo ainda!");
    foreach (Player, i)
    {
      if(GetPlayerTeam(playerid) == GetPlayerTeam(i))
      {
        SendClientMessage(i, agua, string);
      }
     
    }
   
    return 0;
    }



AW: Command without " / " - Cank - 13.12.2010

pawn Код:
//OnPlayerText
if(text[0]=='&')
{
      text[0]='/';
      CallLocalFunction("OnPlayerCommandText", "is", playerid, text);
      return 0;
}
or am I wrong?


Re: Command without " / " - Ash. - 13.12.2010

Removed. My bad - wrong section of code


Re: AW: Command without " / " - CyNiC - 13.12.2010

pawn Код:
if(text[0]=='&')
{
      OnPlayerCommandText(playerid, "/example");
      return 0;
}



Re: AW: Command without " / " - Ash. - 13.12.2010

Quote:
Originally Posted by cynic
Посмотреть сообщение
pawn Код:
if(text[0]=='&')
{
      OnPlayerCommandText(playerid, "/example");
      return 0;
}
This wouldnt work... - OnPlayerCommand is a "public" but publics cannot be run in other publics, Only functions can.

This would work, however

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '&')
    {
        new pName[MAX_PLAYER_NAME], string[64];
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        format(string, sizeof(string), "%s: lol", pName); //You could use SAMP 0.3c's colour embedding to make it look better
        SendClientMessage(playerid, COLOUR, string);
    }
    return 1;
}