AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Count (https://forums.alliedmods.net/showthread.php?t=2255)

Nick 05-30-2004 17:04

Count
 
How would you make a count, so that it knows how many times you have used a command on the player.

xeroblood 05-30-2004 19:50

a global variable.. increment it each time you run the command..

(global variables are any variables declared at the top of the code (usually) )

Nick 05-30-2004 20:07

Can you post an example

AssKicR 05-30-2004 20:56

Code:
new noob public NotNoob(id) {      noob+=1      client_cmd(id,"say I'm not a noob")      server_cmd("say YES U ARE!!!!!!!!!!") } public plugin_init() {     register_plugin("NOOB","1337","Lamer")     register_clcmd("notanoob","NotNoob",0,"NOOB!!!") }

Nick 05-30-2004 21:53

Thanks alot

Nick 05-30-2004 22:06

ok how about something like this:
1st time command used on player - slap
2nd time command use don player - slay
3rd command on player - kick

PM 05-31-2004 06:20

Code:
new g_CmdCounter[32];   // 32 - every player has a separate counter public client_connect(id) {      g_CmdCounter[id] = 0;    // Reset counter for this client } public cmd(id) {      switch (++g_CmdCounter[id])      {      case 1:           // first time command used      case 2:           // second time      case 3:           // third time      }      return PLUGIN_HANDLED; } public plugin_init() {     register_plugin("NOOB","1337","Lamer")     register_clcmd("cmd", "cmd"); }

That could work

Nick 05-31-2004 19:43

Hey thanks alot that helps a bunch :)

Nick 05-31-2004 20:31

Alright I got this error but Im not sure what it means.

Code:

error 002: only a single statement (or expression) can follow each "case"

Burnzy 05-31-2004 20:51

show us ur script that gives the error


All times are GMT -4. The time now is 07:02.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.