Leader chat -
T_Boy - 29.12.2012
Hello! I made this command but I cannot make it work properly. It has three variables, but it doesn't support text. If I say something like: /le Hello! it says: SERVER:UNKNOWN COMMAND; but if I type only the command (/le) it says: Grove leader T_Boy: 0
Can you help me?
if (strcmp("/le", cmdtext, true, 10) == 0)
{
new
string[128],
leader[28],
orgname[118],
text[100];
if(sscanf("s[100]",text)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /le [text]");
if(!IsLeader(playerid)) return SendClientMessage(playerid, COLOR_YELLOW, "You are not a leader!");
GetPlayerName(playerid, leader, sizeof(leader));
orgname = GetOrgName(PlayerOrg[playerid]);
format(string,sizeof(string), "%s leader %s: %d", orgname, leader, text);
SendClientMessageToLeaders(0xB6BAFFFF,string);
return 1;
}
Re: Leader chat -
B-Matt - 29.12.2012
format(string,sizeof(string), "%s leader %s:
%d", orgname, leader,
text);
Text is a string not the integer.
Re: Leader chat -
T_Boy - 29.12.2012
format(string,sizeof(string), "%s leader %s: %s", orgname, leader, text);
Still not working!
Re: Leader chat -
xMCx - 29.12.2012
pawn Код:
if (strcmp("/le", cmdtext, true, 10) == 0)
{
new
string[128],
leader[24],
orgname[118],
text[100];
if(!IsLeader(playerid)) return SendClientMessage(playerid, COLOR_YELLOW, "You are not a leader!");
if(isnull(params)) return SendClientMessage(playerid, COLOR_YELLOW,"Usage: /le [text]");
GetPlayerName(playerid, leader, sizeof(leader));
orgname = GetOrgName(PlayerOrg[playerid]);
format(string,sizeof(string), "%s leader %s: %s", orgname, leader, text);
SendClientMessageToLeaders(0xB6BAFFFF,string);
return 1;
}
if that didnt work post your SendClientMessageToLeaders Function
Re: Leader chat -
YoYo123 - 29.12.2012
The above will give you an error because 'params' is not defined.
Try this:
pawn Код:
if (strcmp("/le", cmdtext, true, 10) == 0)
{
new
string[128],
leader[28],
orgname[118],
text[100];
if(sscanf(cmdtext, "s[100]",text)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /le [text]");
if(!IsLeader(playerid)) return SendClientMessage(playerid, COLOR_YELLOW, "You are not a leader!");
GetPlayerName(playerid, leader, sizeof(leader));
orgname = GetOrgName(PlayerOrg[playerid]);
format(string,sizeof(string), "%s leader %s: %d", orgname, leader, text);
SendClientMessageToLeaders(0xB6BAFFFF,string);
return 1;
}
Re: Leader chat -
Konstantinos - 29.12.2012
I would recomment you since you are using sscanf, to switch to ZCMD because it's faster and better than strcmp.
Last, the lenght of "/le" is not 10, but 3.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/le", true))
{
new
text[100]
;
if(sscanf(cmdtext, "s[100]",text)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /le [text]");
if(!IsLeader(playerid)) return SendClientMessage(playerid, COLOR_YELLOW, "You are not a leader!");
new
string[128],
leader[ MAX_PLAYER_NAME ],
orgname[118]// it should be lower
;
GetPlayerName(playerid, leader, sizeof(leader));
orgname = GetOrgName(PlayerOrg[playerid]);
format(string,sizeof(string), "%s leader %s: %s", orgname, leader, text);
SendClientMessageToLeaders(0xB6BAFFFF,string); // Make sure that function is called.
print(string);// Debug
return 1;
}
return 0;
}
Re: Leader chat -
T_Boy - 29.12.2012
Quote:
Originally Posted by xMCx
pawn Код:
if (strcmp("/le", cmdtext, true, 10) == 0) { new string[128], leader[24], orgname[118], text[100];
if(!IsLeader(playerid)) return SendClientMessage(playerid, COLOR_YELLOW, "You are not a leader!"); if(isnull(params)) return SendClientMessage(playerid, COLOR_YELLOW,"Usage: /le [text]"); GetPlayerName(playerid, leader, sizeof(leader)); orgname = GetOrgName(PlayerOrg[playerid]); format(string,sizeof(string), "%s leader %s: %s", orgname, leader, text); SendClientMessageToLeaders(0xB6BAFFFF,string); return 1; }
if that didnt work post your SendClientMessageToLeaders Function
|
Quote:
Originally Posted by YoYo123
The above will give you an error because 'params' is not defined.
Try this:
pawn Код:
if (strcmp("/le", cmdtext, true, 10) == 0) { new string[128], leader[28], orgname[118], text[100];
if(sscanf(cmdtext, "s[100]",text)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /le [text]"); if(!IsLeader(playerid)) return SendClientMessage(playerid, COLOR_YELLOW, "You are not a leader!"); GetPlayerName(playerid, leader, sizeof(leader)); orgname = GetOrgName(PlayerOrg[playerid]); format(string,sizeof(string), "%s leader %s: %d", orgname, leader, text); SendClientMessageToLeaders(0xB6BAFFFF,string); return 1; }
|
Not working
![Sad](images/smilies/sad.gif)
(
Re: Leader chat -
T_Boy - 29.12.2012
Not working either!
Re: Leader chat -
T_Boy - 29.12.2012
Hmmm. Now I seen that /s and /me also doesn't work, but they worked! Why
Re: Leader chat -
Konstantinos - 29.12.2012
No idea, if you returned false. Anyway, the best solution for it is to replace all the commands with strcmp to ZCMD. It's much faster and easier.