PDA

View Full Version : Loop question


Jstylezzz
10/04/2012, 10:09 AM
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!

[HiC]TheKiller
10/04/2012, 10:16 AM
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.

Jstylezzz
10/04/2012, 10:21 AM
Wow, thanks man! It works!