[HELP]Creating commands that use '!' instead of '/' -
PCheriyan007 - 29.03.2011
I was wondering how I would go about making a command so it would work In-Game but it would look as if it's an IRC Command. For example, say my code is /cookie. What I want to do is to make it !cookie and if I typed an ID then it would give that player a cookie otherwise it would just give the player who did the command the cookie. Here is the code I have so far...
pawn Код:
IRCCMD:cookie(botid, channel[], user[], host[], params[])
{
new playerid;
// Check if the player is connected
if (IsPlayerConnected(playerid))
{
// Echo the formatted message
new cookiemsg[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(cookiemsg, sizeof(cookiemsg), "%s has received a cookie from %s(IRC).", name, user);
IRC_GroupSay(gGroupID, channel, cookiemsg);
format(cookiemsg, sizeof(cookiemsg), "%s has received a cookie from %s(IRC).", name, user);
SendClientMessageToAll(COLOR_ORANGE, cookiemsg);
SetPlayerHealth(playerid,100);
format(cookiemsg, sizeof(cookiemsg), "You have received a cookie from %s(IRC).", name, user);
SendClientMessage(playerid,0x00A765AA,cookiemsg);
}
return 1;
}
What I want to do is for one thing to make the IRC Command so it will not only work for player id 1. I also want to make this command and '!' command. I am using Incognito's IRC Plugin v1.4.1
Re: [HELP]Creating commands that use '!' instead of '/' -
Marricio - 29.03.2011
public onplarrtext
{
if(text[0] == !)
{
if(strcmp(text[0],"!command",true))
{
// bla bla
}
}
return 1;
}
Re: [HELP]Creating commands that use '!' instead of '/' -
Gamer_Z - 29.03.2011
pawn Код:
public OnPlayerText(playerid,text[])
{
if(text[0] == '!')
{
text[0] = '/';
OnPlayerCommandText(playerid,text);
return 0;
}
//your onplayertext code
}
I got up right now, making my vreakfast, so there could be errors..
or:
pawn Код:
public OnPlayerText(playerid,text[])
{
if(text[0] == '!')
{
text[0] = '/';
CallLocalFunction("OnPlayerCommandText","is",playerid,text);
//or
// CallRemoteFunction("OnPlayerCommandText","is",playerid,text);
return 0;
}
//your onplayertext code
}
Re: [HELP]Creating commands that use '!' instead of '/' -
PCheriyan007 - 01.04.2011
Here's my command...
pawn Код:
if(strfind(text,"!say",true)!= -1 )
{
new name[MAX_PLAYER_NAME];
new ircMsg[128];
GetPlayerName(playerid, name, sizeof(name));
format(ircMsg, sizeof(ircMsg), "02[%d] 07%s: %s", playerid, name, text);
AddEcho(ircMsg);
//IRC_GroupSay(gGroupID, IRC_CHANNEL, ircMsg);
return 1;
}
If I type "!say hi", the IRC will also say "!say hi." I'm wondering how do I make it so that "!say" doesn't appear and only the text that the player typed after "!say."
Re: [HELP]Creating commands that use '!' instead of '/' -
admantis - 01.04.2011
Use strdel
Re: [HELP]Creating commands that use '!' instead of '/' -
PCheriyan007 - 01.04.2011
Quote:
Originally Posted by admantis
Use strdel
|
Could you show me an example.
Re: [HELP]Creating commands that use '!' instead of '/' -
PCheriyan007 - 01.04.2011
What I was saying was that when I type in '!say hi' it will say this in the IRC.
Код:
[DR]Sc0pe: !say hey everybody
What I am wondering is how that I would make it say this
Код:
[DR]Sc0pe: hey everybody
My Script...
pawn Код:
if(strfind(text,"!say",true)!= -1 )
{
new name[MAX_PLAYER_NAME];
new ircMsg[128];
GetPlayerName(playerid, name, sizeof(name));
format(ircMsg, sizeof(ircMsg), "[%d] 07%s: %s", playerid, name, text);
AddEcho(ircMsg);
//IRC_GroupSay(gGroupID, IRC_CHANNEL, ircMsg);
return 0;
}
Re: [HELP]Creating commands that use '!' instead of '/' -
admantis - 01.04.2011
pawn Код:
if(strfind(text,"!say",true)!= -1 )
{
new name[MAX_PLAYER_NAME];
new ircMsg[128];
GetPlayerName(playerid, name, sizeof(name));
format(ircMsg, sizeof(ircMsg), "[%d] 07%s: %s", playerid, name, text);
strdel(ircMsg, 0, 4); // 0 is start of string and 4 is the end (!say is 4 char lenght)
AddEcho(ircMsg);
//IRC_GroupSay(gGroupID, IRC_CHANNEL, ircMsg);
return 0;
}
Re: [HELP]Creating commands that use '!' instead of '/' -
PCheriyan007 - 01.04.2011
Quote:
Originally Posted by admantis
pawn Код:
if(strfind(text,"!say",true)!= -1 ) { new name[MAX_PLAYER_NAME]; new ircMsg[128]; GetPlayerName(playerid, name, sizeof(name)); format(ircMsg, sizeof(ircMsg), "[%d] 07%s: %s", playerid, name, text); strdel(ircMsg, 0, 4); // 0 is start of string and 4 is the end (!say is 4 char lenght) AddEcho(ircMsg); //IRC_GroupSay(gGroupID, IRC_CHANNEL, ircMsg); return 0; }
|
It still isn't working. Could someone just instead tell me how to write it as /ircsay. I'm using the default strcmp CMD system.
Re: [HELP]Creating commands that use '!' instead of '/' -
Mean - 01.04.2011
pawn Код:
public OnPlayerText( playerid, text[ ] )
{
if( strcmp( text, "!mycommand", true ) == 0 )
{
// Do your command stuff
return 0; // We must return 0.
}
return 1;
}
Make sure you put it under ONPLAYERTEXT, not ONPLAYERCOMMANDTEXT!!!