SA-MP Forums Archive
Need Help - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Need Help (/showthread.php?tid=153502)



Need Help - xinix000 - 09.06.2010

How can auto kick player when using same command for 3 times ??


Re: Need Help - DJDhan - 09.06.2010

Do you want it for all commands or only one?

Код:
new timesused;
new oldcommand[128];
new newcommand[128];
Then you basically check if oldcommand is same is new command an stuff. Not sure how you will go about doing that. But you will need to get old command and new command in each command you want to do this for.


Re: Need Help - Maxips2 - 09.06.2010


Quote:

new timesused[MAX_PLAYERS];

Quote:

if (strcmp(cmd, "/command", true) == 0)
{
// Something here
timesused[playerid]++
if(timesused[playerid] > 2)
{
Kick(playerid);
}
return 1;
}

Try that, I haven't tested it.


Re: Need Help - Ignas1337 - 09.06.2010

and obviously if 3 times in a row, then add another if at the beginning of onPlayerCommandText
something like:

pawn Код:
if(!strcmp(cmd, "/command", true) == 0){
timesused[playerid] = 0;
}



Re: Need Help - DJDhan - 09.06.2010

It's a very tricky question :P

How is it possible to get the command entered 3 times in a row.MMMMMMMMMM

I know
Take these three commands for eg:
Код:
new bool:firstcmd[MAX_PLAYERS];
new helpcmd[MAX_PLAYERS];
new mecmd[MAX_PLAYERS];
new killcmd[MAX_PLAYERS];
Under OnPlayerConnect
Код:
firstcmd[playerid]=true;
OnPlayerCommandText

Код:
if(!strcmp(cmdtext,"/help",5,true))
{
  if(firstcmd[playerid]==true)
  {
    firstcmd[playerid]=false;
    helpcmd[playerid]++;
  }
  else helpcmd++;
  killcmd[playerid]=0;
  mecmd[playerid]=0;

//your helpcode

  if(helpcmd[playerid]>3)
  {
    Kick(playerid);
  }
  return 1;
}

if(!strcmp(cmdtext,"/me",3,true))
{
  if(firstcmd[playerid]==true)
  {
    firstcmd[playerid]=false;
    mecmd[playerid]++;
  }
  else mecmd[playerid]++;
  killcmd[playerid]=0;
  helpcmd[playerid]=0;
  //your me code
  if(mecmd[playerid]>3)
  {
    Kick(playerid);
  }

  return 1;
}

if(!strcmp(cmdtext,"/kill",5,true))
{
  if(firstcmd[playerid]==true)
  {
    firstcmd[playerid]=false;
    killcmd[playerid]++;
  }
  else killcmd[playerid]++;
  mecmd[playerid]=0;
  helpcmd[playerid]=0;

//your kill code

  if(killcmd[playerid]>3)
  {
    Kick(playerid);
  }

  return 1;
}
How about that?


Re: Need Help - xinix000 - 09.06.2010

It's show the error when i complie

: error 033: array must be indexed (variable "firstcmd")
: error 033: array must be indexed (variable "firstcmd")
: error 022: must be lvalue (non-constant)


Re: Need Help - DJDhan - 09.06.2010

Oops, I modified my post try it now. :P