Loop question
#1

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!
Reply
#2

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.
Reply
#3

Wow, thanks man! It works!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)