Help! :D - 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! :D (
/showthread.php?tid=181941)
Help! :D -
[MKD]Max - 08.10.2010
Hello guys how i want to make when player use commands /ask send client message for admins only i can see it only like lets do /ask for player want help from admins ok and only the admins get it
Re: Help! :D -
[MKD]Max - 08.10.2010
anyhelp !!
Re: Help! :D -
iggy1 - 08.10.2010
Using zcmd and sscanf2 heres a quik one i wrote that should work (unless i missed something) only for rcon as i don't know what admin script you use.
pawn Код:
COMMAND:ask(playerid,params[])
{
new str[128];
if(sscanf(params,"s[128]",str))return SendClientMessage(playerid,0xff0000ffFF,"Error: Usage /ask [message]");
{
for(new i; i < MAX_PLAYERS;i++)
{
if(!IsPlayerConnected(i) || !IsPlayerAdmin(i))continue;
else
{
format(str,sizeof(str),"(%d)%s asks: %s?",playerid,playername(playerid),str);
SendClientMessage(i,0x00ff00AA,str);
}
}
}
return 1;
}
stock playername(playerid)//preferably put this way down at the bottom of the script although it doesn't realy matter.
{
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid,pname,sizeof(pname));
return pname;
}
Re: Help! :D -
Rachael - 08.10.2010
you don't need to use sscanf for commands with only one parameter.
Re: Help! :D -
iggy1 - 08.10.2010
I know its just what i'm used to i should have used params only

with strlen check.
Like this
pawn Код:
COMMAND:ask(playerid,params[])
{
if(!strlen(params))return SendClientMessage(playerid,0xff0000ffFF,"Error: Usage /ask [message]");
{
for(new i; i < MAX_PLAYERS;i++)
{
if(!IsPlayerConnected(i) || !IsPlayerAdmin(i))continue;
else
{
format(params,128,"(%d)%s asks: %s?",playerid,playername(playerid),params);
SendClientMessage(i,0x00ff00AA,str);
}
}
}
return 1;
}
Re: Help! :D -
LarzI - 08.10.2010
Quote:
Originally Posted by iggy1
I know its just what i'm used to i should have used params only  with strlen check.
Like this
pawn Код:
COMMAND:ask(playerid,params[]) { if(!strlen(params))return SendClientMessage(playerid,0xff0000ffFF,"Error: Usage /ask [message]"); { for(new i; i < MAX_PLAYERS;i++) { if(!IsPlayerConnected(i) || !IsPlayerAdmin(i))continue; else { format(params,128,"(%d)%s asks: %s?",playerid,playername(playerid),params); SendClientMessage(i,0x00ff00AA,str); } } } return 1; }
|
Wrong.
Or... It would work, but isnull is more efficient than strlen.
This forum requires that you wait 120 seconds between posts. Please try again in 80 seconds.
Re: Help! :D -
[MKD]Max - 08.10.2010
this way is nice but i need to send for all admins not me only
Re: Help! :D -
iggy1 - 08.10.2010
Quote:
Originally Posted by LarzI
Wrong.
|
Isnull is a seperate function which i don't use. Its not wrong at all. If it was inefficient beyond beleif i'd understand but that won't real make a difference on performance at all, its one command.
Re: Help! :D -
Lenny the Cup - 08.10.2010
Quote:
Originally Posted by iggy1
Isnull is a seperate function which i don't use. Its not wrong at all. If it was inefficient beyond beleif i'd understand but that won't real make a difference on performance at all, its one command.
|
It's not wrong, but there's no point in using strlen when isnull exists, I'm assuming params is at least 169 characters long which means isnull is about 169 times faster than strlen.
OT:
How do you check if someone is an admin? PlayerInfo[playerid][Admin]?
Edit:
Oh, I didn't see my post so I thought it wasn't created
Then change IsPlayerAdmin(i) for PlayerInfo[playerid][admin]
Re: Help! :D -
LarzI - 08.10.2010
Quote:
Originally Posted by iggy1
Isnull is a seperate function which i don't use. Its not wrong at all. If it was inefficient beyond beleif i'd understand but that won't real make a difference on performance at all, its one command.
|
Read my full post, mister.