Loop question - 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: Loop question (
/showthread.php?tid=333094)
Loop question -
Jstylezzz - 10.04.2012
Hello SA-MP,
I was wondering if it's possible to make a command, helpme, and that what the player types, like /helpme idk what to do, that it send "helpme idk what to do" to all players who have PVar(playerid,"helper")==1).
This is what i have now:
Код:
CMD:helpme(playerid,params[ ])
{
if ( sscanf( params, "ui", params[ 0 ]) )
return SendClientMessage( playerid,COLOR_YELLOW,"Please leave a message so the helpers can help you!");
SendClientMessage(playerid,COLOR_YELLOW,"Your help message was sent to all the helpers online!");
for(new all = 0; all < MAX_PLAYERS; all++)
{
if(GetPVarInt(playerid,"Helper") == 1)
{
new helper = GetPVarInt(all,"Helper");
new string[84];
format(string, sizeof(string), params ,RemoveUnderScore(playerid));
SendClientMessage(helper, COLOR_LIGHTBLUE, string);
}
}
return 1;
}
The problem is, it works, but the first letter is replaced by a я and it sends it 100 times or something, for example, when i type /helpme test it sends яest 100x..
Does anyone know how to fix this code?, or am I trying this the wrong way..
please tell!
Re: Loop question -
[HiC]TheKiller - 10.04.2012
pawn Код:
cmd:helpme(playerid, params[])
{
if( sscanf( params, "s", params) ) return SendClientMessage( playerid,COLOR_YELLOW,"Please leave a message so the helpers can help you!");
new pname[24];
GetPlayerName(playerid, pname, 24);
new string[130];
format(string, sizeof(string), "%s(%d) is asking: %s", pname, playerid, params);
for(new i; i<MAX_PLAYERS; i++)
{
if(GetPVarInt(i,"Helper") != 1) continue;
SendClientMessage(i, COLOR_LIGHTBLUE, string);
}
return 1;
}
Try this or something like this.
Re: Loop question -
Jstylezzz - 10.04.2012
Wow, thanks man! It works!