Help please - 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 please (
/showthread.php?tid=159569)
Help please -
bartje01 - 13.07.2010
Hey guys.
I want to make a radio for the mechanics.
how to do this?
I can't just use SendClientMessageToAll.
Because then everyone sees it.I want only that mechanics sees it.
if(mechanic[playerid] >=1)
thats what I use with mechanics.
Please help
Re: Help please -
Hiddos - 13.07.2010
pawn Код:
stock SendClientMessageToMechanics(color, msg[])
{
for(new i; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnect(playerid) || mechanic[playerid] == 0) continue
SendClientMessage(color, msg);
}
}
Re: Help please -
bartje01 - 13.07.2010
And now how make a cmd for it?:P
I have this:
pawn Код:
if(strcmp(cmd, "/r", true) == 0)
{
new text;
new sendername[MAX_PLAYER_NAME];
format(string, sizeof(string), "Mechanic %s Says: %s", sendername, text);
SendClientMessageToMechanics(COLOR_YELLOW, string);
return 1;
}
doesnt work
Thanks btw
Re: Help please -
oliverrud - 13.07.2010
You should really try and use DCMD or ZCMD that's a lot easier for new scripters.
Re: Help please -
bartje01 - 13.07.2010
well, I really want to keep doing strcmp. Don't wanna use anything else :P
Re: Help please -
oliverrud - 13.07.2010
Ah okay, well best of luck
Re: Help please -
[XST]O_x - 13.07.2010
pawn Код:
if(!strcmp(cmdtext, "/r", true, 2))
{
if(mechanic[playerid] < 1) return SendClientMessage(playerid,RED,"You are not a mechanic!");
if(!cmdtext[2]) return SendClientMessage(playerid, RED, "USAGE: /r [chat]");
new string[128],name[24];
GetPlayerName(playerid,name,sizeof(name));
for(new mechanics;mechanics < MAX_PLAYERS; mechanics++)
{
if(IsPlayerConnected(mechanics))
{
if(mechanic[mechanics] >= 1)
{
format(string,sizeof(string),"Mechanic %s Says: %s",name,cmdtext[3]);
SendClientMessage(mechanics,color,string);
}
}
}
return 1;
}
That is basically creating a loop trough all players which are connected,and checks if they are mechanics,if they are,it sends them the message,if they aren't,nothing happens.
Re: Help please -
bartje01 - 13.07.2010
Thanks XST. It works fine
Re: Help please -
[XST]O_x - 13.07.2010
Quote:
Originally Posted by bartje01
Thanks XST. It works fine
|
No problem,but you really should consider starting to work with dcmd+sscanf.
Believe me,I was against moving to it too,but as soon as I did,it became much easier for me.