Help me with my /helpme command xD
#1

This is my /helpme command, after testing it i found out that when a normal player (Who is not a helper) uses this command it sends a message to online helpers But this Doesn't show up for the player
Код:
SendClientMessage(playerid, GREEN, "You have successfully sent a help request, please be patient");
and PlayerStat[playerid][HelpmeReloadTime] isn't set to 61. However if you are a helper and you use this command it will work perfectly. thanks for ur help.

Код:
COMMAND:helpme(playerid, params[])
{
	new message[128], string[128];
	if(PlayerStat[playerid][hMuted] == 1) return SendClientMessage(playerid, GREY, "You are muted from sending help requests.");
    if(sscanf(params,"s[128]", message))return SendClientMessage(playerid, GREY, "USAGE: /helpme [message]");
    if(PlayerStat[playerid][HelpmeReloadTime] > 1) return SendClientMessage(playerid, GREY, "You must wait 10 seconds before sending another help request.");
    for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i) && PlayerStat[i][HelperLevel] >= 1)
		{
		    format(string, sizeof(string), "(( %s (ID: %d) has sent a help request: %s ))", GetOOCName(playerid), playerid, message);
		    SendClientMessage(i, GREEN, string);
		    HelpmeLog(string);
                    SendClientMessage(playerid, GREEN, "You have successfully sent a help request, please be patient");
	            PlayerStat[playerid][HelpmeReloadTime] = 61;
		}
	}
    return 1;
}
Reply
#2

This is because you are not checking if the user is a helper or not, but it will send to helpers because you have PlayerStat[i][HelperLevel] >= 1

pawn Код:
COMMAND:helpme(playerid, params[])
{
    new message[128], string[128];
    if(PlayerStat[playerid][HelperLevel] == 0)return SendClientMessage(playerid, GREY, "Your helper level is too low.");
    if(PlayerStat[playerid][hMuted] == 1) return SendClientMessage(playerid, GREY, "You are muted from sending help requests.");
    if(sscanf(params,"s[128]", message))return SendClientMessage(playerid, GREY, "USAGE: /helpme [message]");
    if(PlayerStat[playerid][HelpmeReloadTime] > 1) return SendClientMessage(playerid, GREY, "You must wait 10 seconds before sending another help request.");
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && PlayerStat[i][HelperLevel] >= 1)
        {
            format(string, sizeof(string), "(( %s (ID: %d) has sent a help request: %s ))", GetOOCName(playerid), playerid, message);
            SendClientMessage(i, GREEN, string);
            HelpmeLog(string);
            SendClientMessage(playerid, GREEN, "You have successfully sent a help request, please be patient");
            PlayerStat[playerid][HelpmeReloadTime] = 61;
        }
    }
    return 1;
}
And use [ pawn ] code in here [ /pawn ] instead of [ code ] code in here [ /code ].
Reply
#3

Why would i check if user is a helper or not? its a /helpme command normal players use this cmd to ask Questions. and helpers must respond..

Sorry for the Bump but after changing the code to one below, its working, (Send the message "You have successfully blah blah.. to player if he uses /helpme) But i really need to know the reason of the problem cause i will use the same type in other commands.

pawn Код:
COMMAND:helpme(playerid, params[])
{
    new message[128], string[128];
    if(PlayerStat[playerid][hMuted] == 1) return SendClientMessage(playerid, GREY, "You are muted from sending help requests.");
    if(sscanf(params,"s[128]", message))return SendClientMessage(playerid, GREY, "USAGE: /helpme [message]");
    if(PlayerStat[playerid][HelpmeReloadTime] > 1) return SendClientMessage(playerid, GREY, "You must wait 60 seconds before sending another help request.");
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && PlayerStat[i][HelperLevel] >= 1)
        {
            format(string, sizeof(string), "(( %s (ID: %d) has sent a help request: %s ))", GetOOCName(playerid), playerid, message);
            SendClientMessage(i, GREEN, string);
            HelpmeLog(string);
        }
    }
    SendClientMessage(playerid, GREEN, "You have successfully sent a help request, please be patient");
    PlayerStat[playerid][HelpmeReloadTime] = 61;
    return 1;
}
Reply
#4

Quote:
Originally Posted by Soumi
Посмотреть сообщение
Why would i check if user is a helper or not? its a /helpme command normal players use this cmd to ask Questions. and helpers must respond..
Sorry for that, I misread the post.

Quote:
Originally Posted by Soumi
Посмотреть сообщение
Sorry for the Bump but after changing the code to one below, its working, (Send the message "You have successfully blah blah.. to player if he uses /helpme) But i really need to know the reason of the problem cause i will use the same type in other commands.

pawn Код:
COMMAND:helpme(playerid, params[])
{
    new message[128], string[128];
    if(PlayerStat[playerid][hMuted] == 1) return SendClientMessage(playerid, GREY, "You are muted from sending help requests.");
    if(sscanf(params,"s[128]", message))return SendClientMessage(playerid, GREY, "USAGE: /helpme [message]");
    if(PlayerStat[playerid][HelpmeReloadTime] > 1) return SendClientMessage(playerid, GREY, "You must wait 60 seconds before sending another help request.");
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && PlayerStat[i][HelperLevel] >= 1)
        {
            format(string, sizeof(string), "(( %s (ID: %d) has sent a help request: %s ))", GetOOCName(playerid), playerid, message);
            SendClientMessage(i, GREEN, string);
            HelpmeLog(string);
        }
    }
    SendClientMessage(playerid, GREEN, "You have successfully sent a help request, please be patient");
    PlayerStat[playerid][HelpmeReloadTime] = 61;
    return 1;
}
Try this:

