SA-MP Forums Archive
Making a cmd 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)
+--- Thread: Making a cmd without / (/showthread.php?tid=616208)



Making a cmd without / - StrikerZ - 02.09.2016

Is it possible to make a command without slash (/) ?
Here is the command i want to be called when i type a . (dot)
Код:
CMD:admin(playerid, params[])  {
	if(PlayerInfo[playerid][pAdmin] >= 2) {
		if(!isnull(params)) {

			new
				szMessage[128];

			if(PlayerInfo[playerid][pAdmin] == 2) format(szMessage, sizeof(szMessage), "* Junior Admin %s: %s", GetPlayerNameEx(playerid), params);
			else if(PlayerInfo[playerid][pAdmin] == 3) format(szMessage, sizeof(szMessage), "* General Admin %s: %s", GetPlayerNameEx(playerid), params);
			else if(PlayerInfo[playerid][pAdmin] == 4) format(szMessage, sizeof(szMessage), "* Senior Admin %s: %s", GetPlayerNameEx(playerid), params);
			else if(PlayerInfo[playerid][pAdmin] == 1337) format(szMessage, sizeof(szMessage), "* Head Admin %s: %s", GetPlayerNameEx(playerid), params);
			else if(PlayerInfo[playerid][pAdmin] == 1338) format(szMessage, sizeof(szMessage), "* Lead Head Admin %s: %s", GetPlayerNameEx(playerid), params);
			else if(PlayerInfo[playerid][pAdmin] == 99999) format(szMessage, sizeof(szMessage), "* Executive Admin %s: %s", GetPlayerNameEx(playerid), params);
			else if(PlayerInfo[playerid][pSMod] == 1) format(szMessage, sizeof(szMessage), "* Senior Moderator %s: %s", GetPlayerNameEx(playerid), params);
			else format(szMessage, sizeof(szMessage), "* Undefined Admin (%i) %s: %s", PlayerInfo[playerid][pAdmin], GetPlayerNameEx(playerid), params);

			foreach(new i: Player)
			{
			    if(PlayerInfo[i][pAdmin] >= 2)
			    {
			        SendClientMessage(i, COLOR_YELLOW, szMessage);
			    }
			}
		}
		else SendClientMessageEx(playerid, COLOR_GREY, "USAGE: (/a)dmin [admin chat]");
	}
	return 1;
}



Re: Making a cmd without / - Threshold - 02.09.2016

Yes, but you'll have to use OnPlayerText instead.

Example:
PHP код:
public OnPlayerText(playeridtext[])
{
    if(
text[0] == '.')
    {
        
// Player typed ".something", possibly a .command
        
return 0// return 0 if they did type a command, so it isn't sent to main chat.
    
}
    return 
1;

https://sampwiki.blast.hk/wiki/OnPlayerText


Re: Making a cmd without / - SickAttack - 02.09.2016

^

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '.') // To prevent unnecessary strcmp if-conditions
    {
        if(!strcmp(text, ".admin", true, 6))
        {
            return cmd_admin(playerid, text[7]), 0;
        }
    }
    return 1;
}

CMD:admin(playerid, params[])
{
    printf("called, %s", params);
    return 1;
}