Need help a Simple chat not working. -
Harry_Sandhu - 02.08.2011
pawn Код:
CMD:n(playerid, params[])
{
if(PlayerInfo[playerid][pNMuted] == 0)
{
new
Message[128];
if(sscanf(params, "z", Message))
{
SendClientMessage(playerid, ERROR, "SYNTAX: /n [message]");
}
else
{
if(PlayerInfo[playerid][pAdmin] >= 1)
{
new
MsgStr[128];
format(MsgStr, sizeof(MsgStr), "Admin %s: %s", GetName(playerid), Message);
SendNewbieMessage(MsgStr);
}
else if(PlayerInfo[playerid][pHelper] == 1)
{
new
MsgStr[128];
format(MsgStr, sizeof(MsgStr), "Helper %s: %s", GetName(playerid), Message);
SendNewbieMessage(MsgStr);
}
else if(PlayerInfo[playerid][pHelper] == 2)
{
new
MsgStr[128];
format(MsgStr, sizeof(MsgStr), "Mod Helper %s: %s", GetName(playerid), Message);
SendNewbieMessage(MsgStr);
}
else if(PlayerInfo[playerid][pHelper] < 1 && PlayerInfo[playerid][pAdmin] < 1)
{
new
MsgStr[128];
format(MsgStr, sizeof(MsgStr), "Newbie %s: %s", GetName(playerid), Message);
SendNewbieMessage(MsgStr);
PlayerInfo[playerid][pNMuted] = 1;
SetTimerEx("NSpamTimer", 4000, false, "d", playerid);
}
}
}
else
{
SendClientMessage(playerid, ERROR, "You are muted from the newbie chat.");
}
return 1;
}
The problem is the chat is not working properly when there is admin online then only it worx but with a Problem.
When i type /n it dosent show Usage: /n [message]
it shows the message to all that Admin/Helper/Helper Mod %s:
PLZ HELP ME
Re: Need help a Simple chat not working. -
TheArcher - 02.08.2011
Beacuse use
pawn Код:
if(sscanf(params, "s[128]", Message))
not "z"
Note:
Z(string)[length] Invalid optional string
z(string)[length] Deprecated optional string
S(string)[length] Optional string
s[length] String
You need a lenth by using s or z for exemple s[128] as i put above
Re: Need help a Simple chat not working. -
Harry_Sandhu - 02.08.2011
But i can use it if only a Admin is online.
Re: Need help a Simple chat not working. -
TheArcher - 02.08.2011
I dont have the full code to verify everything. Acctualy that command for me is 100% working.
Re: Need help a Simple chat not working. -
Harry_Sandhu - 02.08.2011
I will give you the Full Code
Re: Need help a Simple chat not working. -
TheArcher - 02.08.2011
I didnt found any notice but you can also try this:
pawn Код:
CMD:n(playerid, params[])
{
if(PlayerInfo[playerid][pNMuted] == 0)
{
new
Message[128];
if(sscanf(params, "s[128]", Message))
{
SendClientMessage(playerid, ERROR, "Usage: /n [Message]");
}
else
{
if(PlayerInfo[playerid][pHelper] < 1 && PlayerInfo[playerid][pAdmin] < 1)
{
new
MsgStr[128];
format(MsgStr, sizeof(MsgStr), "Newbie %s: %s", GetName(playerid), Message);
SendClientMessageToAll(COLOR_GREEN, MsgStr);
PlayerInfo[playerid][pNMuted] = 1;
SetTimerEx("NSpamTimer", 4000, false, "d", playerid);
}
else if(PlayerInfo[playerid][pAdmin] >= 1)
{
new
MsgStr[128];
format(MsgStr, sizeof(MsgStr), "* Admin %s: %s", GetName(playerid), Message);
SendClientMessageToAll(COLOR_GREEN, MsgStr);
}
else if(PlayerInfo[playerid][pHelper] == 1)
{
new
MsgStr[128];
format(MsgStr, sizeof(MsgStr), "* Helper %s: %s", GetName(playerid), Message);
SendClientMessageToAll(COLOR_GREEN, MsgStr);
}
else if(PlayerInfo[playerid][pHelper] == 2)
{
new
MsgStr[128];
format(MsgStr, sizeof(MsgStr), "* Helper Mod %s: %s", GetName(playerid), Message);
SendClientMessageToAll(COLOR_GREEN, MsgStr);
}
}
}
else
{
SendClientMessage(playerid, ERROR, "You are muted from the newbie chat.");
}
return 1;
}
P.S Optimize the code beacuse i couldnt here.
Re: Need help a Simple chat not working. -
Harry_Sandhu - 02.08.2011
Nop it not worked still when i am not admin then i cant use it.
Re: Need help a Simple chat not working. -
TheArcher - 02.08.2011
Try to use this then:
pawn Код:
CMD:n(playerid, params[])
{
if(PlayerInfo[playerid][pNMuted] == 0) SendClientMessage(playerid, ERROR, "You are muted from the newbie chat.");
new
Message[128];
if(sscanf(params, "s[128]", Message))
{
SendClientMessage(playerid, ERROR, "Usage: /n [Message]");
}
else
{
if(PlayerInfo[playerid][pHelper] < 1 && PlayerInfo[playerid][pAdmin] < 1)
{
new
MsgStr[128];
format(MsgStr, sizeof(MsgStr), "Newbie %s: %s", GetName(playerid), Message);
SendClientMessageToAll(COLOR_GREEN, MsgStr);
PlayerInfo[playerid][pNMuted] = 1;
SetTimerEx("NSpamTimer", 4000, false, "d", playerid);
}
else
{
if(PlayerInfo[playerid][pAdmin] >= 1)
{
new
MsgStr[128];
format(MsgStr, sizeof(MsgStr), "* Admin %s: %s", GetName(playerid), Message);
SendClientMessageToAll(COLOR_GREEN, MsgStr);
}
else if(PlayerInfo[playerid][pHelper] == 1)
{
new
MsgStr[128];
format(MsgStr, sizeof(MsgStr), "* Helper %s: %s", GetName(playerid), Message);
SendClientMessageToAll(COLOR_GREEN, MsgStr);
}
else if(PlayerInfo[playerid][pHelper] == 2)
{
new
MsgStr[128];
format(MsgStr, sizeof(MsgStr), "* Helper Mod %s: %s", GetName(playerid), Message);
SendClientMessageToAll(COLOR_GREEN, MsgStr);
}
}
}
return 1;
}
Re: Need help a Simple chat not working. -
Harry_Sandhu - 02.08.2011
It just says that YOu are Muted from newbie chat.
Re: Need help a Simple chat not working. -
Harry_Sandhu - 02.08.2011
It says that you are muted from newbie chat.