pawn Код:
COMMAND:helpme(playerid, params[])
{
    new message[128], string[128];
    if(PlayerStat[playerid][hMuted] == 1) return SendClientMessage(playerid, GREY, "You are muted from sending help requests.");
    if(sscanf(params,"s[128]", message))return SendClientMessage(playerid, GREY, "USAGE: /helpme [message]");
    if(PlayerStat[playerid][HelpmeReloadTime] > 1) return SendClientMessage(playerid, GREY, "You must wait 60 seconds before sending another help request.");
    SendClientMessage(playerid, GREEN, "You have successfully sent a help request, please be patient");
    PlayerStat[playerid][HelpmeReloadTime] = 61;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && PlayerStat[i][HelperLevel] >= 1)
        {
            format(string, sizeof(string), "(( %s (ID: %d) has sent a help request: %s ))", GetOOCName(playerid), playerid, message);
            SendClientMessage(i, GREEN, string);
            HelpmeLog(string);
        }
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by Tee
Посмотреть сообщение
Sorry for that, I misread the post.



Try this:

pawn Код:
COMMAND:helpme(playerid, params[])
{
    new message[128], string[128];
    if(PlayerStat[playerid][hMuted] == 1) return SendClientMessage(playerid, GREY, "You are muted from sending help requests.");
    if(sscanf(params,"s[128]", message))return SendClientMessage(playerid, GREY, "USAGE: /helpme [message]");
    if(PlayerStat[playerid][HelpmeReloadTime] > 1) return SendClientMessage(playerid, GREY, "You must wait 60 seconds before sending another help request.");
    SendClientMessage(playerid, GREEN, "You have successfully sent a help request, please be patient");
    PlayerStat[playerid][HelpmeReloadTime] = 61;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && PlayerStat[i][HelperLevel] >= 1)
        {
            format(string, sizeof(string), "(( %s (ID: %d) has sent a help request: %s ))", GetOOCName(playerid), playerid, message);
            SendClientMessage(i, GREEN, string);
            HelpmeLog(string);
        }
    }
    return 1;
}
Its like the code i posted above But i want to know why this

pawn Код:
SendClientMessage(playerid, GREEN, "You have successfully sent a help request, please be patient");
PlayerStat[playerid][HelpmeReloadTime] = 61;
isn't working when i place in
Код:
for(new i = 0; i < MAX_PLAYERS; i++)
Reply
#6

I'm not sure but try this:

pawn Код:
COMMAND:helpme(playerid, params[])
{
    new message[128], string[128];
    if(PlayerStat[playerid][hMuted] == 1) return SendClientMessage(playerid, GREY, "You are muted from sending help requests.");
    if(sscanf(params,"s[128]", message))return SendClientMessage(playerid, GREY, "USAGE: /helpme [message]");
    if(PlayerStat[playerid][HelpmeReloadTime] > 1) return SendClientMessage(playerid, GREY, "You must wait 60 seconds before sending another help request.");
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && PlayerStat[i][HelperLevel] >= 1)
        {
            format(string, sizeof(string), "(( %s (ID: %d) has sent a help request: %s ))", GetOOCName(playerid), playerid, message);
            SendClientMessage(i, GREEN, string);
            HelpmeLog(string);
            return 1;
        }
    }
    SendClientMessage(playerid, GREEN, "You have successfully sent a help request, please be patient");
    PlayerStat[playerid][HelpmeReloadTime] = 61;
    return 1;
}
Reply
#7

Quote:
Originally Posted by Soumi
Посмотреть сообщение
This is my /helpme command, after testing it i found out that when a normal player (Who is not a helper) uses this command it sends a message to online helpers But this Doesn't show up for the player
Код:
SendClientMessage(playerid, GREEN, "You have successfully sent a help request, please be patient");
and PlayerStat[playerid][HelpmeReloadTime] isn't set to 61. However if you are a helper and you use this command it will work perfectly. thanks for ur help.

Код:
COMMAND:helpme(playerid, params[])
{
	new message[128], string[128];
	if(PlayerStat[playerid][hMuted] == 1) return SendClientMessage(playerid, GREY, "You are muted from sending help requests.");
    if(sscanf(params,"s[128]", message))return SendClientMessage(playerid, GREY, "USAGE: /helpme [message]");
    if(PlayerStat[playerid][HelpmeReloadTime] > 1) return SendClientMessage(playerid, GREY, "You must wait 10 seconds before sending another help request.");
    for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i) && PlayerStat[i][HelperLevel] >= 1)
		{
		    format(string, sizeof(string), "(( %s (ID: %d) has sent a help request: %s ))", GetOOCName(playerid), playerid, message);
		    SendClientMessage(i, GREEN, string);
		    HelpmeLog(string);
                    SendClientMessage(playerid, GREEN, "You have successfully sent a help request, please be patient");
	            PlayerStat[playerid][HelpmeReloadTime] = 61;
		}
	}
    return 1;
}
Instead of looping within the command, create a seperate function which will send the message to those who's value is set in the variable. Also, if the reload time doesn't work, show the timer function in which checks the value (in seconds or milliseconds) of the time which has been set.
Reply
#8

I've used loops in commands and they work, also Soumi I forgot to say it but use a timer to set the reload time.
Reply
#9

@Tee i'm not using a timer i have a an function that updates this variable every one second.
Reply
#10

Well, ok, sory for that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)