YCMD Question
#1

How can i make to don't let the player to spam an command in this:
Код:
public e_COMMAND_ERRORS:OnPlayerCommandReceived(playerid, cmdtext[], e_COMMAND_ERRORS:success)
{
	switch(success)
	{
		case COMMAND_UNDEFINED: SCM(playerid, COLOR_WHITE, "ERROR: That command doesn't exists. Type /help!");
	}
	return COMMAND_OK;
}
like to spam only 2 times in a second like that:

i can't spam more than 2 times in a second
Reply
#2

SetTimerEx: https://sampwiki.blast.hk/wiki/SetTimerEx
Reply
#3

What to do with settimerex?? i want to return the command, to don't work if was spammed like in the photo, on my server i can spam the command like 6-7 times on a second
Reply
#4

Quote:
Originally Posted by C0oL3r
Посмотреть сообщение
What to do with settimerex?? i want to return the command, to don't work if was spammed like in the photo, on my server i can spam the command like 6-7 times on a second
Or take a look at this: http://forum.sa-mp.com/showpost.php?...93&postcount=6
It's using ZCMD but it's ok you know how to edit it.
Reply
#5

i can't return 1, i can return COMMAND_OK but it will send the message of the command

or

Код:
public e_COMMAND_ERRORS:OnPlayerCommandReceived(playerid, cmdtext[], e_COMMAND_ERRORS:success)
{
	if(lastcommand[playerid] != 0 && gettime()-lastcommand[playerid] < 3)
	{
		SCM(playerid, COLOR_WHITE, "Calm down!");
		return COMMAND_ZERO_RET;
	}
	switch(success)
	{
		case COMMAND_UNDEFINED: SCM(playerid, COLOR_WHITE, "ERROR: That command doesn't exists. Type /help!");
		case COMMAND_OK: lastcommand[playerid] = gettime();
	}
	return COMMAND_OK;
}
but COMMAND_ZERO_RET it will send "Unknown Command" in chat
Reply
#6

What i need to return to don't send the command, and not Unknown command?
Reply
#7

Quote:
Originally Posted by C0oL3r
Посмотреть сообщение
What i need to return to don't send the command, and not Unknown command?
As I know, it's COMMAND_OK

btw, why don't you try using IZCMD or ZCMD?
Reply
#8

because ycmd is faster and it's good if i have much commands.

And with COMMAND_OK it's not working because it's still running the command and send the messages.

Код:
public e_COMMAND_ERRORS:OnPlayerCommandReceived(playerid, cmdtext[], e_COMMAND_ERRORS:success)
{
	if(lastcommand[playerid] != 0 && gettime()-lastcommand[playerid] < 1)
	{
		return COMMAND_OK;
	}
	switch(success)
	{
		case COMMAND_UNDEFINED: SCM(playerid, COLOR_WHITE, "ERROR: That command doesn't exists. Type /help!");
		case COMMAND_OK: lastcommand[playerid] = gettime();
	}
	return COMMAND_OK;
}
i did something wrong?
Reply
#9

I never used YCMD but let's be logic.

PHP код:
public e_COMMAND_ERRORS:OnPlayerCommandReceived(playeridcmdtext[], e_COMMAND_ERRORS:success)
{
    if(
lastcommand[playerid] != && gettime()-lastcommand[playerid] < 2)
    {
        
SCM(playerid0xFF0000FF"Don't spam commands.");
        return 
COMMAND_OK;
    }
    
    switch(
success)
    {
        case 
COMMAND_UNDEFINEDSCM(playeridCOLOR_WHITE"ERROR: That command doesn't exists. Type /help!");
    }
    
lastcommand[playerid] = gettime();
    return 
COMMAND_OK;

Reply
#10

that's what i said, it's sending the message to don't spam but the command is still running
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)