SA-MP Forums Archive
how would i do this? - 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: how would i do this? (/showthread.php?tid=248566)



how would i do this? - CrazyBlob - 14.04.2011

how would i make it so when i type this cmd


/rules

twice it says youve typed it twice...?


thanks do i use like if(count

or somethin ty


Re: how would i do this? - Seven_of_Nine - 14.04.2011

pawn Код:
new twice = 0;
     if(cmdtext == "/rules" && twice == 0) {
          twice++;
     } else {
          twice = 0;
          return SendClientMessage(playerid,red,"You've typed /rules twice!");
     }
}
I don't know.. maybe it works


Re: how would i do this? - CrazyBlob - 14.04.2011

im a bit confused could you explane it - thanks


Re: how would i do this? - Kyle - 14.04.2011

pawn Код:
new RulesAmount[MAX_PLAYERS];
 
     OnplayerConnect(playerid)
     {
         RulesAmount[playerid] = 0;
     }


     if(strcmp(cmd, "/rules", true) == 0)
     {
        if(RulesAmount[playerid] <= 1) { RulesAmount[playerid] ++;
        else
        {
             RulesAmount[playerid] = 0;
             return SendClientMessage(playerid,red,"You've typed /rules twice!");
        }
     }

}



Re: how would i do this? - CrazyBlob - 14.04.2011

k thanks


Re: how would i do this? - Seven_of_Nine - 14.04.2011

corrected:
pawn Код:
new twice = 0; // Creates a variable with the value 0.
     if(cmdtext == "/rules") { //checks we typed /rules
          if(twice == 0) { //if our variable (twice) is still 0, then it adds one (so twice is 1 now.)
          twice++;
          } else { //Now, we've got the twice 1, and typed /rules, so it returns that message:
          twice = 0; //sets twice 0 to repeat the code.
          return SendClientMessage(playerid,red,"You've typed /rules twice!");//sends this message, and it doesnt perform /rules.
     }
}



Re: how would i do this? - Kyle - 14.04.2011

Quote:
Originally Posted by Seven_of_Nine
Посмотреть сообщение
corrected:
pawn Код:
new twice = 0; // Creates a variable with the value 0.
     if(cmdtext == "/rules") { //checks we typed /rules
          if(twice == 0) { //if our variable (twice) is still 0, then it adds one (so twice is 1 now.)
          twice++;
          } else { //Now, we've got the twice 1, and typed /rules, so it returns that message:
          twice = 0; //sets twice 0 to repeat the code.
          return SendClientMessage(playerid,red,"You've typed /rules twice!");//sends this message, and it doesnt perform /rules.
     }
}
Yours will not work, you create a global varible 'twice' you need a player varible.


Re: how would i do this? - Seven_of_Nine - 14.04.2011

I've been minderped! Well, I'm practicing