Help for announce command - 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: Help for announce command (
/showthread.php?tid=248532)
Help for announce command -
mitchboy - 14.04.2011
Hello, I'm making an announce filterscript, finaly it doesn't give errors anymore but now IG it says:
"Unknown command"
Here is my source:
Код:
#define FILTERSCRIPT
#include <a_samp>
#include <sscanf>
#include <zcmd>
forward OnPlayerCommandText(playerid, cmdtext[]);
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/announce", true))
{
if(!IsPlayerAdmin(playerid))
{
if(strlen(cmdtext) < 10)
{
return 1;
}
new gText[128];
format(gText, sizeof(gText), "%s", cmdtext[10]);
GameTextForAll(gText, 5000, 3);
}
}
return 1;
}
Re: Help for announce command -
Seven_of_Nine - 14.04.2011
if you have included zcmd, why don't you use it?
pawn Код:
//Announcer script by Seven_of_Nine :]
COMMAND:announce(playerid,params[]) {
new
poster[40],
mess[128];
sscanf(params,"s",mess);
if(PlayerInfo[playerid][pAdminLevel] >= 3) {
if(!isnull(mess)) {
new text[128];
GetPlayerName(playerid,poster,sizeof(poster));
format(text,sizeof(text),"[Announce] | Administrator \"%s\" has announced his message. (%s)",poster,mess);
SendClientMessageToAll(COLOR_LIGHTBLUE,text);
GameTextForAll(mess,5000,3);
} else {
return SendClientMessage(playerid,red,"USAGE: /announce [message], and all players will see this message on-screen.");
}
} else {
return SendClientMessage(playerid,red,"Only lvl3 admins can use this command. Looking for a way to announce? Try /message!");
}
return 1;
}
btw you should search for it first after ask. same topic opened about 1 hour ago.
Re: Help for announce command -
Sascha - 14.04.2011
first of all:
"forward OnPlayerCommandText(playerid, cmdtext[]);" you don't need to forward the default samp callbacks...
secondly: is it right that it should work for "none rcon admins" only?...
and thirdly: did you even load the filterscript?
Re: Help for announce command -
HyperZ - 14.04.2011
Try this:
pawn Код:
if(strcmp(cmdtext, "/announce", true))
{
new
string[ 128 ],
idx
;
if(!IsPlayerAdmin(playerid)) return 0;
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result)) return SendClientMessage(playerid, -1, "USAGE: /announce [text]");
format(string, sizeof(string), "%s", result);
GameTextForAll(string, 5000, 3);
return 1;
}
Edit: i suggest you to use zcmd
Created With ZCMD:
pawn Код:
COMMAND:announce(playerid,params[])
{
if(isnull(params)) return SendClientMessage(playerid, -1, "USAGE: /announce [Text]");
GameTextForAll(params,5000,3);
return 1;
}