[NeedHelp] - 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: [NeedHelp] (
/showthread.php?tid=452144)
[NeedHelp] -
kartik - 20.07.2013
First , I dont know why my previous topic was deleted ! So if by mistake I broke a rule please pm me ..
Here's the question :
stock SendAdminMessage(text[])
{
for (new pid; pid<MAX_PLAYERS; pid++)
{
If(IsPlayerAdmin(pid)
{
SendClientMessage(pid,SOME_COLOR,GetPlayerName(pid )+":"+text);
return 1;
}
}
}
//after including zcmd
CMD:a(playerid,params[])
{
SendAdminMessage(params);
return 1;
}
//this code compiles fine but nothing shows up when i do /a some text here
//also dos not show an UNKNOWN COMMAND error
//what to do ?
Re: [NeedHelp] -
Threshold - 20.07.2013
pawn Код:
stock SendAdminMessage(const text[])
{
for(new pid = 0; pid < MAX_PLAYERS; pid++)
{
if(IsPlayerAdmin(pid))
{
SendClientMessage(pid, -1, text);
}
}
return 1;
}
//after including zcmd
CMD:a(playerid,params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You are not an admin.");
SendAdminMessage(params);
return 1;
}
Basically, by putting 'return 1' INSIDE the loop, it is ending it and will not continue past the first matching player. Also, this shouldn't be compiling successfully, there are missing brackets and possibly undefined variables in this code. Try the code I've given and see how it works for you.
EDIT: Also read the below poster's, as I was going to mention logging into RCON, but his post was submitted before I could edit it.
Re: [NeedHelp] -
JaKe Elite - 20.07.2013
first of all.
You make sure you're RCON Logged in?
Second use sscanf, or use the isnull made up function to check if the string inputted is null.
Then if it is not, Make it sendable like this
pawn Код:
if(isnull(params)) return //SendClientMessage
new string[128];
format(string, 128, "CHAT: %s", params);
SendAdminMessage(params);
Re: [NeedHelp] -
kartik - 20.07.2013
Thanks a lot ...I just realized i should not forget to initialize pointers